-
Notifications
You must be signed in to change notification settings - Fork 188
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
Thermostats refactoring #4845
Thermostats refactoring #4845
Conversation
Fix outdated instructions in chapter on bonded interactions. Remove automatic linking of words that collide with class names and namespaces due to the large number of false positives.
API changes: thermalized bond random number generator seed moved to the thermostat class to avoid accidentally modifying the global seed, LB thermostat seed parameter is now interpreted as the RNG seed instead of the RNG Philox counter.
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Several Cython features have been deprecated in Cython 3.0 and will generate errors in future Cython releases. This change removes .pxi include files, all `IF` conditional statements, and cpdef functions. Almost all Cython 3.0 deprecation warnings were addressed, a silent API change from Python 3.11 was mitigated, and some of the custom Cython code for type checking was replaced by equivalent C++ code.
Regarding the API change for thermalized bonds: the thermalized bond thermostat had always used a single, global RNG state that would be silently overwritten by each new thermalized bond. The new API no longer gives the false impression that each bond maintains its own RNG. The thermostat infrastructure is likely going to change in the near future anyway. We should really consider rewriting the DPD thermostat to no longer get incremented by external components like constraints. This would allow us to have a single shared RNG counter from which all thermostats could extract their random numbers (the RNG salt decorrelates them). Then the DPD non-bonded potential and thermalized bonds would behave like any other interaction, since they would just fetch the RNG values from the system thermostat. This would also make the thermostat script interface a lot more maintainable. Right now it's quite convoluted, because the specificities of each thermostat prevent me from applying the SOLID principles. In particular, when turning a thermostat on, the arguments are dispatched to the thermostat container ( In any case, I think this refactoring is a big improvement over the original Cython code, and from my side can be reviewed and merged as is. We can then consult with our users during the next software meeting how we want to proceed with further refactoring of the thermostats, and decide on which API changes would be acceptable. I would prefer not to delay the merge decision for this PR, because it simplifies the LB particle coupling code quite a bit and removes highly coupled global variables, and I would like to leverage that in my ongoing GPU LB work resp. ongoing globals removal work. |
There might actually be a bug in the LB particle coupling RNG. I have produced a MWE in #4848. |
Description of changes:
ScriptInterface
class per core class (fixes Split thermostats into separate classes #3980)ThermostatFlags
enum, allow deactivating a single thermostat, add anis_active
flag accessible from the Python interface (fixes Refactor thermostat switches #4266)nogil
deprecation warning subsistsseed
was moved tosystem.thermostat.set_thermalized_bond()
seed
parameter now gets written to the RNG seed (silent change)0
and theseed
value was used to set the RNG counter, thus two independent simulations with a different seed would actually get the same particle coupling random noise sequence with a time lag equal to the difference between the two seeds