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_scalar():
    mesh = CuboidMesh(1, 1, 1, 1, 1, 1)
    f = scalar_field(mesh, lambda r: r[0] + r[1] + r[2])
    assert np.allclose(f, np.array((1.5)))