Closed lestephen closed 1 month ago
Hi, @lestephen!
I think your solution is somewhat counterintuitive and imposes unnecessary obligations on the user if he wants to extend the Input
class (I mean this example).
If we can do something like that now:
from pyfluids import Mixture, FluidsList, Input, Phases
mixture = Mixture(
[
FluidsList.Nitrogen,
FluidsList.Oxygen,
FluidsList.CarbonDioxide,
FluidsList.Argon,
FluidsList.Water,
],
[72.37, 11.33, 2.03, 0.87, 13.4],
)
mixture.specify_phase(Phases.Gas)
mixture.update(Input.pressure(101449), Input.temperature(623.706))
print(mixture.density)
Then the best solution would be to return an instance of the Fluid
or Mixture
from the specify_phase
/ unspecify_phase
method. With this, we will be able to do the following:
from pyfluids import Mixture, FluidsList, Input, Phases
mixture = (
Mixture(
[
FluidsList.Nitrogen,
FluidsList.Oxygen,
FluidsList.CarbonDioxide,
FluidsList.Argon,
FluidsList.Water,
],
[72.37, 11.33, 2.03, 0.87, 13.4],
)
.specify_phase(Phases.Gas)
.with_state(Input.pressure(101449), Input.temperature(623.706))
)
print(mixture.density)
What do you think?
Thanks for responding so quickly. Yes, I think this is a better solution than what I had proposed.
Ok, I'll implement it soon👌
While
specify_phase
is available to specify mixture phase after the creation of the mixture object, there does not appear to be a mechanism for specifying the phase usingwith_state
.This prevents the creation of complex mixture such as:
which yields the following error:
This mixture can be created using CoolProp's Python bindings with the following code, which imposes a
gas
phase constraint (note that temperature units are K):Could Input.pressure() or Input.temperature() be modified so that a second optional parameter is an imposed phase?