close and finalize LAMMPS instance in MLIAP example python scripts

This commit is contained in:
Axel Kohlmeyer
2023-04-06 12:58:30 -04:00
parent ebcb443237
commit 4c403e5b71
4 changed files with 26 additions and 20 deletions

View File

@ -85,8 +85,7 @@ class LinearModel():
def __call__(self,elems,bispectrum,beta,energy): def __call__(self,elems,bispectrum,beta,energy):
energy[:] = bispectrum @ self.weights + self.bias energy[:] = bispectrum @ self.weights + self.bias
beta[:] = self.weights beta[:] = self.weights
mymodel = LinearModel("Ta06A.mliap.model") mymodel = LinearModel("Ta06A.mliap.model")
import lammps import lammps
@ -98,4 +97,5 @@ lammps.mliap.activate_mliappy(lmp)
lmp.commands_string(before_loading) lmp.commands_string(before_loading)
lammps.mliap.load_model(mymodel) lammps.mliap.load_model(mymodel)
lmp.commands_string(after_loading) lmp.commands_string(after_loading)
lmp.close()
lmp.finalize()

View File

@ -103,6 +103,8 @@ model = torch.load(torch_model)
# Connect the PyTorch model to the mliap pair style. # Connect the PyTorch model to the mliap pair style.
lammps.mliap.load_model(model) lammps.mliap.load_model(model)
# run the simulation with the mliap pair style # run the simulation with the mliap pair style
lmp.commands_string(after_loading) lmp.commands_string(after_loading)
lmp.close()
lmp.finalize()

View File

@ -103,6 +103,8 @@ model = torch.load(torch_model)
# Connect the PyTorch model to the mliap pair style. # Connect the PyTorch model to the mliap pair style.
lammps.mliap.load_model_kokkos(model) lammps.mliap.load_model_kokkos(model)
# run the simulation with the mliap pair style # run the simulation with the mliap pair style
lmp.commands_string(after_loading) lmp.commands_string(after_loading)
lmp.close()
lmp.finalize()

View File

@ -6,30 +6,30 @@
before_loading =\ before_loading =\
"""# 3d Lennard-Jones melt """# 3d Lennard-Jones melt
units lj units lj
atom_style atomic atom_style atomic
lattice fcc 0.8442 lattice fcc 0.8442
region box block 0 10 0 10 0 10 region box block 0 10 0 10 0 10
create_box 1 box create_box 1 box
create_atoms 1 box create_atoms 1 box
mass 1 1.0 mass 1 1.0
velocity all create 3.0 87287 loop geom velocity all create 3.0 87287 loop geom
""" """
after_loading =\ after_loading =\
""" """
pair_style mliap unified EXISTS pair_style mliap unified EXISTS
pair_coeff * * Ar pair_coeff * * Ar
neighbor 0.3 bin neighbor 0.3 bin
neigh_modify every 20 delay 0 check no neigh_modify every 20 delay 0 check no
fix 1 all nve fix 1 all nve
thermo 50 thermo 50
run 250 run 250
""" """
import lammps import lammps
@ -63,3 +63,5 @@ lammps.mliap.load_unified(unified)
# Run the simulation with the mliap unified pair style # Run the simulation with the mliap unified pair style
# Use pre-loaded model by specifying model filename as "EXISTS" # Use pre-loaded model by specifying model filename as "EXISTS"
lmp.commands_string(after_loading) lmp.commands_string(after_loading)
lmp.close()
lmp.finalize()