Skip to content

Commit

Permalink
Added test coverage for model.features().
Browse files Browse the repository at this point in the history
  • Loading branch information
john-hen committed Feb 23, 2021
1 parent 1b7b260 commit ee8de1f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
21 changes: 14 additions & 7 deletions mph/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,23 @@ def physics(self):
tags = [str(tag) for tag in self.java.physics().tags()]
return [str(self.java.physics(tag).name()) for tag in tags]

def physic_features(self, node):
def features(self, physics):
"""
Returns features for a specified physics node. Those features
include initial conditions, boundary conditions and COMSOL specific
advanced modeling features connected to the physics type.
Returns the names of all features in the given `physics` interface.
Features refers to the nodes defined under a physics interface.
They define the differential equation, boundary conditions,
initial values, etc.
"""
physicsTags = [str(tag) for tag in self.java.physics().tags()]
ptag = physicsTags[self.physics().index(node)]
if physics not in self.physics():
error = f'No physics interface named "{physics}".'
logger.error(error)
raise ValueError(error)
tags = [str(tag) for tag in self.java.physics().tags()]
ptag = tags[self.physics().index(physics)]
tags = [str(tag) for tag in self.java.physics(ptag).feature().tags()]
return [str(self.java.physics(ptag).feature(tag).name()) for tag in tags]
return [str(self.java.physics(ptag).feature(ftag).name())
for ftag in tags]

def materials(self):
"""Returns the names of all materials."""
Expand Down
10 changes: 10 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ def test_physics():
assert 'electric currents' in physics


def test_features():
features = model.features('electrostatic')
assert 'Laplace equation' in features
assert 'zero charge' in features
assert 'initial values' in features
assert 'anode' in features
assert 'cathode' in features


def test_materials():
materials = model.materials()
assert 'medium 1' in materials
Expand Down Expand Up @@ -289,6 +298,7 @@ def test_save():
test_geometries()
test_selections()
test_physics()
test_features()
test_materials()
test_meshes()
test_studies()
Expand Down

0 comments on commit ee8de1f

Please sign in to comment.