diff --git a/_setup/parameters.py b/_setup/parameters.py
index 0339036095a9fbd537c4d5f7ce74553063e0287d..1d51c49681fd274b3e494bea28bf591ef531e137 100644
--- a/_setup/parameters.py
+++ b/_setup/parameters.py
@@ -20,11 +20,12 @@ class Parameters:
'''
- def __init__(self, A=None, Ms=None, K=0.0, D=0.0, gamma0=2.212761569e+05, mu0=scipy.pi*4.0e-07, alpha=1.0, T_start=None, T_end=None, k=None, H_ext=None, easy_axis=(1,0,0), zhangLi=False, g=2.0023193043617, muB=9.27400968e-24, e=1.6021766208e-19, P=None, J=None, xi=None, dmCoupling="none", maxwellCoupling="strayField", slonczewski=False, hbar=1.054571800e-34, Je=None, d=None, p=(1,0,0), TOL=1.0e-8, preconditionerType="jacobi", guessType="old", theta=0.5):
+ def __init__(self, A=None, Ms=None, K=0.0, D=0.0, dmi_axis='z', gamma0=2.212761569e+05, mu0=scipy.pi*4.0e-07, alpha=1.0, T_start=None, T_end=None, k=None, H_ext=None, easy_axis=(1,0,0), zhangLi=False, g=2.0023193043617, muB=9.27400968e-24, e=1.6021766208e-19, P=None, J=None, xi=None, dmCoupling="none", maxwellCoupling="strayField", slonczewski=False, hbar=1.054571800e-34, Je=None, d=None, p=(1,0,0), TOL=1.0e-8, preconditionerType="jacobi", guessType="old", theta=0.5):
self.A = A
self.Ms = Ms
self.K = K
self.D = D
+ self.dmi_axis = dmi_axis
self.gamma0 = gamma0
self.mu0 = mu0
diff --git a/integrators/_integrator.py b/integrators/_integrator.py
index e71163b31e8d977927c98f3bb7be752704105d41..5becb5469582dbce838350cda873422dee6a37fb 100644
--- a/integrators/_integrator.py
+++ b/integrators/_integrator.py
@@ -364,7 +364,8 @@ class _Integrator:
self._t += self._k
self._time_cf.Set( self._t )
- print(self._itCounter)
+ if(self._callback != None):
+ print(self._callback)
self.Write()
@@ -388,12 +389,9 @@ class _Integrator:
if duration != None:
if self.parameters.T_start == None:
self.parameters.T_start = 0.0
- self.parameters.T_end = duration
- elif self.parameters.T_end == None:
- self.parameters.T_end = self.parameters.T_start + duration
- else:
+ elif self._counter != 0:
self.parameters.T_start = self.Time()
- self.parameters.T_end = self.parameters.T_start + duration
+ self.parameters.T_end = self.parameters.T_start + duration
self.GetReady()
self.Do()
diff --git a/integrators/_linearForms/_opInterfacialDMI.py b/integrators/_linearForms/_opInterfacialDMI.py
index fb922a2a2c58f63b54f4df9037f9e67f318108f9..ef93b5fe592d08afdb02439e78f236dc44d98c0c 100644
--- a/integrators/_linearForms/_opInterfacialDMI.py
+++ b/integrators/_linearForms/_opInterfacialDMI.py
@@ -1,11 +1,15 @@
from ngsolve import CoefficientFunction
+
################################################################################
-def _OpInterfacialDMI(Dgf, axis):
+def _OpInterfacialDMI(Dgf, ax):
op = [None, None, None]
+ axisMap = {'x': 0, 'y': 1, 'z': 2}
+ axis = axisMap[ax]
+
for j in range(3):
if(j == axis):
op[j] = sum(Dgf[k,k] for k in range(3) if k != axis)
diff --git a/integrators/_linearForms/interfacialAxisDMI.py b/integrators/_linearForms/interfacialAxisDMI.py
index 30794dd1cacb781563e816f559a4a4ed33b2e410..70bc0ec8d14e28da0c58b7c1cfc4cb95c7cdf776 100644
--- a/integrators/_linearForms/interfacialAxisDMI.py
+++ b/integrators/_linearForms/interfacialAxisDMI.py
@@ -5,9 +5,7 @@ from . import _opInterfacialDMI
################################################################################
-def InterfacialAxisDMI(phi, gf, Dphi, Dgf, specialAxis='z'):
- axisMap = {'x': 0, 'y': 1, 'z': 2}
- ax = axisMap[specialAxis]
+def InterfacialAxisDMI(phi, gf, Dphi, Dgf, ax):
return InnerProd(_opInterfacialDMI._OpInterfacialDMI(Dgf, ax), phi) \
+ InnerProd(gf, _opInterfacialDMI._OpInterfacialDMI(Dphi, ax))
diff --git a/integrators/_linearForms/interfacialDMI.py b/integrators/_linearForms/interfacialDMI.py
deleted file mode 100644
index d7cac18866a9bd0607e684072331f910a580b5c4..0000000000000000000000000000000000000000
--- a/integrators/_linearForms/interfacialDMI.py
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-################################################################################
-
-
-def InterfacialDMI(phi, gf, Dphi, Dgf):
-
- return \
- - Dgf[2,0]*phi[0] - Dgf[2,1]*phi[1] \
- + Dgf[0,0]*phi[2] + Dgf[1,1]*phi[2] \
- + gf[2]*Dphi[0,0] + gf[2]*Dphi[1,1] \
- - gf[0]*Dphi[2,0] - gf[1]*Dphi[2,1]
-
-################################################################################
diff --git a/integrators/_tpsx.py b/integrators/_tpsx.py
index c5868d5732fc4e4f16f3fb1066f1a92b6eba0fda..b56e2e3f3316e5e5d1b032ac575660f33d5a2760 100644
--- a/integrators/_tpsx.py
+++ b/integrators/_tpsx.py
@@ -466,7 +466,8 @@ class TPSX(_integrator._Integrator):
def _InterfacialDMI(self, gf, Dgf):
- return _linearForms.InterfacialAxisDMI(self._phi, gf, self._Dphi, Dgf, 'z')
+ return _linearForms.InterfacialAxisDMI(self._phi, gf, self._Dphi, Dgf \
+ , self.parameters.dmi_axis)
#------------------------------------------------------------------------------#
diff --git a/integrators/tps2.py b/integrators/tps2.py
index bc4946da83fd842aa544b1e4689c071b2c5e1c77..3dd8748cc73c29df123bdf6fb27faeeac8b5128f 100644
--- a/integrators/tps2.py
+++ b/integrators/tps2.py
@@ -117,73 +117,28 @@ class TPS2(_tpsx.TPSX):
def _ComputeWeight(self):
- # TODO abstrahieren
- # exchange
- tmp_cf = -self._C_ex * FrobeniusInnerProd(self._Mag.Dm, self._Mag.Dm)
-
- # external
+ tmp_cf = self._WeightExchange()
+
if (self.parameters.H_ext != None and any(self.parameters.H_ext)):
- tmp_cf += InnerProd(self._hext_cf, self._Mag.m)
-
- # anisotropy
+ tmp_cf += self._WeightApplied()
+
if (self._C_ani):
- tmp_cf -= self._C_ani \
- * InnerProd(self._Mag.phiUniaxialAnisotropy(self._easy_cf), self._Mag.cf)
-
- # dm
- if (self.parameters.dmCoupling == "bulk"):
- tmp_cf -= self._C_dm \
- * InnerProd(Curl(self._Mag.Dm), self._Mag.m)
- elif (self.parameters.dmCoupling == "interfacial"):
- tmp_cf -= self._C_dm \
- * ( -self._Mag.Dm[2,0]*self._Mag.cf[0] \
- - self._Mag.Dm[2,1]*self._Mag.cf[1] \
- + self._Mag.Dm[0,0]*self._Mag.cf[2] \
- + self._Mag.Dm[1,1]*self._Mag.cf[2] )
- elif (self.parameters.dmCoupling != "none"):
- print("Error in TPS2._ComputeWeight():")
- print("Dzyaloshinskii-Moriya options not >bulk<, >interfacial< \
- or >none< are not implemented yet")
- sys.exit()
-
- # maxwell
- if (self.parameters.maxwellCoupling=="strayField"):
- tmp_cf += InnerProd(self._Mag.hs.cf, self._Mag.m)
- elif (self.parameters.maxwellCoupling=="eddyCurrent"):
- pass # TOECDO
-# tmp_cf += self._Mag.H.restricted_cf * self._Mag.cf
- elif (self.parameters.maxwellCoupling != "none"):
- print("Error in TPS2.ComputeWeight():")
- print("Maxwell options not >strayField<, >eddyCurrent< \
- or >none< are not implemented yet")
- sys.exit()
-
- # zhang-li
- if (self.parameters.zhangLi):
- tmp_cf += CoefficientFunction( CrossProd( self._Mag.m \
- , self._Mag.opZhangLi(self._j_cf) ) ) * self._Mag.cf
- tmp_cf += self.parameters.xi \
- * CoefficientFunction(self._Mag.opZhangLi(self._j_cf) ) \
- * self._Mag.cf
-
- # slonczewski
- if (self.parameters.slonczewski):
- from commix.integrators._linearForms._gSlonczewski import _G
- G = _G(self.parameters.P, self._p_cf, self._Mag.m)
+ tmp_cf += self._WeightUniaxialAnisotropy()
- tmp_cf += G * CoefficientFunction( CrossProd( self._Mag.m \
- , self._p_cf ) ) * self._Mag.cf
+ if (self.parameters.dmCoupling != "none"):
+ tmp_cf += self._WeightDzyaloshinskiiMoriya()
- weight = IfPos(-tmp_cf, \
- self.parameters.alpha / (1.0 + self._k*self._theta \
- / self.parameters.alpha*IfPos(self.MWeightCut(self._k)+tmp_cf, \
- -tmp_cf, self.MWeightCut(self._k))), \
- self.parameters.alpha + self._k*self._theta \
- * IfPos(self.MWeightCut(self._k)-tmp_cf, \
- tmp_cf, self.MWeightCut(self._k) ) )
+ if(self.parameters.maxwellCoupling != "none"):
+ tmp_cf += self._WeightMaxwell()
+
+ if(self.parameters.zhangLi):
+ tmp_cf += self._WeightZhangLi()
+
+ if (self.parameters.slonczewski):
+ tmp_cf += self._WeightSlonczewski()
- return weight
+ return self._WeightCut(tmp_cf)
#------------------------------------------------------------------------------#
@@ -411,6 +366,96 @@ class TPS2(_tpsx.TPSX):
return True
+#------------------------------------------------------------------------------#
+
+
+ def _WeightExchange(self):
+ return -self._C_ex * FrobeniusInnerProd(self._Mag.Dm, self._Mag.Dm)
+
+
+#------------------------------------------------------------------------------#
+
+
+ def _WeightApplied(self):
+ return InnerProd(self._hext_cf, self._Mag.m)
+
+
+#------------------------------------------------------------------------------#
+
+
+ def _WeightUniaxialAnisotropy(self):
+ return -self._C_ani \
+ * InnerProd(self._Mag.phiUniaxialAnisotropy(self._easy_cf), self._Mag.cf)
+
+
+#------------------------------------------------------------------------------#
+
+
+ def _WeightDzyaloshinskiiMoriya(self):
+ if(self.parameters.dmCoupling == "bulk"):
+ return -self._C_dm \
+ * InnerProd(Curl(self._Mag.Dm), self._Mag.m)
+ elif(self.parameters.dmCoupling == "interfacial"):
+ from commix.integrators._linearForms._opInterfacialDMI \
+ import _OpInterfacialDMI
+ return -self._C_dm \
+ * InnerProd(self._Mag.m \
+ , _OpInterfacialDMI(self._Mag.Dm, self.parameters.dmi_axis))
+ elif (self.parameters.dmCoupling != "none"):
+ print("Error in TPS2._ComputeWeight():")
+ print("Dzyaloshinskii-Moriya options not >bulk<, >interfacial< \
+ or >none< are not implemented yet")
+ sys.exit()
+
+
+#------------------------------------------------------------------------------#
+
+
+ def _WeightMaxwell(self):
+ if (self.parameters.maxwellCoupling=="strayField"):
+ return InnerProd(self._Mag.hs.cf, self._Mag.m)
+ elif (self.parameters.maxwellCoupling != "none"):
+ print("Error in TPS2.ComputeWeight():")
+ print("Maxwell options not >strayField< \
+ or >none< are not implemented yet")
+ sys.exit()
+
+
+#------------------------------------------------------------------------------#
+
+
+ def _WeightZhangLi(self):
+ return self._C_zl * CoefficientFunction( CrossProd( self._Mag.m \
+ , self._Mag.opZhangLi(self._j_cf) ) ) * self._Mag.cf \
+ + self._C_zl * self.parameters.xi \
+ * CoefficientFunction(self._Mag.opZhangLi(self._j_cf) ) \
+ * self._Mag.cf
+
+
+#------------------------------------------------------------------------------#
+
+
+ def _WeightSlonczewski(self):
+ from commix.integrators._linearForms._gSlonczewski import _G
+ G = _G(self.parameters.P, self._p_cf, self._Mag.m)
+
+ return self._C_sl * G * CoefficientFunction( CrossProd( self._Mag.m \
+ , self._p_cf ) ) * self._Mag.cf
+
+
+#------------------------------------------------------------------------------#
+
+
+ def _WeightCut(self, cf):
+ return IfPos(-cf, \
+ self.parameters.alpha / (1.0 + self._k*self._theta \
+ / self.parameters.alpha*IfPos(self.MWeightCut(self._k)+cf, \
+ -cf, self.MWeightCut(self._k))), \
+ self.parameters.alpha + self._k*self._theta \
+ * IfPos(self.MWeightCut(self._k)-cf, \
+ cf, self.MWeightCut(self._k) ) )
+
+
#------------------------------------------------------------------------------#
diff --git a/tests/nucleation.py b/tests/nucleation.py
index 60099545afc1feb1e1f301f930c2e7c17df6dc8c..23b39b76354fa176f64b17d4521ed5050cf28842 100644
--- a/tests/nucleation.py
+++ b/tests/nucleation.py
@@ -7,7 +7,7 @@ ngsglobals.numthreads = 4
geo = Geometry(geometry=Disk(80.0, 0.4), h_max=1.0, scaling=1.0e-09)
par = Parameters(A=1.5e-11, Ms=5.8e+05, K=8.0e+05, alpha=0.3 \
, slonczewski=True, D=5.0e-03, Je = 2.0e+12, dmCoupling="interfacial", P=0.4 \
- , d=0.4e-09, k=0.1e-12)
+ , d=0.4e-09, k=0.5e-12)
par.easy_axis = (0, 0, 1)
inside = IfPos(x*x + y*y - 20.0**2, 0.0, -1.0)
par.p = (0.0, 0.0, inside)
diff --git a/tests/nucleationTest.py b/tests/nucleationTest.py
index ff71994363d4d86c8a2937413ff0ecd58ddfd87c..ee95f298e4369df23739171749511e00bb7a1a5e 100644
--- a/tests/nucleationTest.py
+++ b/tests/nucleationTest.py
@@ -1,20 +1,22 @@
from commix import *
from ngsolve import IfPos, x, y
+from ngsolve import ngsglobals
+ngsglobals.numthreads = 4
+
geo = Geometry(geometry="data/nucleation_mesh.vol", scaling=1e-09)
par = Parameters(A=1.5e-11, Ms=5.8e+05, K=8.0e+05, alpha=0.3 \
, slonczewski=True, D=3.0e-03, Je = 2.0e+12, dmCoupling="interfacial", P=0.4 \
- , d=0.4e-09, T_start=0.0e-09, T_end=2.0e-09, k=1.0e-13)
+ , d=0.4e-09, k=1.0e-13)
par.easy_axis = (0, 0, 1)
inside = IfPos(x*x + y*y - 20.0**2, 0.0, -1.0)
par.p = (0.0, 0.0, inside)
-par.maxwellCoupling = "none"
-
+#par.maxwellCoupling = "none"
par.m0 = "data/nucleationRelaxed.vtk"
nuc = Integrator(scheme=TPS2AB, geometry=geo, parameters=par)
nuc.SetResultsFolder("NucleationResult")
-nuc.Integrate()
+nuc.Integrate(2.0e-09)
diff --git a/tests/sp4.py b/tests/sp4.py
index ce17c3e11038bb75800739cbe294ffb08261bd8a..6a68762ab8887563200db2af66cce88a91e8538c 100644
--- a/tests/sp4.py
+++ b/tests/sp4.py
@@ -5,7 +5,7 @@ ngsglobals.numthreads = 4
geo = Geometry(geometry="data/sp4mesh.vol", scaling=1.0e-09)
par = Parameters(A=1.3e-11, Ms=8.0e+05, K=0.0, gamma0=2.211e+05, alpha=0.02 \
- , T_start=0.0e-09, T_end=3.0e-09, k=0.1e-12)
+ , T_start=0.0e-09, T_end=3.0e-09, k=0.5e-12)
par.m0 = "data/sp4sState.vtk"
par.H_ext = (-24.6e-03/par.mu0, 4.3e-03/par.mu0, 0.0)
diff --git a/tests/sp5_fromRelaxed.py b/tests/sp5_fromRelaxed.py
index 2968fa755f381f9aa61a8719d8e3f8fd9a46d374..160926d192788e73a2466fff6fcd165685ef6dff 100644
--- a/tests/sp5_fromRelaxed.py
+++ b/tests/sp5_fromRelaxed.py
@@ -1,5 +1,8 @@
from commix import *
+from ngsolve import ngsglobals
+ngsglobals.numthreads=2
+
geo = Geometry(geometry="data/sp5mesh.vol", scaling=1.0e-09)
par = Parameters(A=1.3e-11, Ms=8.0e+05, K=0.0, gamma0=2.211e+05, alpha=0.1 \
, zhangLi=True, g=2.0, P=1.0e+12, J=(1.0, 0.0, 0.0), xi=0.05 \