stko.OrcaEnergy
- class stko.OrcaEnergy(orca_path, topline, basename=None, output_dir=None, num_cores=1, charge=0, multiplicity=1, write_input_only=False, discard_output=True)[source]
Bases:
objectUses Orca to calculate energy and other properties.
By default,
get_results()will extract other properties of thestk.Moleculepassed tocalculate(), which will be saved in the attributes ofstko.OrcaResults.All intermediate and output files from Orca are deleted at the end of the job (i.e. the
.gbwfile will be deleted) because they can quickly build up to large sizes. The discard_output option allows you to keep output files if desired.Additionally, the write_input_only option is available for jobs where you would like more customization or to run outside of the Python environment.See also
- Parameters:
topline (str) – Top line designating the type of calculation. Should start with
!.basename (str | None) – Base name of Orca output files.
output_dir (Path | str | None) – The name of the directory into which files generated during the calculation are written, if
Nonethenuuid.uuid4()is used.num_cores (int) – The number of cores Orca should use.
charge (int) – Formal molecular charge.
multiplicity (int) – Multiplicity of system (2S+1), where S is the spin.
write_input_only (bool) –
Trueif you only want the input file written and to not have the Orca job run.discard_output (bool) –
Trueif you want to delete auxillary Orca output files such as the.gbwfile.
Notes
When running
calculate(), this calculator changes the present working directory withos.chdir(). The original working directory will be restored even if an error is raised, so unless multi-threading is being used this implementation detail should not matter.If multi-threading is being used an error could occur if two different threads need to know about the current working directory as
stko.OrcaEnergycan change it from under them.Note that this does not have any impact on multi-processing, which should always be safe.
Examples
import stk import stko bb1 = stk.BuildingBlock('NCCNCCN', [stk.PrimaryAminoFactory()]) bb2 = stk.BuildingBlock('O=CCCC=O', [stk.AldehydeFactory()]) polymer = stk.ConstructedMolecule( stk.polymer.Linear( building_blocks=(bb1, bb2), repeating_unit="AB", orientations=[0, 0], num_repeating_units=1 ) ) # Optimize the constructed molecule so that it has a # reasonable structure. opt = stko.UFF() polymer = opt.optimize(polymer) # Calculate energy using Orca. orca = stko.OrcaEnergy( orca_path='/opt/orca/orca', topline='! SP B97-3c', ) orca_results = orca.get_results(polymer) # Extract properties from the energy calculator for a given # molecule. total_energy = orca_results.get_total_energy()
If you want the input file written (instead of the job run), you can use the write_input_only argument to save the input file in the output_dir as orca_input.inp with the input xyz file as input_structure.xyz.
# Optimize the constructed molecule so that it has a # reasonable structure. optimizer = stko.ETKDG() polymer = optimizer.optimize(polymer) # Calculate energy using Orca. orca = stko.OrcaEnergy( orca_path='/opt/orca/orca', topline='! SP B97-3c', write_input_only=True, ) orca.get_results(polymer)
Methods
Calculate the energy of mol.
Calculate the Orca properties of mol.
- get_energy(mol)[source]
Calculate the energy of mol.
- Parameters:
mol (Molecule) – The
stk.Moleculewhose energy is to be calculated.- Returns:
The energy or
Noneifwrite_input_onlymode.- Return type:
float | None
- get_results(mol)[source]
Calculate the Orca properties of mol.
- Parameters:
mol (Molecule) – The
stk.Moleculewhose energy is to be calculated.- Returns:
The properties, with units, from Orca calculations or
Noneifwrite_input_onlymode.- Return type:
OrcaResults | None