Open kevinsung opened 6 years ago
I like the design to compute orbitals and other quantities on the fly. At this stage, the overhead to recompute things is negligible. By the time when the interface was implemented, molecule.canonical_orbitals was a regular attribute than the property. To make the interface compatible with the old implementation, run_pyscf is kept and attributes like molecule.canonical_orbitals, molecule.orbital_energies are initialized in run_pyscf.
When computing things on the fly, the symmetry of the system needs to be carefully considered. The orbitals may be differed by a phase from run to run. If orbitals are recomputed, the MO integrals may be varied during the simulation accordingly, which may cause numerical instability.
I think this issue still persists. Do you have any ideas on how to resolve this problem? As a temporary solution, I wrote setters for all problematic properties, as shown below, but I am not familiar with the design of this project and am not sure if this is okay. Since @sunqm mentioned that recomputing may cause instability, the setter only updates when the values are not specified.
@canonical_orbitals.setter
def canonical_orbitals(self, value):
if self._canonical_orbitals is None:
self._canonical_orbitals = value
else:
raise AttributeError
Input:
Output:
The reason is that PyscfMolecularData has
canonical_orbitals
, etc., as properties rather than attributes. One could fix this by adding setters, but I don't know what the correct design or intended usage is. If we can calculate stuff on the fly, then perhaps we don't even need to performrun_pyscf
on a PyscfMolecularData? @sunqm