question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
andrrizzicommented, Dec 5, 2017

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 by thermodynamic_state.system.getForce(i) does not own the SWIG C++ memory, so the System gets deallocated, and by the time you call getNumTorsions(), that area of the memory could be already overwritten. I’m surprised you didn’t get a segfault.

0reactions
jchoderacommented, Dec 6, 2017

Thanks!

Also, their sphinx docs stylesheet is gorgeous!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found