Confusing behavior of ThermodynamicState system attribute
See original GitHub issue@andrrizzi : Any idea what is going on here?
Let’s check how many torsion terms there are:
>>> from openmmtools import testsystems, states
>>> from simtk import unit, openmm
>>> testsystem = testsystems.HostGuestVacuum()
>>> testsystem.system.getForce(2).getNumTorsions()
758
Now what happens if we create a ThermodynamicState
?
>>> thermodynamic_state = states.ThermodynamicState(testsystem.system, temperature=300.0*unit.kelvin)
>>> thermodynamic_state.system.getForce(2).getNumTorsions()
0
Huh? But it gets weirder:
>>> system = thermodynamic_state.system
>>> system.getForce(2).getNumTorsions()
758
Is accessing a method of thermodynamic_state.system
somehow causing @setter
instead of @property
to be called?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
1.2 Definitions and Fundamental Ideas of Thermodynamics
The thermodynamic state of a system is defined by specifying values of a set of measurable properties sufficient to determine all other properties....
Read more >Fundamental of Thermodynamic: Basic Concepts & Laws
All characteristics of a system have constant values at any given state. As a result, if the value of even one attribute changes,...
Read more >TAKING THERMODYNAMICS (TOO) SERIOUSLY
Thermodynamics is essentially a system of relationships (i.e., equations of state) among the macroscopic parameters of a system at equilibrium.
Read more >Entropy (statistical thermodynamics) - Wikipedia
Boltzmann's principle Ludwig Boltzmann defined entropy as a measure of the number of possible microscopic states (microstates) of a system in thermodynamic ...
Read more >LECTURE NOTES ON THERMODYNAMICS
These are lecture notes for AME 20231, Thermodynamics, a sophomore-level undergraduate course taught in the Department of Aerospace and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah! This is likely caused by how the SWIG memory is handled.
thermodynamic_state.system
is a copy. If you don’t assign it to anything, the garbage collector is going to pick it up as soon as it has the chance. The force returned bythermodynamic_state.system.getForce(i)
does not own the SWIG C++ memory, so theSystem
gets deallocated, and by the time you callgetNumTorsions()
, that area of the memory could be already overwritten. I’m surprised you didn’t get a segfault.Thanks!
Also, their sphinx docs stylesheet is gorgeous!