Skip to content
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

Error for int arguments #131

Closed
ianhbell opened this issue Dec 16, 2022 · 0 comments · Fixed by #133
Closed

Error for int arguments #131

ianhbell opened this issue Dec 16, 2022 · 0 comments · Fixed by #133

Comments

@ianhbell
Copy link
Contributor

It took me a while to realize precisely what the problem was, but if I pass an integer argument in some cases I get what I assume are iteration failures, while when I pass the same quantity as a float, no problem. I assume the values should be up-cast to double first.

model = SAFTVRQMie(["hydrogen"])
display( model.params.sigma)
display(model.params.lambda_a)
display(model.params.lambda_r)
display(model.params.epsilon)

crit = Clapeyron.crit_pure(model)
print(crit)
Tc, pc, vc = crit
T = 14
print(T)
p, vl, vv = saturation_pressure(model, T)
prop = -Clapeyron.VT_entropy_res(model, vl, T, z)/8.31446261815324

yields

...
(33.434046890891814, 1.3841855209847114e6, 6.452374327127238e-5)14
InexactError: Int64(3.453199220287775e-10)

Stacktrace:
  [1] Int64
    @ ./float.jl:788 [inlined]
  [2] convert
    @ ~/.julia/packages/ForwardDiff/QdStj/src/dual.jl:433 [inlined]
  [3] setindex!
    @ ./array.jl:966 [inlined]
  [4] d(model::SAFTVRQMie{BasicIdeal}, V::Float64, T::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#fun#184"{SAFTVRQMie{BasicIdeal}, Float64, Vector{Float64}}, Int64}, Int64, 1}, z::Vector{Float64}, _σeff::Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#fun#184"{SAFTVRQMie{BasicIdeal}, Float64, Vector{Float64}}, Int64}, Float64, 1}})
    @ Clapeyron ~/.julia/packages/Clapeyron/u0y5V/src/models/SAFT/SAFTVRMie/variants/SAFTVRQMie.jl:164
  [5] macro expansion
    @ ~/.julia/packages/Clapeyron/u0y5V/src/utils/macros.jl:77 [inlined]
  [6] data(model::SAFTVRQMie{BasicIdeal}, V::Float64, T::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#fun#184"{SAFTVRQMie{BasicIdeal}, Float64, Vector{Float64}}, Int64}, Int64, 1}, z::Vector{Float64})
    @ Clapeyron ~/.julia/packages/Clapeyron/u0y5V/src/models/SAFT/SAFTVRMie/variants/SAFTVRQMie.jl:86
  [7] a_mono
    @ ~/.julia/packages/Clapeyron/u0y5V/src/models/SAFT/SAFTVRMie/variants/SAFTVRQMie.jl:74 [inlined]
  [8] macro expansion
    @ ~/.julia/packages/Clapeyron/u0y5V/src/utils/macros.jl:77 [inlined]
  [9] a_res
    @ ~/.julia/packages/Clapeyron/u0y5V/src/models/SAFT/SAFTVRMie/variants/SAFTVRQMie.jl:79 [inlined]
 [10] eos_res(model::SAFTVRQMie{BasicIdeal}, V::Float64, T::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#fun#184"{SAFTVRQMie{BasicIdeal}, Float64, Vector{Float64}}, Int64}, Int64, 1}, z::Vector{Float64})
    @ Clapeyron ~/.julia/packages/Clapeyron/u0y5V/src/base/EoSModel.jl:75
 [11] fun
    @ ~/.julia/packages/Clapeyron/u0y5V/src/methods/VT.jl:22 [inlined]
 [12] derivative
    @ ~/.julia/packages/ForwardDiff/QdStj/src/derivative.jl:14 [inlined]
 [13] derivative
    @ ~/.julia/packages/Clapeyron/u0y5V/src/solvers/ad.jl:6 [inlined]
 [14] VT_entropy_res(model::SAFTVRQMie{BasicIdeal}, V::Float64, T::Int64, z::Vector{Float64})
    @ Clapeyron ~/.julia/packages/Clapeyron/u0y5V/src/methods/VT.jl:23
 [15] top-level scope
    @ In[71]:17
 [16] eval
    @ ./boot.jl:368 [inlined]
 [17] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1428
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant