Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Impose Mixture Phase During Creation #44

Closed
lestephen opened this issue Sep 28, 2024 · 3 comments · Fixed by #45
Closed

Unable to Impose Mixture Phase During Creation #44

lestephen opened this issue Sep 28, 2024 · 3 comments · Fixed by #45
Assignees
Labels
enhancement New feature or request

Comments

@lestephen
Copy link

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 using with_state.

This prevents the creation of complex mixture such as:

mixture = Mixture([FluidsList.Nitrogen, FluidsList.Oxygen, FluidsList.CarbonDioxide, FluidsList.Argon, FluidsList.Water],
[72.37, 11.33, 2.03, 00.87, 13.4]).with_state(
Input.pressure(101449), Input.temperature(623.706))

which yields the following error:

ValueError: One stationary point (not good) for T=623.706,p=101449,z=[ 0.689054749976, 0.0944405350566, 0.0123029388101, 0.00580880011636, 0.198392976041 ]

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):

CP.PropsSI('D','T|gas',896.856,'P',101449,'HEOS::Nitrogen[0.7237]&Oxygen[0.1133]&CarbonDioxide[0.0203]&Argon[0.0087]&Water[0.134]')

Could Input.pressure() or Input.temperature() be modified so that a second optional parameter is an imposed phase?

@portyanikhin
Copy link
Owner

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?

@portyanikhin portyanikhin self-assigned this Sep 29, 2024
@portyanikhin portyanikhin added the enhancement New feature or request label Sep 29, 2024
@lestephen
Copy link
Author

Thanks for responding so quickly. Yes, I think this is a better solution than what I had proposed.

@portyanikhin
Copy link
Owner

Ok, I'll implement it soon👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants