QuantumATK Forum
QuantumATK => General Questions and Answers => Topic started by: AsifShah on October 30, 2022, 07:40
-
Dear Admin,
I am trying to call partial charges on configuration inside a hook method as:
def post_step_hook(step, time, configuration, forces, stress):
PC=PartialCharges(configuration)
md_trajectory = MolecularDynamics(
bulk_configuration,
constraints=constraints,
trajectory_filename='File1.hdf5',
steps=3000,
log_interval=10,
post_step_hook=post_step_hook,
method=method
)
But I get the following error:
Traceback (most recent call last):
File "Electric_Field_F_Migration.py", line 923, in <module>
md_trajectory = MolecularDynamics(
File "zipdir/NL/Dynamics/MolecularDynamics/MolecularDynamics.py", line 776, in MolecularDynamics
File "zipdir/NL/Dynamics/MolecularDynamics/HookFunctionContainer.py", line 252, in callAllHookFunctions
File "Electric_Field_F_Migration.py", line 914, in post_step_hook
PC=PartialCharges(configuration)
File "zipdir/NL/Analysis/PartialCharges.py", line 85, in __init__
File "zipdir/NL/Analysis/Analysis.py", line 282, in __init__
File "zipdir/NL/Analysis/Analysis.py", line 253, in _supportConfigurationWithCalculator
File "zipdir/NL/Analysis/Analysis.py", line 209, in _supportConfiguration
File "zipdir/NL/Analysis/AnalysisUtilities.py", line 176, in checkConfiguration
NL.ComputerScienceUtilities.Exceptions.NLTypeError: The parameter 'configuration' must be an instance of one of the following: BulkConfiguration, MoleculeConfiguration, DeviceConfiguration
Kindly help in this case, as how to calculate partialcharges inside hook?
-
What do you get if you include
print(configuration)
nlprint(configuration)
in the hook function? That will give us a better clue. Or attach your script so we can test it
-
I have attached the script below.
-
Turns out the correct way to do it is to use
PC = configuration.partialCharges()
-
I already tried this one but it returns nothing.
-
Yes, it seems the correct way is
pc = PartialCharges(configuration.configuration())
Previous reply only works if partial charges are already computed and you want to extract them, which of course is not your case.
-
Thanks yes it did work.