LupoLab / Luna.jl

Nonlinear optical pulse propagator
MIT License
60 stars 27 forks source link

Density for helium has changed #210

Open chrisbrahms opened 3 years ago

chrisbrahms commented 3 years ago

With the latest version of CoolProp, our density comparisons for helium in test_physdata.jl fail because the results from CoolProp are now different. I think this is because CoolProp updated their equation of state: https://github.com/CoolProp/CoolProp/releases/tag/v6.4.0

Do we just change the numbers to the new CoolProp data?

jtravs commented 3 years ago

Haven;t looked yet. Are these the comparisons to REFPROP? Or just previous CoolProp values?

chrisbrahms commented 3 years ago

A comment in the test claims that it compares to REFPROP https://github.com/LupoLab/Luna/blob/f3a377047599eff18a0d50c55e69aa527e9edd0a/test/test_physdata.jl#L63

jtravs commented 3 years ago

OK, then that is harder. How out is it, and how many of them fail?

chrisbrahms commented 3 years ago

test output with stacktraces removed:

[ Info: ================= test_physdata.jl
Nonlinear coefficients: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:51
  Expression: PhysData.χ3_gas(:He, 1) ≈ 1.2617371645226101e-27
   Evaluated: 1.2617370217991359e-27 ≈ 1.2617371645226101e-27

Nonlinear coefficients: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:53
  Expression: PhysData.n2_gas(:He, 1) ≈ 3.5647819877255427e-25
   Evaluated: 3.564781584514427e-25 ≈ 3.5647819877255427e-25

Nonlinear coefficients: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:55
  Expression: PhysData.n2_gas.(:He, [1, 2]) ≈ [3.5647819877255427e-25, 7.125642138007481e-25]
   Evaluated: [3.564781584514427e-25, 7.125642212017557e-25] ≈ [3.5647819877255427e-25, 7.125642138007481e-25]

Nonlinear coefficients: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:56
  Expression: PhysData.n2_gas.([:He, :Ne], 1) ≈ [3.5647819877255427e-25, 6.416061508801999e-25]
   Evaluated: [3.564781584514427e-25, 6.416061508801999e-25] ≈ [3.5647819877255427e-25, 6.416061508801999e-25]

Density: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:70
  Expression: isapprox(PhysData.density(:He, 0.002, 294.0), 4.927180563885407e22, rtol = 7.0e-16)
   Evaluated: isapprox(4.927187794842085e22, 4.927180563885407e22; rtol = 7.0e-16)

Density: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:71
  Expression: isapprox(PhysData.density(:He, 0.02, 294.0), 4.927137517453137e23, rtol = 2.0e-16)
   Evaluated: isapprox(4.92714475905741e23, 4.927137517453137e23; rtol = 2.0e-16)

Density: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:72
  Expression: isapprox(PhysData.density(:He, 2.0, 294.0), 4.9224080868066745e25, rtol = 2.0e-13)
   Evaluated: isapprox(4.922416489436133e25, 4.9224080868066745e25; rtol = 2.0e-13)

Density: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:73
  Expression: isapprox(PhysData.density(:He, 40.0, 294.0), 9.66755645602771e26, rtol = 6.0e-16)
   Evaluated: isapprox(9.66760987214315e26, 9.66755645602771e26; rtol = 6.0e-16)

Density: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:74
  Expression: isapprox(PhysData.density(:He, 400.0, 294.0), 8.309132317978155e27, rtol = 1.0e-13)
   Evaluated: isapprox(8.308879698102269e27, 8.309132317978155e27; rtol = 1.0e-13)

Density: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:92
  Expression: isapprox(PhysData.density(:He, 10.0, 10.0), 9.218927214187151e27, rtol = 6.0e-16)
   Evaluated: isapprox(9.186154985703197e27, 9.218927214187151e27; rtol = 6.0e-16)

Density: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:93
  Expression: isapprox(PhysData.density(:He, 10.0, 100.0), 7.142310177179197e26, rtol = 6.0e-16)
   Evaluated: isapprox(7.142652919387785e26, 7.142310177179197e26; rtol = 6.0e-16)

Density: Test Failed at C:\Users\cbrahms\.julia\dev\Luna\test\test_physdata.jl:94
  Expression: isapprox(PhysData.density(:He, 10.0, 1000.0), 7.234660811823096e25, rtol = 6.0e-13)
   Evaluated: isapprox(7.234649699095616e25, 7.234660811823096e25; rtol = 6.0e-13)
jtravs commented 3 years ago

OK, I'd rather keep teh REFPROP values as is, and tune the tolerances. A quick check suggests they are still close to withing 1e-6 or so, which is more than sufficient for us. The good thing about keeping the REFPROP values is that they are at least independent.

In the medium term I suspect we shoudl move to something like https://github.com/ypaul21/Clapeyron.jl

chrisbrahms commented 3 years ago

Anything that gets rid of the awkward CoolProp.jl dependency. Just had a quick test and Clapeyron only supports helium with one of their models as far as I can tell. It gives similar values but further away from REFPROP than CoolProp is.

jtravs commented 3 years ago

Theres is also https://github.com/stillyslalom/PyThermo.jl (which brings in a python dependency) And actually several others. But this could wait.

jtravs commented 3 years ago

With PyThermo I get e.g.

julia> molar_density(Species("He", P=100000*2.0, T = 294.0)) * CODATA2014.N_A
4.922416489436133e25 m^-3

compared to the equivalent test which suggests 4.9224080868066745e25

isapprox(PhysData.density(:He, 2.0, 294.0), 4.9224080868066745e25, rtol = 2.0e-13)