Git Product home page Git Product logo

Comments (6)

chmarti1 avatar chmarti1 commented on September 28, 2024 1

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.

chmarti1 avatar chmarti1 commented on September 28, 2024 1

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.

chmarti1 avatar chmarti1 commented on September 28, 2024

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.

defencedog avatar defencedog commented on September 28, 2024

Extremely Thank You

from pyromat.

defencedog avatar defencedog commented on September 28, 2024

@chmarti1 Kindly guide on what basis are these values dT=.01, dp=1e-5 ...small but how small?

from pyromat.

defencedog avatar defencedog commented on September 28, 2024

@chmarti1 perturbation does not significantly change the value of the slope.
Done & Done, thanks

from pyromat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.