Giter Club home page Giter Club logo

Comments (4)

longemen3000 avatar longemen3000 commented on August 16, 2024

yeah, paramtables are something of a stopgap that we coded a long time ago. now you can pass parameters as a named tuple.

julia> PR(["a1","a2"],userlocations = (Tc = [18.0, 3.5],Pc = [2.3, 0.1],Mw = [1.0, 1.0]),alpha_userlocations = (;acentricfactor =[0.1, 0.3]))
PR{BasicIdeal, PRAlpha, NoTranslation, vdW1fRule} with 2 components:
 "a1"
 "a2"
Contains parameters: a, b, Tc, Pc, Mw

but it is a relatively recent development (#156 ). there are some problems with that approach (what to do with group components? association?)

On the acentric factor, PR is really really general Peng-Robinson model, you can pass your own mixing rule, translation model, and alpha function. for example, Twu alpha does not depend on acentric factor. On more complicated models, the dependencies could change. for example, PSRK uses a mixing rule that depends on a UNIFAC model itself, but the main model is still a Redlich-Kwong model RK,. you can check the input parameters of PR (from the docs, or using the julia REPL (?PR):

  Input parameters
  ==================

    •  Tc: Single Parameter (Float64) - Critical Temperature [K]

    •  Pc: Single Parameter (Float64) - Critical Pressure [Pa]

    •  Mw: Single Parameter (Float64) - Molecular Weight [g/mol]

    •  k: Pair Parameter (Float64) (optional)

    •  l: Pair Parameter (Float64) (optional)

In that sense, the main PR model does not depend on acentricfactor, but the (default) alpha model does.
teqp has this function named canonical_PR, that is a shortcut for their generalized cubic form, that assumes the default alpha function and translation model. maybe we could add that.

To answer that specific param table question, you need to pass a table with acentricfactor to alpha_userlocations instead of locations.

from clapeyron.jl.

longemen3000 avatar longemen3000 commented on August 16, 2024

on the canonical_PR

function canonical_PR(Tc,Pc,acentricfactor,Mw = zeros(length(Tc));k = zeros(length(Tc),length(Tc)), l = zeros(length(Tc),length(Tc)))
    n = length(Tc)
    components = ["component " * string(i) for i in 1:n]
    return PR(components, userlocations = (;Tc = Tc,Pc = Pc,Mw = Mw, k = k,l = l), 
    alpha_userlocations = (;acentricfactor = acentricfactor))
end

then, on a script on a REPL:

julia> canonical_PR(rand(2),rand(2),rand(2))
PR{BasicIdeal, PRAlpha, NoTranslation, vdW1fRule} with 2 components:
 "component 1"
 "component 2"
Contains parameters: a, b, Tc, Pc, Mw

there are of course, some caveats to this. without specifying the molecular weight, you cannot calculate speed of sound measurements. and without specifying an appropiate ideal model, the calorific calculations will assume ideal gas (Cp = 5/2 * R)

from clapeyron.jl.

fedebenelli avatar fedebenelli commented on August 16, 2024

Thanks for the information! I come from libraries that use a very different approach in terms of modularity, so having the isolated alpha function was new to me.
I do like this approach, but maybe documentation wasn't clear (or straightforward) enough for me to understand that I should give the parameters to two different arguments. At a glance it seems that PR only depends (well it does technically) on those pure parameters only.

Thanks!

from clapeyron.jl.

longemen3000 avatar longemen3000 commented on August 16, 2024

An update about this. i just added a shortcut for this particular case, while it breaks the purity of the design, it is better for an usability perspective

from clapeyron.jl.

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.