Comments (6)
There's another comment worth making here. The Joule-Thomson coefficient is classically used to approximate the temperature after the isenthalpic throttle in a refrigeration cycle. PYroMat can do that job without the intermediate step of calculating "mu."
In this example, we get the temperature after a throttling operation from 300K, 20bar down to 1bar.
>>> r = pm.get('mp.C2H2F4')
>>> h1 = r.h(T=300., p=20.)
>>> T2 = r.T(h=h1, p=1.)
>>> T2
array([246.78990841])
from pyromat.
Good question. As a percentage of the value being perturbed, the "delta" should be larger than the machine error in the calculation (1e-6 is the WORST error PYroMat usually tolerates in numerical inversion problems, 1e-15 is more typical), but small enough that changes in the perturbation does not significantly change the value of the slope.
For example, here are three ways of calculating the "same" number:
>>> n2 = pm.get('mp.N2')
>>> n2.cp(T=T,p=p) # First, what is the "True" value?
array([1.04135039])
>>> T = 300; dT = .01; p=1.01325; dp = 1e-5
>>> dhdt = (n2.h(T=T+dT,p=p) - n2.h(T=T,p=p)) / dT # Now, get the same value numerically
>>> dhdt
array([1.04135041]) # Pretty good!
>>> dT = .02
>>> dhdt = (n2.h(T=T+dT,p=p) - n2.h(T=T,p=p)) / dT # Now, repeat with a larger dT
>>> dhdt
array([1.04135043]) # Still pretty good!
from pyromat.
I'm glad you raise this topic - it's been on my list of things to add in future releases. In the meantime, the easiest way to calculate the Joule-Thomson coefficient is numerically.
Most texts recommend calculating the JT coefficient from the partial derivative of volume with respect to temperature at constant pressure (thermal expansion coefficient). The easiest way to calculate that without coding your own methods is to perturb specific volume at constant pressure.
>>> dT=.01; T=300.; dp=1e-5; p=1.01325
>>> alpha = (n2.v(T=T+dT,p=p) - n2.v(T=T,p=p)) / dT
>>> alpha
array([0.00293603])
I don't recommend using this approach in PYroMat, though. It's much easier to calculate the derivatives of enthalpy with respect to temperature and pressure directly. This example calculates the JT coefficient in Kelvin per bar.
>>> dhdp = (n2.h(p=p+dp,T=T) - n2.h(p=p,T=T)) / dp
>>> dhdt = (n2.h(p=p,T=T+dt) - n2.h(p=p,T=T)) / dt # Or just use dhdt = n2.cp(p=p,T=T)
>>> mu = -dhdp / dhdt
>>> mu
array([0.21195838])
These methods are a little inelegant, but they work well. The back-end doesn't use these kinds of methods - it calculates these derivatives analytically from the EOS coefficients, so it's more efficient.
from pyromat.
Extremely Thank You
from pyromat.
@chmarti1 Kindly guide on what basis are these values dT=.01, dp=1e-5
...small but how small?
from pyromat.
@chmarti1 perturbation does not significantly change the value of the slope.
Done & Done, thanks
from pyromat.
Related Issues (20)
- [Review] Default unit converters for time are incorrect in subsecond range HOT 7
- [Review] Insert citation to NumPy in Paper HOT 1
- Inverse routines do not convert units HOT 1
- [Review] Repo/Docs are missing some guidelines for contribution HOT 1
- [Review] Include `extra_requires` in setup.py
- Proposal: unit confusion with default p&T HOT 4
- Test code breaks on d_s()
- There is a problem with temperature-entalpy with air as ideal gas HOT 5
- Discussion: Error Codes HOT 2
- Create a state class HOT 2
- Easily capable to handle a simple inverse arg case for Ideal Gases HOT 6
- Code from Live-Page of PYroMat HOT 2
- Error in R1234ze Saturation Density HOT 1
- General Inverse Property Lookup Functionality HOT 1
- Add Multiphase Ammonia
- Different result using substance.p() and substance.ps() in multiphase substance HOT 1
- Incorrect Pressure-Density Relationship for Multiphase Oxygen HOT 4
- Provide typing HOT 5
- IGMIX does not include entropy of mixing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyromat.