Dears,
I´m using with great success the Coolprop wrapper, but one challenging task is to form the "mixture" string.
Air for instance must be written as: "O2[0.21]&N2[0.79]"
When working with complex mixtures, like up to 10 components, my idea was to use a table and extract a "concat" function from the table. All good doing it the hard way:
(...)
Problem: if I add or remove one of the 10 components from the table, maybe for a simpler composition, then the formula for "mixture" would fail.
Solution: maybe write a program? But don´t even know how to start.
Any help would be great.
Best regards,
Fred.
Solved! Go to Solution.
Here is a function which creates the string, including zero values
Here is a slight modification so that zero values are omitted
And here is a function which can do both, depending on its third argument
Attached file is in format P9. Maybe someone ( @LucMeekes ?) can convert it to P8 format or lower.
EDIT: There were copy & paste errors in the first version of the functions. Is now fixed.
Should be no problem.
But I don't know Coolprop and the syntax that is needed there.
Is it necessary to include names with a mol_frac of zero or could we simply omit them?
Many thanks!
The string syntax is "component_name[mol%]&component_name[mol%]& ... etc".
The requirements are, the sum must be = 1 and the component name must follow the Coolprop library.
If the mol fraction is zero, both show or omit is ok, For example:
Air: "O2[0.21]&N2[0.79]"
Only oxygen: "O2[1]&N2[0]" or "O2[1]", all ok
In advance, many thanks for the help.
Best regards,
Fred.
Here is a function which creates the string, including zero values
Here is a slight modification so that zero values are omitted
And here is a function which can do both, depending on its third argument
Attached file is in format P9. Maybe someone ( @LucMeekes ?) can convert it to P8 format or lower.
EDIT: There were copy & paste errors in the first version of the functions. Is now fixed.
Here's the file in Prime6.
Success!
Luc
Dear Werner,
I can´t thank you enough, it is just perfect and elegant. It also helped me a lot to learn more about programming.
Best regards,
Fred.