diff --git a/examples/SPIN/test_problems/README b/examples/SPIN/test_problems/README index 17e0935a35..66de9fa88e 100644 --- a/examples/SPIN/test_problems/README +++ b/examples/SPIN/test_problems/README @@ -44,7 +44,9 @@ directory. energy versus temperature. Comparison to the Langevin function results (computed by the python script). Note: This example is a reworked version of a test problem - provided by Martin Kroger (ETHZ). + provided by Martin Kroger (ETHZ). + Note 2: Two versions of this test are deployed, one at low + damping (0.01) and one at large damping (1.0). - validation_nve: simulates a small assembly of magnetic atoms (54). The atoms are diff --git a/examples/SPIN/test_problems/run_all.sh b/examples/SPIN/test_problems/run_all.sh index fb682e3ef5..51f11dc6d6 100755 --- a/examples/SPIN/test_problems/run_all.sh +++ b/examples/SPIN/test_problems/run_all.sh @@ -12,13 +12,19 @@ cd validation_damped_precession/ rm res_lammps.dat res_llg.dat cd .. -# test 3: langevin, damping and Zeeman -cd validation_langevin_precession/ +# test 3: langevin, damping and Zeeman, low damping (0.01) +cd validation_langevin_precession_d0.01/ ./run-test-prec.sh rm average_spin test-prec-spin.in res_lammps.dat res_langevin.dat cd .. -# test 4: NVE run, test Etot preservation +# test 4: langevin, damping and Zeeman, large damping (1.0) +cd validation_langevin_precession_d1.0/ +./run-test-prec.sh +rm average_spin test-prec-spin.in res_lammps.dat res_langevin.dat +cd .. + +# test 5: NVE run, test Etot preservation cd validation_nve/ ./run-test-nve.sh rm nve_spin_lattice.pdf res_lammps.dat diff --git a/examples/SPIN/test_problems/validation_langevin_precession/langevin.py b/examples/SPIN/test_problems/validation_langevin_precession_d0.01/langevin.py similarity index 100% rename from examples/SPIN/test_problems/validation_langevin_precession/langevin.py rename to examples/SPIN/test_problems/validation_langevin_precession_d0.01/langevin.py diff --git a/examples/SPIN/test_problems/validation_langevin_precession/plot_precession.py b/examples/SPIN/test_problems/validation_langevin_precession_d0.01/plot_precession.py similarity index 100% rename from examples/SPIN/test_problems/validation_langevin_precession/plot_precession.py rename to examples/SPIN/test_problems/validation_langevin_precession_d0.01/plot_precession.py diff --git a/examples/SPIN/test_problems/validation_langevin_precession/run-test-prec.sh b/examples/SPIN/test_problems/validation_langevin_precession_d0.01/run-test-prec.sh similarity index 100% rename from examples/SPIN/test_problems/validation_langevin_precession/run-test-prec.sh rename to examples/SPIN/test_problems/validation_langevin_precession_d0.01/run-test-prec.sh diff --git a/examples/SPIN/test_problems/validation_langevin_precession/test-prec-spin.template b/examples/SPIN/test_problems/validation_langevin_precession_d0.01/test-prec-spin.template similarity index 100% rename from examples/SPIN/test_problems/validation_langevin_precession/test-prec-spin.template rename to examples/SPIN/test_problems/validation_langevin_precession_d0.01/test-prec-spin.template diff --git a/examples/SPIN/test_problems/validation_langevin_precession_d1.0/langevin.py b/examples/SPIN/test_problems/validation_langevin_precession_d1.0/langevin.py new file mode 100755 index 0000000000..0e9b634eeb --- /dev/null +++ b/examples/SPIN/test_problems/validation_langevin_precession_d1.0/langevin.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import numpy as np, pylab, tkinter +import matplotlib.pyplot as plt +import mpmath as mp + +mub=5.78901e-5 # Bohr magneton (eV/T) +kb=8.617333262145e-5 # Boltzman constant (eV/K) +g=2.0 # Lande factor (adim) + +Hz=10.0 # mag. field (T) + +#Definition of the Langevin function +def func(t): + return mp.coth(g*mub*Hz/(kb*t))-1.0/(g*mub*Hz/(kb*t)) + +npoints=200 +ti=0.01 +tf=20.0 +for i in range (0,npoints): + temp=ti+i*(tf-ti)/npoints + print('%lf %lf %lf' % (temp,func(temp),-g*mub*Hz*func(temp))) diff --git a/examples/SPIN/test_problems/validation_langevin_precession_d1.0/plot_precession.py b/examples/SPIN/test_problems/validation_langevin_precession_d1.0/plot_precession.py new file mode 100755 index 0000000000..0141af56a0 --- /dev/null +++ b/examples/SPIN/test_problems/validation_langevin_precession_d1.0/plot_precession.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +#Program fitting the exchange interaction +#Model curve: Bethe-Slater function +import numpy as np, pylab, tkinter +import matplotlib.pyplot as plt +from scipy.optimize import curve_fit +from decimal import * +import sys, string, os + + +argv = sys.argv +if len(argv) != 3: + print("Syntax: ./plot_precession.py res_lammps.dat res_langevin.dat") + sys.exit() + +lammps_file = sys.argv[1] +langevin_file = sys.argv[2] + +T_lmp,S_lmp,E_lmp = np.loadtxt(lammps_file, skiprows=0, usecols=(0,2,3),unpack=True) +T_lan,S_lan,E_lan = np.loadtxt(langevin_file, skiprows=0, usecols=(0,1,2),unpack=True) + +plt.figure() +plt.subplot(211) +plt.ylabel('') +plt.plot(T_lmp, S_lmp, 'b-', label='LAMMPS') +plt.plot(T_lan, S_lan, 'r--', label='Langevin') + +plt.subplot(212) +plt.ylabel('E (in eV)') +plt.plot(T_lmp, E_lmp, 'b-', label='LAMMPS') +plt.plot(T_lan, E_lan, 'r--', label='Langevin') + +plt.xlabel('T (in K)') +pylab.xlim([0,20.0]) +plt.legend() +plt.show() diff --git a/examples/SPIN/test_problems/validation_langevin_precession_d1.0/run-test-prec.sh b/examples/SPIN/test_problems/validation_langevin_precession_d1.0/run-test-prec.sh new file mode 100755 index 0000000000..ecdbb2c156 --- /dev/null +++ b/examples/SPIN/test_problems/validation_langevin_precession_d1.0/run-test-prec.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +tempi=0.0 +tempf=20.0 + +rm res_*.dat + +# compute Lammps +N=20 +for (( i=0; i<$N; i++ )) +do + temp="$(echo "$tempi+$i*($tempf-$tempi)/$N" | bc -l)" + sed s/temperature/${temp}/g test-prec-spin.template > \ + test-prec-spin.in + + # test standard Lammps + ./../../../../src/lmp_serial -in test-prec-spin.in + + # test spin/kk with Kokkos Lammps + # mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ + # -k on -sf kk -in test-prec-spin.in + + Hz="$(tail -n 1 average_spin | awk -F " " '{print $3}')" + sz="$(tail -n 1 average_spin | awk -F " " '{print $5}')" + en="$(tail -n 1 average_spin | awk -F " " '{print $6}')" + echo $temp $Hz $sz $en >> res_lammps.dat +done + +# compute Langevin +python3 langevin.py > res_langevin.dat + +# plot results +python3 plot_precession.py res_lammps.dat res_langevin.dat diff --git a/examples/SPIN/test_problems/validation_langevin_precession_d1.0/test-prec-spin.template b/examples/SPIN/test_problems/validation_langevin_precession_d1.0/test-prec-spin.template new file mode 100644 index 0000000000..94e7a02fee --- /dev/null +++ b/examples/SPIN/test_problems/validation_langevin_precession_d1.0/test-prec-spin.template @@ -0,0 +1,48 @@ +#LAMMPS in.run + +units metal +atom_style spin +# atom_style spin/kk +atom_modify map array +boundary p p p + +# read_data singlespin.data + +lattice sc 3.0 +region box block 0.0 1.0 0.0 1.0 0.0 1.0 +create_box 1 box +create_atoms 1 box + +mass 1 1.0 +set type 1 spin 1.0 0.0 0.0 1.0 + +# defines a pair/style for neighbor list, but do not use it +pair_style spin/exchange 4.0 +pair_coeff * * exchange 1.0 0.0 0.0 1.0 + +group bead type 1 + +variable H equal 10.0 +variable Kan equal 0.0 +variable Temperature equal temperature +variable RUN equal 1000000 + +fix 1 all nve/spin lattice no +fix 2 all precession/spin zeeman ${H} 0.0 0.0 1.0 anisotropy ${Kan} 0.0 0.0 1.0 +fix_modify 2 energy yes +# fix 3 all langevin/spin ${Temperature} 0.01 12345 +fix 3 all langevin/spin ${Temperature} 1.0 12345 + +compute compute_spin all spin +compute outsp all property/atom spx spy spz sp +compute magsz all reduce ave c_outsp[3] + +thermo 50000 +thermo_style custom step time temp vol pe c_compute_spin[5] etotal + +variable magnetic_energy equal c_compute_spin[5] + +fix avespin all ave/time 1 ${RUN} ${RUN} v_Temperature v_H v_Kan c_magsz v_magnetic_energy file average_spin + +timestep 0.1 +run ${RUN}