Skip to content

Commit

Permalink
Merge pull request #30 from ubermag/loading_subregions_for_compute
Browse files Browse the repository at this point in the history
Check loading subregions with compute
  • Loading branch information
lang-m authored Oct 20, 2022
2 parents c953d4c + e01c91d commit 146f448
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions micromagnetictests/calculatortests/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ def setup(self):
p2 = (10e-9, 2e-9, 2e-9)
cell = (2e-9, 2e-9, 2e-9)
region = df.Region(p1=p1, p2=p2)
mesh = df.Mesh(region=region, cell=cell)

subregions = {
"a": df.Region(p1=(0, 0, 0), p2=(6e-9, 2e-9, 2e-9)),
"b": df.Region(p1=(6e-9, 0, 0), p2=(10e-9, 2e-9, 2e-9)),
}
mesh = df.Mesh(region=region, cell=cell, subregions=subregions)
self.subregions = subregions
self.system = mm.System(name=name)
self.system.energy = (
mm.Exchange(A=1e-12)
Expand All @@ -39,23 +43,24 @@ def test_energy(self):

def test_energy_density(self):
for term in self.system.energy:
assert isinstance(
self.calculator.compute(term.density, self.system), df.Field
)
assert isinstance(
self.calculator.compute(self.system.energy.density, self.system), df.Field
)
e_density = self.calculator.compute(term.density, self.system)
assert isinstance(e_density, df.Field)
assert e_density.mesh.subregions == self.subregions
e_density = self.calculator.compute(self.system.energy.density, self.system)
assert isinstance(e_density, df.Field)
assert e_density.mesh.subregions == self.subregions
self.calculator.delete(self.system)

def test_effective_field(self):
for term in self.system.energy:
assert isinstance(
self.calculator.compute(term.effective_field, self.system), df.Field
)
assert isinstance(
self.calculator.compute(self.system.energy.effective_field, self.system),
df.Field,
effective_field = self.calculator.compute(term.effective_field, self.system)
assert isinstance(effective_field, df.Field)
assert effective_field.mesh.subregions == self.subregions
effective_field = self.calculator.compute(
self.system.energy.effective_field, self.system
)
assert isinstance(effective_field, df.Field)
assert effective_field.mesh.subregions == self.subregions
self.calculator.delete(self.system)

def test_invalid_func(self):
Expand All @@ -79,12 +84,14 @@ def test_dmi(self):
assert isinstance(
self.calculator.compute(term.energy, self.system), float
)
assert isinstance(
self.calculator.compute(term.density, self.system), df.Field
)
assert isinstance(
self.calculator.compute(term.effective_field, self.system), df.Field
e_density = self.calculator.compute(term.density, self.system)
assert isinstance(e_density, df.Field)
assert e_density.mesh.subregions == self.subregions
effective_field = self.calculator.compute(
term.effective_field, self.system
)
assert isinstance(effective_field, df.Field)
assert effective_field.mesh.subregions == self.subregions
assert isinstance(
self.calculator.compute(self.system.energy.energy, self.system), float
)
Expand Down

0 comments on commit 146f448

Please sign in to comment.