nlsave¶
- nlsave(filename, nl_object, object_id='', labels=None, comment=None, hidden=False)¶
Function for saving the given object to a NetCDF or HDF5 file. This function is collective over all MPI processes.
- Parameters:
filename (string) – The full or relative filename path that the QuantumATK object should be saved to. If no extension is given, then “.hdf5” will be appended to the filename.
nl_object (A QuantumATK object) – The QuantumATK object that should be saved to file.
object_id (string) – A unique identifier that should be attached to the saved object. If the object_id already exists in the file, the old data will be automatically deleted prior to saving the new object.
Default:''
(an empty string)labels –
Deprecated: from v2017.0.comment –
Deprecated: from v2017.0.hidden (bool) – This flag controls if the object is hidden. Hidden objects do not show up on the Lab Floor.
Default: False
Usage Examples¶
Save the self-consistent state of a calculation:
# Set up configuration
molecule_configuration = MoleculeConfiguration(
elements = [Nitrogen, Hydrogen, Hydrogen, Hydrogen],
cartesian_coordinates = [[ 0. , 0. , 0.124001],
[ 0. , 0.941173, -0.289336],
[ 0.81508, -0.470587, -0.289336],
[-0.81508, -0.470587, -0.289336]]*Angstrom
)
calculator = HuckelCalculator()
molecule_configuration.setCalculator(calculator)
# Perform SCF loop
molecule_configuration.update()
# Save state
nlsave('nh3_scf.hdf5', molecule_configuration)
Restore the self-consistent state from a saved file, calculate the
MolecularEnergySpectrum, and save it to the file spectrum.hdf5
with object_id = 'id0'
. This will overwrite any data in the file
spectrum.hdf5
associated with this object_id
.
# Read self-consistent calculation
molecule_configurations = nlread(
'nh3_scf.hdf5',
MoleculeConfiguration
)
molecule_configuration = molecule_configurations[0]
# Calculate the molecular energy spectrum
spectrum = MolecularEnergySpectrum(molecule_configuration)
# Save the molecular energy spectrum
nlsave('spectrum.hdf5', spectrum, 'id0')
More details regarding file IO in QuantumATK can be found here.