Beispiel #1
0
 def __init__(self, mesh, J, name="exchange"):
     self.mesh = mesh
     # J is a scalar field, because that's good enough for uniform
     # exchange. Could be changed trivially by making J a vector field
     # and changing the J = self.J[c_i] line in the compute method.
     self.J = scalar_field(mesh, J)
     # field and energy are just np.arrays. In principle, they could be
     # created in the scope of the compute method, but we want to avoid
     # re-creating the objects in memory unnecessarily.
     self.field = vector_field(mesh, 0)
     self.energy = scalar_field(mesh, 0)
     self.in_jacobian = True
Beispiel #2
0
def test_initialise_vector():
    mesh = CuboidMesh(1, 1, 1, 1, 1, 1)
    v = vector_field(mesh, lambda r: 2 * r)
    assert np.allclose(v, np.array((1, 1, 1)))