Author Topic: Hook Method for Partial Charge  (Read 4191 times)

0 Members and 1 Guest are viewing this topic.

Offline AsifShah

  • QuantumATK Guru
  • ****
  • Posts: 173
  • Country: in
  • Reputation: 2
    • View Profile
Hook Method for Partial Charge
« 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?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: Hook Method for Partial Charge
« Reply #1 on: November 8, 2022, 08:11 »
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

Offline AsifShah

  • QuantumATK Guru
  • ****
  • Posts: 173
  • Country: in
  • Reputation: 2
    • View Profile
Re: Hook Method for Partial Charge
« Reply #2 on: November 9, 2022, 07:16 »
I have attached the script below.
« Last Edit: November 12, 2022, 09:49 by AsifShah »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: Hook Method for Partial Charge
« Reply #3 on: November 9, 2022, 19:42 »
Turns out the correct way to do it is to use

PC = configuration.partialCharges()
« Last Edit: November 9, 2022, 19:55 by Anders Blom »

Offline AsifShah

  • QuantumATK Guru
  • ****
  • Posts: 173
  • Country: in
  • Reputation: 2
    • View Profile
Re: Hook Method for Partial Charge
« Reply #4 on: November 10, 2022, 12:41 »
I already tried this one but it returns nothing.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: Hook Method for Partial Charge
« Reply #5 on: November 10, 2022, 20:02 »
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.

Offline AsifShah

  • QuantumATK Guru
  • ****
  • Posts: 173
  • Country: in
  • Reputation: 2
    • View Profile
Re: Hook Method for Partial Charge
« Reply #6 on: November 12, 2022, 09:49 »
Thanks yes it did work.