From 138477b9b83a7513cb1ac40a4c11208c63fff712 Mon Sep 17 00:00:00 2001 From: Anders Bergman Date: Tue, 11 Oct 2022 22:21:34 +0200 Subject: [PATCH 1/2] Added examples for finite temperature exercises. --- content/finitetemp/SimpleCubic/inpsd.dat | 31 ++++++++++++ content/finitetemp/SimpleCubic/jfile | 2 + content/finitetemp/SimpleCubic/momfile | 1 + content/finitetemp/SimpleCubic/posfile | 1 + content/finitetemp/SingleSpin/inpsd.dat | 35 ++++++++++++++ content/finitetemp/SingleSpin/jfile | 1 + content/finitetemp/SingleSpin/kfile | 1 + content/finitetemp/SingleSpin/momfile | 1 + content/finitetemp/SingleSpin/posfile | 1 + content/finitetemp/finitetemp.rst | 60 ++++++++++++++++++++++++ 10 files changed, 134 insertions(+) create mode 100644 content/finitetemp/SimpleCubic/inpsd.dat create mode 100644 content/finitetemp/SimpleCubic/jfile create mode 100644 content/finitetemp/SimpleCubic/momfile create mode 100644 content/finitetemp/SimpleCubic/posfile create mode 100644 content/finitetemp/SingleSpin/inpsd.dat create mode 100644 content/finitetemp/SingleSpin/jfile create mode 100644 content/finitetemp/SingleSpin/kfile create mode 100644 content/finitetemp/SingleSpin/momfile create mode 100644 content/finitetemp/SingleSpin/posfile diff --git a/content/finitetemp/SimpleCubic/inpsd.dat b/content/finitetemp/SimpleCubic/inpsd.dat new file mode 100644 index 0000000..de7aaa9 --- /dev/null +++ b/content/finitetemp/SimpleCubic/inpsd.dat @@ -0,0 +1,31 @@ +simid simpcube +ncell 10 10 10 System size +BC P P P Boundary conditions (0=vacuum, P=periodic) +cell 1.00000 0.00000 0.00000 + 0.00000 1.00000 0.00000 + 0.00000 0.00000 1.00000 +Sym 1 Symmetry of lattice (0 for no, 1 for cubic, 2 for 2d cubic, 3 for hexagonal) +do_prnstruct 1 + +posfile ./posfile +momfile ./momfile +exchange ./jfile + +Initmag 3 Initial config of moments (1=random, 2=cone, 3=spec., 4=file) + +ip_mode N +ip_mcanneal 1 + 5000 300.0 1.00e-16 0.95 + +mode S +Temp 300.00 K Temperature of the system +hfield 0.00000 0.00000 0.00000 Static H field + +damping 0.01 Damping parameter (gamma) +nstep 10000 Number of time-steps +timestep 1.000e-16 s The time step-size for the SDE-solver + +plotenergy 1 Sample energies +do_avrg Y Measure averages +do_cumu Y Sample cumulative averages +do_spintemp Y Measure spin temperature diff --git a/content/finitetemp/SimpleCubic/jfile b/content/finitetemp/SimpleCubic/jfile new file mode 100644 index 0000000..97ac2db --- /dev/null +++ b/content/finitetemp/SimpleCubic/jfile @@ -0,0 +1,2 @@ +1 1 1.0 0.0 0.0 0.80000000000000 +1 1 1.0 1.0 0.0 0.50000000000000 diff --git a/content/finitetemp/SimpleCubic/momfile b/content/finitetemp/SimpleCubic/momfile new file mode 100644 index 0000000..1c025a3 --- /dev/null +++ b/content/finitetemp/SimpleCubic/momfile @@ -0,0 +1 @@ +1 1 1.00 0.0 0.0 1.0 diff --git a/content/finitetemp/SimpleCubic/posfile b/content/finitetemp/SimpleCubic/posfile new file mode 100644 index 0000000..a2a4794 --- /dev/null +++ b/content/finitetemp/SimpleCubic/posfile @@ -0,0 +1 @@ +1 1 0.000000 0.000000 0.000000 diff --git a/content/finitetemp/SingleSpin/inpsd.dat b/content/finitetemp/SingleSpin/inpsd.dat new file mode 100644 index 0000000..f601338 --- /dev/null +++ b/content/finitetemp/SingleSpin/inpsd.dat @@ -0,0 +1,35 @@ +simid SingleSP +ncell 1 1 1 System size +BC 0 0 0 Boundary conditions (0=vacuum,P=periodic) +cell 0.00000 0.00000 0.00000 + 0.00000 0.00000 0.00000 + 0.00000 0.00000 0.00000 +Sym 0 Symmetry of lattice (0 for no, 1 for cubic, 2 for 2d cubic, 3 for hexagonal) +do_prnstruct 2 Print lattice structure (0=no, 1=yes, 2=coordinates only) + +posfile ./posfile +exchange ./jfile +momfile ./momfile +anisotropy ./kfile + +Mensemble 1 Number of samples in ensemble averaging +Initmag 3 (1=random, 2=cone, 3=spec., 4=file) + +ip_mode N Initial phase parameters + +mode S S=SD, M=MC +temp 5.00 Measurement phase parameters +damping 0.50000 -- +Nstep 150000 -- +timestep 1.000e-15 -- + +do_avrg Y Measure averages +avrg_step 100 + +do_tottraj Y Measure moments +tottraj_step 10000 +tottraj_buff 10 time step, buffer size + +do_cumu Y + +real_time_measure Y diff --git a/content/finitetemp/SingleSpin/jfile b/content/finitetemp/SingleSpin/jfile new file mode 100644 index 0000000..1ceae49 --- /dev/null +++ b/content/finitetemp/SingleSpin/jfile @@ -0,0 +1 @@ + 1 1 0.0 0.0 1.0 0.0000 diff --git a/content/finitetemp/SingleSpin/kfile b/content/finitetemp/SingleSpin/kfile new file mode 100644 index 0000000..3ad61ab --- /dev/null +++ b/content/finitetemp/SingleSpin/kfile @@ -0,0 +1 @@ + 1 1 -0.100 0.0 0.0 0.0 1.0 0.0 diff --git a/content/finitetemp/SingleSpin/momfile b/content/finitetemp/SingleSpin/momfile new file mode 100644 index 0000000..3710eeb --- /dev/null +++ b/content/finitetemp/SingleSpin/momfile @@ -0,0 +1 @@ +1 1 1.00000 0.00000 0.0000 1.0000 diff --git a/content/finitetemp/SingleSpin/posfile b/content/finitetemp/SingleSpin/posfile new file mode 100644 index 0000000..37a0fa8 --- /dev/null +++ b/content/finitetemp/SingleSpin/posfile @@ -0,0 +1 @@ +1 1 0.0 0.0 0.0 diff --git a/content/finitetemp/finitetemp.rst b/content/finitetemp/finitetemp.rst index 2be3f1b..f45f958 100644 --- a/content/finitetemp/finitetemp.rst +++ b/content/finitetemp/finitetemp.rst @@ -1,2 +1,62 @@ Finite temperatures =================== + + +Statistics +---------- +In this exercise we will investigate how statistics affect simulated measurables. + +A single spin with an uniaxial anisotropy has a bi-stable, Ising like, magnetic state. At finite temperatures the stability of the magnetic state is not finite +but follows an exponential (Arrhenius) relaxation behaviour. As seen in the lecture, ensemble averaging can be crucial for the analysis of such systems. + + * Investigate the amount of statistics that is needed to say something relevant about the life time of the magnetic state of the system. + + * Does the need of statistics change with system parameters? (temperature, anisotropy, external field) + + * Extra: Can you fit the relaxation behaviour to an `Arrhenius function `_? + +You can do a similar analysis for a finite 1d-chain by either modifying the single spin example, or +starting from the `SimpleSystems/HeisChain `_ example. + + * Is there a difference by performing ensemble averaging compared to just increasing the system size? + + * Does the exchange interaction magnitude affect the stability of the spin chains? + +An accessible article for those interested in spin chains and statistics can be found here: `A. Vindigni Inorganica Chimica Acta, 361 3731 (2008) `_. + + + +Thermalization +-------------- +In this exercise the thermalization rates in spin simulations will be investigated. + +As mentioned in the lecture, thermalising the system before performing measurements is crucial for ensuring relevant results. +Here we will investigate this for a simple cubic model system. + +The initial ``inpsd.dat`` file looks as follows + +.. literalinclude:: SimpleCubic/inpsd.dat + +and the almost trivial ``posfile`` and ``momfile`` are written as + +.. literalinclude:: SimpleCubic/posfile +.. literalinclude:: SimpleCubic/momfile + +The ``jfile``, that will be changed during the exercise initially can look like + +.. literalinclude:: SimpleCubic/jfile + +i.e. including nearest and next-nearest neighbours on the cubic lattice. Notice that since ``sym 1`` is given in ``inpsd.dat``, the ``jfile`` can be kept to a minimum of two lines. + + * Starting with the inputs as defined above, vary the simulation method and damping (where applicable) to investigate the thermalization rate of the system. + + * Is the thermalization faster when going from low to high temperatures or vice versa? Anything particular happening around Tc? + + * Change the sign of the next-nearest neighbour and redo the study. Is the magnetization a good measurable for determining the thermalization now? + +Phase diagrams +-------------- + + +Minimization +------------ From e89e3dd50b92046b8b2d73c69cd7b22f5ad430e4 Mon Sep 17 00:00:00 2001 From: Anders Bergman Date: Tue, 11 Oct 2022 23:09:06 +0200 Subject: [PATCH 2/2] Added 2D square lattice example. --- .../finitetemp/SquareLattice/Base/inpsd.dat | 28 +++++++++++++ content/finitetemp/SquareLattice/Base/jfile | 1 + content/finitetemp/SquareLattice/Base/momfile | 1 + content/finitetemp/SquareLattice/Base/posfile | 1 + content/finitetemp/SquareLattice/printM.sh | 13 ++++++ content/finitetemp/SquareLattice/runme.sh | 12 ++++++ .../finitetemp/SquareLattice/sc_64_ALPS.dat | 42 +++++++++++++++++++ content/finitetemp/finitetemp.rst | 30 +++++++++++++ 8 files changed, 128 insertions(+) create mode 100644 content/finitetemp/SquareLattice/Base/inpsd.dat create mode 100644 content/finitetemp/SquareLattice/Base/jfile create mode 100644 content/finitetemp/SquareLattice/Base/momfile create mode 100644 content/finitetemp/SquareLattice/Base/posfile create mode 100755 content/finitetemp/SquareLattice/printM.sh create mode 100755 content/finitetemp/SquareLattice/runme.sh create mode 100644 content/finitetemp/SquareLattice/sc_64_ALPS.dat diff --git a/content/finitetemp/SquareLattice/Base/inpsd.dat b/content/finitetemp/SquareLattice/Base/inpsd.dat new file mode 100644 index 0000000..3b3af5d --- /dev/null +++ b/content/finitetemp/SquareLattice/Base/inpsd.dat @@ -0,0 +1,28 @@ +simid scHeis64 +ncell 64 64 1 +BC P P 0 Boundary conditions (0=vacuum,P=periodic) +cell 1.00000 0.00000 0.00000 + 0.00000 1.00000 0.00000 + 0.00000 0.00000 1.00000 +Sym 1 Symmetry of lattice (0 for no, 1 for cubic, 2 for 2d cubic, 3 for hexagonal) + +aunits Y +posfile ./posfile +exchange ./jfile +momfile ./momfile +do_prnstruct 1 + +Mensemble 1 +Initmag 3 (1=random, 2=cone, 3=spec., 4=file) + +ip_mode M Initial phase parameters +ip_temp TEMP -- +ip_mcNstep 5000 -- + +mode M S=SD, M=MC +temp TEMP Measurement phase parameters +mcNstep 5000 -- + +do_avrg Y Measure averages +plotenergy 1 +do_cumu Y diff --git a/content/finitetemp/SquareLattice/Base/jfile b/content/finitetemp/SquareLattice/Base/jfile new file mode 100644 index 0000000..921c92f --- /dev/null +++ b/content/finitetemp/SquareLattice/Base/jfile @@ -0,0 +1 @@ + 1 1 1.0 0.0 0.0 0.5000 diff --git a/content/finitetemp/SquareLattice/Base/momfile b/content/finitetemp/SquareLattice/Base/momfile new file mode 100644 index 0000000..e4329cd --- /dev/null +++ b/content/finitetemp/SquareLattice/Base/momfile @@ -0,0 +1 @@ +1 1 1.00000 0.0 0.0 1.0 diff --git a/content/finitetemp/SquareLattice/Base/posfile b/content/finitetemp/SquareLattice/Base/posfile new file mode 100644 index 0000000..37a0fa8 --- /dev/null +++ b/content/finitetemp/SquareLattice/Base/posfile @@ -0,0 +1 @@ +1 1 0.0 0.0 0.0 diff --git a/content/finitetemp/SquareLattice/printM.sh b/content/finitetemp/SquareLattice/printM.sh new file mode 100755 index 0000000..563786c --- /dev/null +++ b/content/finitetemp/SquareLattice/printM.sh @@ -0,0 +1,13 @@ +#! /bin/csh -f +foreach Temp (0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0) + echo $Temp | sed ' s/K//' > tmp + cat tmp >> Tlist + cat T$Temp/cumulants.scHeis64.out | tail -1 | awk '{print $2}' > tmp1 + cat T$Temp/cumulants.scHeis64.out | tail -1 | awk '{print $5}' > tmp2 + cat tmp1 >> Mlist + cat tmp2 >> Ulist +end + +paste Tlist Mlist Ulist > magnetization.dat +rm Tlist Mlist Ulist tmp tmp1 tmp2 +exit diff --git a/content/finitetemp/SquareLattice/runme.sh b/content/finitetemp/SquareLattice/runme.sh new file mode 100755 index 0000000..c634499 --- /dev/null +++ b/content/finitetemp/SquareLattice/runme.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +for Temp in 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 +do + mkdir T$Temp/ + echo "Temp: " $Temp + cp Base/* T$Temp/ + cd T$Temp/ + gsed -i "s/TEMP/$Temp/g" inpsd.dat + ${SD_BINARY} > out.log + cd .. +done diff --git a/content/finitetemp/SquareLattice/sc_64_ALPS.dat b/content/finitetemp/SquareLattice/sc_64_ALPS.dat new file mode 100644 index 0000000..ee76b5a --- /dev/null +++ b/content/finitetemp/SquareLattice/sc_64_ALPS.dat @@ -0,0 +1,42 @@ +# Temperature (J) Magnetization + 0.01000000 0.99162215 + 0.06000000 0.95483038 + 0.11000000 0.92026908 + 0.16000000 0.88392499 + 0.21000000 0.83767839 + 0.26000000 0.80447273 + 0.31000000 0.75743914 + 0.36000000 0.71563720 + 0.41000000 0.66379796 + 0.46000000 0.60234222 + 0.51000000 0.55313209 + 0.56000000 0.47708797 + 0.61000000 0.34753675 + 0.66000000 0.21652653 + 0.71000000 0.12810921 + 0.76000000 0.09693399 + 0.81000000 0.07360353 + 0.86000000 0.06022234 + 0.91000000 0.05290496 + 0.96000000 0.04736220 + 1.01000000 0.04230193 + 1.06000000 0.03953494 + 1.11000000 0.03636440 + 1.16000000 0.03424181 + 1.21000000 0.03237245 + 1.26000000 0.03086418 + 1.31000000 0.02957311 + 1.36000000 0.02842018 + 1.41000000 0.02759275 + 1.46000000 0.02657334 + 1.51000000 0.02610488 + 1.56000000 0.02525342 + 1.61000000 0.02479467 + 1.66000000 0.02425726 + 1.71000000 0.02366309 + 1.76000000 0.02337222 + 1.81000000 0.02274532 + 1.86000000 0.02252159 + 1.91000000 0.02217737 + 1.96000000 0.02185710 + 2.01000000 0.02166938 diff --git a/content/finitetemp/finitetemp.rst b/content/finitetemp/finitetemp.rst index f45f958..7d426cf 100644 --- a/content/finitetemp/finitetemp.rst +++ b/content/finitetemp/finitetemp.rst @@ -56,6 +56,36 @@ i.e. including nearest and next-nearest neighbours on the cubic lattice. Notice Phase diagrams -------------- +Obtaining the M vs T relationship is probably the most common use case for Monte Carlo simulations on spin systems. +In this exercise you can compare the MC functionalities of UppASD with a the ALPS package. + +The system in question is here the 2d square lattice with NN exchange couplings. +To compare with other model implementations this example uses the ``aunits Y`` flag which sets the temperature unit to the exchange strength ``J`` instead of Kelvin. + +The ``inpsd.dat`` will here look as follows (to start with). Note the **TEMP** entries for initial and measurement temperatures. + +.. literalinclude:: SquareLattice/Base/inpsd.dat + +and the ``posfile`` and ``momfile``, and ``jfile`` files looks as + +.. literalinclude:: SquareLattice/Base/posfile +.. literalinclude:: SquareLattice/Base/momfile +.. literalinclude:: SquareLattice/Base/jfile + +Again, note that with ``aunits Y`` the exchange interaction in ``jfile`` is not defined in ``mRy`` but in the dimensionless energy scale of ``J`` (not Joule either). + +In order to obtain the full M(T) curve, several simulations are needed at consecutive temperatures. +This is preferably scripted, like in this example where we use a simple ``bash`` script ``runme.sh`` + +.. literalinclude:: SquareLattice/runme.sh + +Here you either need to replace the ``${SD_BINARY}`` expression, or export the location of your UppASD binary as the environment variable with the same name. + + * Run the script and plot the resulting M(T) curve. + + * Compare with the reference data in the :download:`sc_64_ALPS.dat ` file + + * Are the simulation parameters "good enough" or are more thermalization/sampling steps needed to obtain an accurate M(T) curve? Minimization