Open mikhailmints opened 1 year ago
@mikhailmints thank you for reporting it!
It is very likely that #868 solves the problem - it is a PR in which we switch from theta to supersaturation as a driver for timestep adaptivity, what helps to stabilise the solver behaviour further away from the activation point (and in your logs the RH is almost =1, which hints that this might be the case). Help welcome in reviewing and making that PR mergeable.
As a temporary workaround, you can either try disabling timestep adaptivity when instantiating the Condensation
dynamic or try using SciPy ODE solver instead of the PySDM internal one using the scipy_solver
argument for Pyrcel.Simulation.__init__
.
HTH
Thanks for the response! Disabling timestep adaptivity still seems to give the same error. If I use the SciPy solver, I get the following:
lsoda-- at t (=r1), too much accuracy requested
for precision of machine.. see tolsf (=r2)
in above, r1 = 0.2523173154976D-04 r2 = NaN
/home/mmints/anaconda3/lib/python3.10/site-packages/scipy/integrate/_ode.py:1348: UserWarning: lsoda: Excess accuracy requested (tolerances too small).
warnings.warn('{:s}: {:s}'.format(self.__class__.__name__,
Traceback (most recent call last):
File "/central/home/mmints/CliMA/AerosolActivationEmulation/CondFailedIssueMinExample.py", line 30, in <module>
results = simulation.run()
File "/home/mmints/anaconda3/lib/python3.10/site-packages/PySDM_examples/Pyrcel/simulation.py", line 85, in run
output_products = super()._run(
File "/home/mmints/anaconda3/lib/python3.10/site-packages/PySDM_examples/utils/basic_simulation.py", line 19, in _run
self.particulator.run(steps=steps_per_output_interval)
File "/home/mmints/anaconda3/lib/python3.10/site-packages/PySDM/particulator.py", line 48, in run
dynamic()
File "/home/mmints/anaconda3/lib/python3.10/site-packages/PySDM/dynamics/condensation.py", line 95, in __call__
self.particulator.condensation(
File "/home/mmints/anaconda3/lib/python3.10/site-packages/PySDM/backends/impl_numba/test_helpers/scipy_ode_condensation_solver.py", line 32, in _condensation
func(
File "/home/mmints/anaconda3/lib/python3.10/site-packages/PySDM/backends/impl_numba/methods/condensation_methods.py", line 137, in _condensation
) = solver(
File "/home/mmints/anaconda3/lib/python3.10/site-packages/PySDM/backends/impl_numba/test_helpers/scipy_ode_condensation_solver.py", line 217, in solve
assert integ.success, integ.message
AssertionError: Unexpected istate in LSODA.
Changing rtol_x
and rtol_thd
again does not seem to affect anything.
I also tried this with the current version of #868, and I am still getting exactly the same errors.
Thank you for the follow ups. Indeed seems it is not related in any way with condensation numerics in PySDM (as the same problem arises with SciPy solver).
I confirm I've reproduced it locally.
Seems the problem arises at the very beginning (temperature in the warning logs barely differs from the initial temperature). Setting a lower initial RH could help here, in principle the aerosol initialisation (searching for equilibrium wet radii) is well posed only for RH<1.
It looks like in the SciPy solver specifically, decreasing the value of rtol
does help - for example, I changed the value to 1e-8
in #1106, and the test failures that looked similar to this issue disappeared (except now some tests now time out). The example I provided above now also works with the SciPy solver, although if the sampling is changed to Logarithmic
, it still fails (in the middle of the simulation, not in the very beginning like before). With the normal condensation solver, however, I still couldn't find any way to make it work other than reducing the number of superdroplets. Changing the initial RH also does not help.
Stale issue message
Stale issue message
Stale issue message
For some input parameters, the condensation solver is failing in the parcel environment. Here is a minimal example using
PySDM_examples.Pyrcel
:Produces the following output (first and last part shown):
I tried changing
rtol_thd
,rtol_x
, anddt_cond_range
to different values, but the error still appeared. In this particular example, changing the number of superdroplets to100
instead of1000
makes the error disappear. However, ifLogarithmic
is used for the spectral sampling instead ofConstantMultiplicity
, the issue appears even for low numbers of superdroplets.