core_dual_numbers example - confusion with units and references #106
Replies: 14 comments 19 replies
-
Hi, thank you for the feedback on the notebooks.
state.helmholtz_energy(Contributions.ResidualNvt) / (KB * 300*KELVIN) to verify that the output is indeed the same
lnphi = state.chemical_potential(Contributions.ResidualNvt)/RGAS/T - np.log(Z) will give you the correct result.
N=300*MOL
V=24.537*LITER
T=300*KELVIN
state = State(eos, temperature=T, volume=V, total_moles=N)
state.ln_phi_pure(), state.ln_phi()
The point of the
regarding your suggestions:
|
Beta Was this translation helpful? Give feedback.
-
thanks for the responses, now, it is all clearer for me! I have some follow up comments:
[was]
[should be]
then i can see that lnphi converges to zero (and phi converges to one) as volume increases or number of moles decreases
gives
|
Beta Was this translation helpful? Give feedback.
-
Hi Iuri, thanks for your interest in FeOs and your detailed look into the notebooks. Your suggestions are very valuable for us to further improve these examples. As Philipp already mentioned, we should add more/clearer information about the units that are internally used in the Concerning the typo, I'll have a look at it as soon as time permits - thanks for the comment. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks again for the responses, i have another follow up comment: i tried extending the "core_dual_numbers" to a binary mixture and testing the "ln_phi_pure" method there here is the test
here is the original subset code with prints and error
here is a potential fix
|
Beta Was this translation helpful? Give feedback.
-
The focus of the dual number notebook is to explain and showcase (using the print statements) how the data types are changed from within Rust depending on the derivatives that are needed and that there is no special Python syntax needed to work with the generalized (hyper-) dual numbers. That being said, I agree that the two notebooks (the one explaining dual numbers and the one explaining how to implement the Python class) should use a consistent implementation of the PR EoS. That's certainly something we have to improve. |
Beta Was this translation helpful? Give feedback.
-
regarding my last comment: the statement but the statement i think this caused the |
Beta Was this translation helpful? Give feedback.
-
That's correct. A numpy array of length one will be casted to a scalar when it's considered for multiplication so we have to use |
Beta Was this translation helpful? Give feedback.
-
i think i understood the behavior, i suggested a fix in the above comment "here is a potential fix" now i see that in the next example
|
Beta Was this translation helpful? Give feedback.
-
one more thing, possible bug in the dual operator overloading: while making changes to the mixing rule of the eos i got to a point where i have a variable A and a variable B (B is one of the state variables and A is a constant of the eos in array format, with len==1) then B*A gives <class 'builtins.Dual2_64'> and the latter results in an error when calculating derivatives involved in lnphi i believe the type of A*B should also be <class 'builtins.Dual2_64'> seems like the ultimately, the error is
|
Beta Was this translation helpful? Give feedback.
-
possible issue regarding the example 'core_user_defined_eos'
latest in my case is
|
Beta Was this translation helpful? Give feedback.
-
is this example (from
in comparison with
|
Beta Was this translation helpful? Give feedback.
-
hi, this also does not seem right to me:
Cp for ideal pressure gas is Cv+R |
Beta Was this translation helpful? Give feedback.
-
would you like me to open a new discussion specific to this check?
i can provide a more thorough example regarding fugacity coefficient trend
with both forms
…On Mon, Mar 20, 2023, 09:10 Philipp Rehner ***@***.***> wrote:
Thank you for the reminder, I forgot that there is still this open point
in here. As a quick check, I compared the both expressions and it turns out
they reproduce the same pressures but not the same Helmholtz
energies/chemical potentials/entropies. Maybe they can be rewritten so that
this only becomes a question of different reference states or there is
something significantly wrong here. I will have a closer look at that asap.
For the future, we should use this discussion forum more in its intended
way (think of Stack Overflow) then we won't lose track of open discussions
—
Reply to this email directly, view it on GitHub
<#106 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACTMSVLV3IP7IG625RLHDLTW5BCMDANCNFSM6AAAAAATZFXHEI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
sure, i will do it later today
…On Mon, Mar 20, 2023, 09:26 Philipp Rehner ***@***.***> wrote:
Since we are now talking about a potential bug in the code can you open an
issue on that specifically?
—
Reply to this email directly, view it on GitHub
<#106 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACTMSVPGT6TSBLA5R6JTCMLW5BEHJANCNFSM6AAAAAATZFXHEI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
hi,
I was reading and trying the first example 'core_dual_numbers'
and got confused with some aspects:
(some of which apply to the example "core_user_defined_eos.ipynb as well")
in the rev1 attachment i highlight some points of confusion
in the rev2 attachment i try to refactor the Helmholtz function of the EOS to S.I. and Reid/Poling/Prausnitz notation, and try to get the same results as before for the dimensionless results (a_kt)
main issues:
also lnphi and lnphi_pure do not seem to match, what does that mean?
(in my opinion the chemical potential / lnphi is a very motivating application for autodiffing)
but the type of the object state that arrives at the Helmholtz function of the class is of the type "<class 'builtins.StateF'>"
and contains floats with implicit units - that also caused me some confusion when trying to take advantage of the units system inside the Helmholtz function, perhaps rename the argument of the "def helmholtz_energy(self, state):" to
"def helmholtz_energy(self, state_floats):" / warn in the docstring of the class in the example that the received object contains only floats and array of floats (mol fracs)
suggestions:
thanks for your attention
Beta Was this translation helpful? Give feedback.
All reactions