Skip to content

Commit 3d6b29d

Browse files
author
Weiwei Wang
committed
add mesh pbc option
1 parent a245d8a commit 3d6b29d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

fidimag/common/cuboid_mesh.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
class CuboidMesh(object):
3535
def __init__(self, dx=1, dy=1, dz=1, nx=1, ny=1, nz=1, x0=0, y0=0, z0=0,
36-
periodicity=(False, False, False), unit_length=1.0):
36+
periodicity=(False, False, False), unit_length=1.0, pbc=None):
3737
"""
3838
Create mesh with cells of size dx * dy * dz.
3939
@@ -48,6 +48,8 @@ def __init__(self, dx=1, dy=1, dz=1, nx=1, ny=1, nz=1, x0=0, y0=0, z0=0,
4848
mesh = CuboidMesh(2, 2, 2, 250, 25, 2, periodicity=(True, False, False))
4949
# create a mesh of dimensions 500 x 50 x 4 nm, with cellsize
5050
# of 2 nm in any direction and periodic along the x-axis.
51+
# Alternatively, the periodicity can be set through the option 'pbc',
52+
# acceptable parameters could be '1d' or '2d'.
5153
5254
"""
5355
self.dx = dx
@@ -72,10 +74,16 @@ def __init__(self, dx=1, dy=1, dz=1, nx=1, ny=1, nz=1, x0=0, y0=0, z0=0,
7274
self.mesh_type = "cuboid"
7375
self.unit_length = unit_length
7476

77+
if pbc == '1d':
78+
self.periodicity = (True, False, False)
79+
elif pbc == '2d':
80+
self.periodicity = (True, True, False)
81+
7582
self.coordinates = self.init_coordinates()
7683
self.neighbours = self.init_neighbours()
7784
self.grid = self.init_grid() # for vtk export
7885

86+
7987
def init_coordinates(self):
8088
coordinates = np.zeros((self.n, 3))
8189
for i in range(self.nz):

fidimag/micro/llg_stt_cpp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, mesh, name='unnamed'):
2727
self.a_J = 1
2828
self.beta = 0
2929
self.J_time_fun = None
30+
self.p = (0,0,1)
3031

3132
def get_p(self):
3233
return self._p

0 commit comments

Comments
 (0)