Skip to content

Add PropsSImulti function - #51

Open
spinnau wants to merge 3 commits into
CoolProp:masterfrom
spinnau:fix-22
Open

Add PropsSImulti function#51
spinnau wants to merge 3 commits into
CoolProp:masterfrom
spinnau:fix-22

Conversation

@spinnau

@spinnau spinnau commented Jul 8, 2026

Copy link
Copy Markdown
  • Implements the PropsSImulti function using ccall on the appropriate function from the CoolProp C-interface. Thus, most of the work ist done by CoolProp, e.g. returning Inf for single value pairs with calculation errors and extraction of fractions from the fluid string.
  • Overloads PropsSI.() broadcasting to internally use PropsSImulti. This avoids the AbstractState allocation overhead for each state pair and allows to use PropsSImulti with the PropsSI call signature like in the Python wrapper.
  • Adds test for PropsSImulti and PropsSI.() calls.

Fix #22

Summary by CodeRabbit

  • New Features

    • Added a new multi-output API for bulk thermodynamic property calculations in a single call.
    • Enabled broadcasting of property queries across vector and scalar inputs for batch-style usage.
    • Introduced an additional public API alias for multi-value evaluation.
  • Tests

    • Expanded validation for multi-parameter and mixture-based property calculations using reference values, including both array and scalar pressure scenarios.

* Implements the `PropsSImulti` function using `ccall` on the appropriate
  function from the CoolProp C-interface.
* Overloads `PropsSI.()` broadcasting to internally use `PropsSImulti`.
  This avoids the `AbstractState` allocation overhead for each state pair.
* Adds test for `PropsSImulti` and `PropsSI.()` calls.

Fix CoolProp#22
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds PropsSImulti for multi-evaluation property calls, a PropsSI broadcast method that delegates to it, export wiring for the new API, and tests covering mixture density results.

Changes

PropsSImulti Implementation

Layer / File(s) Summary
Core implementation and broadcasting support
src/CoolProp.jl
Adds Base.Broadcast import, implements PropsSImulti with output/state sizing, ccall into libcoolprop, matrix reshaping, and zero-size error handling, and adds a broadcasted(::typeof(PropsSI), ...) method that normalizes inputs and delegates to PropsSImulti.
Export wiring and test coverage
src/CoolProp.jl, test/runtests.jl
Adds PropsSImulti to the exported symbol list and adds assertions for PropsSImulti and PropsSI. results against fixed reference densities for a predefined mixture.

Poem

A rabbit hops through states galore,
One call now checks a whole wide score.
PropsSImulti sings, PropsSI streams,
Density hops through testing dreams. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding PropsSImulti.
Linked Issues check ✅ Passed The PR implements #22 by adding PropsSImulti and routing broadcasted PropsSI calls through it for batched evaluation.
Out of Scope Changes check ✅ Passed No unrelated changes stand out; the broadcast overload, exports, and tests all support the PropsSImulti feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@spinnau

spinnau commented Jul 8, 2026

Copy link
Copy Markdown
Author

I have tested this on Linux x64 and Windows x64.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/runtests.jl (1)

48-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for scalar value1 + vector value2 and for multiple outputs.

Both new assertions pass a vector as value1 and a scalar as value2, so they miss the broadcasted bug (see src/CoolProp.jl Line 212) and the multi-output reshape path. A case like PropsSI.("D", "T", 300, "P", [101325, 101325], "R125[0.5]&R32[0.5]") and a "D,H" PropsSImulti assertion would guard both.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/runtests.jl` around lines 48 - 50, The current tests in
PropsSI/PropsSImulti only cover vector value1 with scalar value2, so they do not
exercise the broadcasted path in PropsSI or the multi-output reshape behavior in
PropsSImulti. Add a PropsSI. test that uses scalar value1 and vector value2, and
add a PropsSImulti assertion with multiple outputs (for example including both D
and H) to verify the reshape logic and catch the broadcasted bug in
CoolProp.jl’s PropsSI handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/CoolProp.jl`:
- Around line 208-223: The `broadcasted(::typeof(PropsSI), ...)` method computes
`size_values` from `value1` twice, so scalar `value1` with vector `value2` gets
the wrong broadcast size. Fix the size calculation to use both inputs’ lengths
in `broadcasted` before normalizing `value1` and `value2`, ensuring the scalar
is expanded to match the vector and the arguments passed to `PropsSImulti` stay
the same length. Update the logic in `broadcasted` so it correctly handles
either side being the scalar.

---

Nitpick comments:
In `@test/runtests.jl`:
- Around line 48-50: The current tests in PropsSI/PropsSImulti only cover vector
value1 with scalar value2, so they do not exercise the broadcasted path in
PropsSI or the multi-output reshape behavior in PropsSImulti. Add a PropsSI.
test that uses scalar value1 and vector value2, and add a PropsSImulti assertion
with multiple outputs (for example including both D and H) to verify the reshape
logic and catch the broadcasted bug in CoolProp.jl’s PropsSI handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c6ce669b-a93f-40f2-8d06-65ccaa60caf4

📥 Commits

Reviewing files that changed from the base of the PR and between 46a2496 and 88d7492.

📒 Files selected for processing (2)
  • src/CoolProp.jl
  • test/runtests.jl

Comment thread src/CoolProp.jl

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/runtests.jl (1)

49-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a test for the "backend::fluid" notation in PropsSI. broadcast.

The broadcasted method in src/CoolProp.jl explicitly handles the occursin("::", fluid) case to extract a custom backend, but none of the new tests exercise this path. All broadcast tests use the default "HEOS" backend. Adding a test like PropsSI.("D", "T", [300, 350], "P", 101325, "REFPROP::R125[0.5]&R32[0.5]") would validate the backend extraction logic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/runtests.jl` around lines 49 - 52, Add a broadcast test in
test/runtests.jl that exercises PropsSI. with a fluid string using the
"backend::fluid" form so the broadcasted path in src/CoolProp.jl that checks
occursin("::", fluid) is covered. Use a case like PropsSI. over
temperature/pressure inputs with "REFPROP::R125[0.5]&R32[0.5]" and assert the
expected density results, alongside the existing PropsSI. tests that currently
only cover the default HEOS backend.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/runtests.jl`:
- Around line 49-52: Add a broadcast test in test/runtests.jl that exercises
PropsSI. with a fluid string using the "backend::fluid" form so the broadcasted
path in src/CoolProp.jl that checks occursin("::", fluid) is covered. Use a case
like PropsSI. over temperature/pressure inputs with
"REFPROP::R125[0.5]&R32[0.5]" and assert the expected density results, alongside
the existing PropsSI. tests that currently only cover the default HEOS backend.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bb5c0e6-fa59-44e7-9e2c-936232399f34

📥 Commits

Reviewing files that changed from the base of the PR and between 88d7492 and 5e339d5.

📒 Files selected for processing (2)
  • src/CoolProp.jl
  • test/runtests.jl
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/CoolProp.jl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create PropsSImulti()

1 participant