QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: gulian on October 29, 2021, 13:45

Title: Get MTP calculator from previous training
Post by: gulian on October 29, 2021, 13:45
Dear all,

as a first step, by following the notes for the MomentTensorPotentialTraining class (see https://docs.quantumatk.com/manual/Types/MomentTensorPotentialTraining/MomentTensorPotentialTraining.html#momenttensorpotentialtraining-c (https://docs.quantumatk.com/manual/Types/MomentTensorPotentialTraining/MomentTensorPotentialTraining.html#momenttensorpotentialtraining-c)), I obtained a trained MTP potential set, stored in the mtp_study.hdf5 file.

Then, I would like to get the calculator that employes this potential set, as explained in the example:

Code
mtp_calculator = moment_tensor_potential_training.momentTensorPotentialCalculators()[0]

How can I achieve this by reading the "mtp_study.hdf5" file? Alternatively, what is the procedure to obtain a suitable calculator from the MTPPotential instantiated from the "mtp_study.mtp" file?

Thank you very much for you help!

Best regards
Title: Re: Get MTP calculator from previous training
Post by: Anders Blom on November 1, 2021, 20:33
I haven't had time to play with fitting MTPs myself yet, but following the manual you should be able to use the MTPPotential constructor:
https://docs.quantumatk.com/manual/Types/MTPPotential/MTPPotential.html
(see the bottom of the page you linked to, just before the Notes)
Title: Re: Get MTP calculator from previous training
Post by: sureshko on November 2, 2021, 17:00
Hi,
You may try the below to get the MTP calculator from .hdf5 file.
Code
moment_tensor_potential_training=nlread('mtp_study.hdf5',MomentTensorPotentialTraining)[-1]
mtp_calculator = moment_tensor_potential_training.momentTensorPotentialCalculators()[0]
Easy way to use the calculator from .mtp file is to follow this manual page which is also what Anders suggested in previous comment
https://docs.quantumatk.com/tutorials/combining_potentials/combining_potentials.html
Basically doing this
Code
potentialSet = TremoloXPotentialSet('potential_name')
potentialSet.addParticleType(ParticleType.fromElement(Oxygen))
.
....add other elements...
.
potentialSet.addPotential(MTPPotential(file='mtp_study.mtp'))
calculator = TremoloXCalculator(parameters=potentialSet)
bulk_configuration.setCalculator(calculator)

I hope this answers your question.
With regards,
Suresh
Title: Re: Get MTP calculator from previous training
Post by: gulian on November 3, 2021, 11:01
Dear Anders, dear Suresh,

thank you very much for your answers.

Indeed, it was really easy to read the MTP set from both the .hdf5 and the .mtp files. I tried both approaches and they work fine.

Best regards,

Gianfranco