Skip to content

Conversation

@prehner
Copy link
Contributor

@prehner prehner commented Jul 9, 2025

example

fit_params = ["m", "sigma", "epsilon_k"]
parameters = np.array([[1.5,3.4,230.,2.3]]*5)
temperature = np.expand_dims(np.linspace(250., 400.0, 5),1)
Estimator.vapor_pressure(Model.PcSaftNonAssoc, fit_params, parameters, temperature)
(array([  99933.70173872,  382387.65114945, 1070682.32242729, 2441538.87227273, 4841857.50255882]),
 array([[-1.04684676e+05,  1.37290974e+05, -2.94409278e+03],
        [-3.22786970e+05,  4.07169153e+05, -9.49492301e+03],
        [-7.81086667e+05,  8.82668213e+05, -2.31891697e+04],
        [-1.62658737e+06,  1.54917675e+06, -4.76856550e+04],
        [-3.06545531e+06,  2.31346353e+06, -8.79512774e+04]]),
 array([ True,  True,  True,  True,  True]))

return values are the vapor pressure in Pa, the gradients of the vapor pressure with respect to fit_params and the success status of every input.

n = 10000000
fit_params = ["m", "sigma", "epsilon_k"]
parameters = np.array([[1.5,3.4,230.,2.3]]*n)
temperature = np.expand_dims(np.linspace(250., 400.0, n),1)
%time Estimator.vapor_pressure(Model.PcSaftNonAssoc, fit_params, parameters, temperature)
CPU times: user 6min 29s, sys: 790 ms, total: 6min 30s
Wall time: 6.89 s

Went to 10 million vapor pressures to catch a glimpse of the CPU usage in top. Efficiency as defined as total CPU time divided by number of cores and wall time is 88.4% which also seems high.

liquid density

n = 10000000
fit_params = ["m", "sigma", "epsilon_k"]
parameters = np.array([[1.5,3.4,230.,2.3]]*n)
temperature = np.linspace(250., 400.0, n)
pressure = np.array([1e5]*n)
input = np.stack((temperature, pressure),axis=1)
%time Estimator.liquid_density(Model.PcSaftNonAssoc, fit_params, parameters, input)
CPU times: user 3min 16s, sys: 860 ms, total: 3min 17s
Wall time: 3.97 s

@prehner
Copy link
Contributor Author

prehner commented Jul 10, 2025

With the extremely performant implementations in feos-ad, the wrapping of feos-ad models in feos-core structs becomes a bit of a bottleneck. The latest commit introduces traits for phase equilibrium calculations so that they can directly operate on the data structures in feos-ad. (Certainly still WIP for now). Timings look promising.

Vapor pressures

n = 10000000
fit_params = ["m", "sigma", "epsilon_k"]
parameters = np.array([[1.5,3.4,230.,2.3]]*n)
temperature = np.expand_dims(np.linspace(250., 400.0, n),1)
%time ParameterFit.vapor_pressure(Model.PcSaftNonAssoc, fit_params, parameters, temperature)
CPU times: user 1min 52s, sys: 727 ms, total: 1min 53s
Wall time: 2.48 s

Liquid densities

n = 10000000
fit_params = ["m", "sigma", "epsilon_k"]
parameters = np.array([[1.5,3.4,230.,2.3]]*n)
temperature = np.linspace(250., 400.0, n)
pressure = np.array([1e5]*n)
input = np.stack((temperature, pressure),axis=1)
%time ParameterFit.liquid_density(Model.PcSaftNonAssoc, fit_params, parameters, input)
CPU times: user 1min 32s, sys: 740 ms, total: 1min 33s
Wall time: 2.14 s

Bubble points

n = 1000000
fit_params = ["k_ij"]
parameters = np.array([[1.5,3.4,230.,2.3,2.3,3.5,245.,1.4,0.01]]*n)
temperature = np.linspace(200., 406.0, n)
molefracs = np.array([.5]*n)
pressure = np.array([1e5]*n)
input = np.stack((temperature, molefracs, pressure),axis=1)
%time ParameterFit.bubble_point_pressure(Model.PcSaftNonAssoc, fit_params, parameters, input)
CPU times: user 13min 58s, sys: 86.7 ms, total: 13min 58s
Wall time: 13.8 s

A million bubble point calculations in under 15 seconds 🥳

Bubble points with cross-association

n = 100000
fit_params = ["k_ij"]
parameters = np.array([[1.5,3.4,230.,2.3,0.01,1200.,1.0,2.0,2.3,3.5,245.,1.4,0.01,0.005,500.,1.0,1.0]]*n)
temperature = np.linspace(200., 388.0, n)
molefracs = np.array([.5]*n)
pressure = np.array([1e5]*n)
input = np.stack((temperature, molefracs, pressure),axis=1)
%time ParameterFit.bubble_point_pressure(Model.PcSaftFull, fit_params, parameters, input)
CPU times: user 4min 50s, sys: 19.9 ms, total: 4min 50s
Wall time: 4.67 s

As expected significantly slower but still one million in under one minute

@prehner prehner marked this pull request as ready for review August 18, 2025 10:57
@g-bauer g-bauer merged commit b4c2976 into main Oct 13, 2025
15 checks passed
@g-bauer g-bauer deleted the feos-ad-python branch October 13, 2025 13:34
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 this pull request may close these issues.

3 participants