-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fugacity functions update #35
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1fa8409
add fugacity funcs compatible with Sept 2023 CoolProp master branch
chris-hampel-CA 512082e
fix fugacity output type specification
chris-hampel-CA 2b7766c
Update version and fix test
barche 39e55fd
Fix up buffer length for fugacity functions
barche 1198e1a
Remove some TODOs
barche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -926,6 +926,63 @@ function AbstractState_update(handle::Clong, input_pair::AbstractString, value1: | |
return nothing | ||
end | ||
|
||
#TODO: these functions will not work with CoolProp_jll 6.5. Needs new version released of current master from Sept 2023 | ||
""" | ||
AbstractState_get_fugacity(handle::Clong, i::Integer) | ||
|
||
Return the fugacity of species `i` | ||
|
||
# Arguments | ||
* `handle`: The integer handle for the state class stored in memory | ||
* `i`: The index of the species | ||
|
||
# Example | ||
```julia | ||
julia> handle = AbstractState_factory("HEOS", "Water&Ethanol"); | ||
julia> pq_inputs = get_input_pair_index("PQ_INPUTS"); | ||
julia> t = get_param_index("T"); | ||
julia> AbstractState_set_fractions(handle, [0.4, 0.6]); | ||
julia> AbstractState_update(handle, pq_inputs, 101325, 0); | ||
julia> AbstractState_get_fugacity(handle, 0) | ||
30227.119385400914 | ||
julia> AbstractState_free(handle); | ||
``` | ||
""" | ||
function AbstractState_get_fugacity(handle::Clong, i::Integer) | ||
buffer_length = length(message_buffer) | ||
output = ccall( (:AbstractState_get_fugacity, libcoolprop), Cdouble, (Clong, Clong, Ref{Clong}, Ptr{UInt8}, Clong), handle, i, errcode, message_buffer::Array{UInt8, 1}, buffer_length) | ||
raise(errcode, message_buffer) | ||
return output | ||
end | ||
|
||
""" | ||
AbstractState_get_fugacity_coefficient(handle::Clong, i::Real) | ||
|
||
Return the fugacity coefficient of species `i` | ||
|
||
# Arguments | ||
* `handle`: The integer handle for the state class stored in memory | ||
* `i`: The index of the species | ||
|
||
# Example | ||
```julia | ||
julia> handle = AbstractState_factory("HEOS", "Water&Ethanol"); | ||
julia> pq_inputs = get_input_pair_index("PQ_INPUTS"); | ||
julia> t = get_param_index("T"); | ||
julia> AbstractState_set_fractions(handle, [0.4, 0.6]); | ||
julia> AbstractState_update(handle, pq_inputs, 101325, 0); | ||
julia> AbstractState_get_fugacity_coefficient(handle, 0) | ||
0.7457961851803392 | ||
julia> AbstractState_free(handle); | ||
``` | ||
""" | ||
function AbstractState_get_fugacity_coefficient(handle::Clong, i::Integer) #TODO: maybe type this as an integer? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove TODO comment |
||
buffer_length = length(message_buffer) | ||
output = ccall( (:AbstractState_get_fugacity_coefficient, libcoolprop), Cdouble, (Clong, Clong, Ref{Clong}, Ptr{UInt8}, Clong), handle, i, errcode, message_buffer::Array{UInt8, 1}, buffer_length) | ||
raise(errcode, message_buffer) | ||
return output | ||
end | ||
|
||
""" | ||
AbstractState_keyed_output(handle::Clong, param::Clong) | ||
|
||
|
@@ -1435,7 +1492,7 @@ function AbstractState_all_critical_points(handle::Clong, length::Integer) | |
return AbstractState_all_critical_points(handle, length, T, p, rhomolar, stable) | ||
end | ||
|
||
for symorigin = [:PropsSI, :PhaseSI, :K2F, :F2K, :HAPropsSI, :AbstractState_factory, :AbstractState_free, :AbstractState_set_fractions, :AbstractState_get_mole_fractions, :AbstractState_get_mole_fractions_satState, :AbstractState_update, :AbstractState_keyed_output, :AbstractState_output, :AbstractState_specify_phase, :AbstractState_unspecify_phase, :AbstractState_update_and_common_out, :AbstractState_update_and_1_out, :AbstractState_update_and_5_out, :AbstractState_set_binary_interaction_double, :AbstractState_set_cubic_alpha_C, :AbstractState_set_fluid_parameter_double, :AbstractState_first_saturation_deriv, :AbstractState_first_partial_deriv, :AbstractState_build_phase_envelope, :AbstractState_build_spinodal, :AbstractState_all_critical_points, :AbstractState_get_phase_envelope_data, :AbstractState_get_spinodal_data] | ||
for symorigin = [:PropsSI, :PhaseSI, :K2F, :F2K, :HAPropsSI, :AbstractState_factory, :AbstractState_free, :AbstractState_set_fractions, :AbstractState_get_mole_fractions, :AbstractState_get_mole_fractions_satState, :AbstractState_update, :AbstractState_get_fugacity, :AbstractState_get_fugacity_coefficient, :AbstractState_keyed_output, :AbstractState_output, :AbstractState_specify_phase, :AbstractState_unspecify_phase, :AbstractState_update_and_common_out, :AbstractState_update_and_1_out, :AbstractState_update_and_5_out, :AbstractState_set_binary_interaction_double, :AbstractState_set_cubic_alpha_C, :AbstractState_set_fluid_parameter_double, :AbstractState_first_saturation_deriv, :AbstractState_first_partial_deriv, :AbstractState_build_phase_envelope, :AbstractState_build_spinodal, :AbstractState_all_critical_points, :AbstractState_get_phase_envelope_data, :AbstractState_get_spinodal_data] | ||
sym = Symbol(lowercase(string(symorigin))) | ||
@eval const $sym = $symorigin | ||
@eval export $sym, $symorigin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove TODO comment