-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
28 changed files
with
664 additions
and
1,987 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,31 @@ | ||
import netgen | ||
import ngsolve | ||
import numpy as np | ||
import pytest | ||
|
||
from ossdbs.electrodes import AbbottStJudeActiveTip6142_6145 | ||
|
||
from .test_electrodes import TestElectrode | ||
|
||
class TestAbbottStJudeActiveTip6142_6145: | ||
|
||
class TestAbbottStJudeActiveTip6142_6145(TestElectrode): | ||
@pytest.fixture | ||
def AbbottStJudeActiveTip6142_6145_electrode(self): | ||
def electrode(self): | ||
return AbbottStJudeActiveTip6142_6145() | ||
|
||
def test_rename_boundaries(self, AbbottStJudeActiveTip6142_6145_electrode): | ||
@pytest.fixture | ||
def electrode_name(self): | ||
return "AbbottStJudeActiveTip6142_6145" | ||
|
||
def test_rename_boundaries(self, electrode, electrode_name): | ||
"""Test whether set_contact_names() works.""" | ||
electrode = AbbottStJudeActiveTip6142_6145_electrode | ||
electrode.set_contact_names( | ||
{ | ||
"Body": "RenamedBody", | ||
"Contact_1": "RenamedContact_1", | ||
"NonExistingPart": "NonExistingPart", | ||
} | ||
) | ||
geometry = electrode.geometry | ||
netgen_geometry = netgen.occ.OCCGeometry(geometry) | ||
with ngsolve.TaskManager(): | ||
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh()) | ||
desired = { | ||
"RenamedBody", | ||
"RenamedContact_1", | ||
"Contact_2", | ||
"Contact_3", | ||
"Contact_4", | ||
} | ||
assert desired == set(mesh.GetBoundaries()) | ||
self.check_rename_boundaries(electrode, electrode_name) | ||
|
||
def test_contacts(self, AbbottStJudeActiveTip6142_6145_electrode): | ||
def test_contacts(self, electrode, electrode_name): | ||
"""Test the number and names of contacts.""" | ||
electrode = AbbottStJudeActiveTip6142_6145_electrode | ||
geometry = electrode.geometry | ||
netgen_geometry = netgen.occ.OCCGeometry(geometry) | ||
with ngsolve.TaskManager(): | ||
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh()) | ||
desired = {"Body", "Contact_1", "Contact_2", "Contact_3", "Contact_4"} | ||
assert desired == set(mesh.GetBoundaries()) | ||
self.check_contacts(electrode, electrode_name) | ||
|
||
def test_electrode_volume(self, AbbottStJudeActiveTip6142_6145_electrode): | ||
def test_electrode_volume(self, electrode, electrode_name): | ||
"""Test volume of the entire electrode.""" | ||
electrode = AbbottStJudeActiveTip6142_6145_electrode | ||
|
||
total_length = electrode._parameters.total_length | ||
tip_length = electrode._parameters.tip_length | ||
radius = electrode._parameters.lead_diameter * 0.5 | ||
height = total_length - tip_length | ||
|
||
desired = (np.pi * radius**2 * height) + (4 / 3 * np.pi * radius**3 * 0.5) | ||
actual = electrode.geometry.mass | ||
tolerance = 1e-5 | ||
self.check_electrode_volume(electrode, electrode_name) | ||
|
||
np.testing.assert_allclose(actual, desired, atol=tolerance) | ||
|
||
def test_contacts_volume(self, AbbottStJudeActiveTip6142_6145_electrode): | ||
def test_contacts_volume(self, electrode, electrode_name): | ||
"""Test volume of all the contacts.""" | ||
electrode = AbbottStJudeActiveTip6142_6145_electrode | ||
|
||
contact_length = electrode._parameters.contact_length | ||
radius = electrode._parameters.lead_diameter * 0.5 | ||
n_contacts = electrode._n_contacts | ||
|
||
C1_height = electrode._parameters.tip_length - radius | ||
C1_volume = (4 / 3 * radius**3 * np.pi * 0.5) + ( | ||
C1_height * radius**2 * np.pi | ||
) | ||
|
||
desired = (contact_length * radius**2 * np.pi) * (n_contacts - 1) + C1_volume | ||
actual = electrode._contacts().mass | ||
tolerance = 1e-5 | ||
|
||
np.testing.assert_allclose(actual, desired, atol=tolerance) | ||
self.check_contacts_volume(electrode, electrode_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,31 @@ | ||
import netgen | ||
import ngsolve | ||
import numpy as np | ||
import pytest | ||
|
||
from ossdbs.electrodes import AbbottStJudeActiveTip6146_6149 | ||
|
||
from .test_electrodes import TestElectrode | ||
|
||
class TestAbbottStJudeActiveTip6146_6149: | ||
|
||
class TestAbbottStJudeActiveTip6146_6149(TestElectrode): | ||
@pytest.fixture | ||
def AbbottStJudeActiveTip6146_6149_electrode(self): | ||
def electrode(self): | ||
return AbbottStJudeActiveTip6146_6149() | ||
|
||
def test_rename_boundaries(self, AbbottStJudeActiveTip6146_6149_electrode): | ||
@pytest.fixture | ||
def electrode_name(self): | ||
return "AbbottStJudeActiveTip6146_6149" | ||
|
||
def test_rename_boundaries(self, electrode, electrode_name): | ||
"""Test whether set_contact_names() works.""" | ||
electrode = AbbottStJudeActiveTip6146_6149_electrode | ||
electrode.set_contact_names( | ||
{ | ||
"Body": "RenamedBody", | ||
"Contact_1": "RenamedContact_1", | ||
"NonExistingPart": "NonExistingPart", | ||
} | ||
) | ||
geometry = electrode.geometry | ||
netgen_geometry = netgen.occ.OCCGeometry(geometry) | ||
with ngsolve.TaskManager(): | ||
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh()) | ||
desired = { | ||
"RenamedBody", | ||
"RenamedContact_1", | ||
"Contact_2", | ||
"Contact_3", | ||
"Contact_4", | ||
} | ||
assert desired == set(mesh.GetBoundaries()) | ||
self.check_rename_boundaries(electrode, electrode_name) | ||
|
||
def test_contacts(self, AbbottStJudeActiveTip6146_6149_electrode): | ||
def test_contacts(self, electrode, electrode_name): | ||
"""Test the number and names of contacts.""" | ||
electrode = AbbottStJudeActiveTip6146_6149_electrode | ||
geometry = electrode.geometry | ||
netgen_geometry = netgen.occ.OCCGeometry(geometry) | ||
with ngsolve.TaskManager(): | ||
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh()) | ||
desired = {"Body", "Contact_1", "Contact_2", "Contact_3", "Contact_4"} | ||
assert desired == set(mesh.GetBoundaries()) | ||
self.check_contacts(electrode, electrode_name) | ||
|
||
def test_electrode_volume(self, AbbottStJudeActiveTip6146_6149_electrode): | ||
def test_electrode_volume(self, electrode, electrode_name): | ||
"""Test volume of the entire electrode.""" | ||
electrode = AbbottStJudeActiveTip6146_6149_electrode | ||
|
||
total_length = electrode._parameters.total_length | ||
tip_length = electrode._parameters.tip_length | ||
radius = electrode._parameters.lead_diameter * 0.5 | ||
height = total_length - tip_length | ||
|
||
desired = (np.pi * radius**2 * height) + (4 / 3 * np.pi * radius**3 * 0.5) | ||
actual = electrode.geometry.mass | ||
tolerance = 1e-5 | ||
self.check_electrode_volume(electrode, electrode_name) | ||
|
||
np.testing.assert_allclose(actual, desired, atol=tolerance) | ||
|
||
def test_contacts_volume(self, AbbottStJudeActiveTip6146_6149_electrode): | ||
def test_contacts_volume(self, electrode, electrode_name): | ||
"""Test volume of all the contacts.""" | ||
electrode = AbbottStJudeActiveTip6146_6149_electrode | ||
|
||
contact_length = electrode._parameters.contact_length | ||
radius = electrode._parameters.lead_diameter * 0.5 | ||
n_contacts = electrode._n_contacts | ||
|
||
C1_height = electrode._parameters.tip_length - radius | ||
C1_volume = (4 / 3 * radius**3 * np.pi * 0.5) + ( | ||
C1_height * radius**2 * np.pi | ||
) | ||
|
||
desired = (contact_length * radius**2 * np.pi) * (n_contacts - 1) + C1_volume | ||
actual = electrode._contacts().mass | ||
tolerance = 1e-5 | ||
|
||
np.testing.assert_allclose(actual, desired, atol=tolerance) | ||
self.check_contacts_volume(electrode, electrode_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,31 @@ | ||
import netgen | ||
import ngsolve | ||
import numpy as np | ||
import pytest | ||
|
||
from ossdbs.electrodes import AbbottStJudeDirected6172 | ||
|
||
from .test_electrodes import TestElectrode | ||
|
||
class TestAbbottStJudeDirected6172: | ||
|
||
class TestAbbottStJudeDirected6172(TestElectrode): | ||
@pytest.fixture | ||
def AbbottStJudeDirected6172_electrode(self): | ||
def electrode(self): | ||
return AbbottStJudeDirected6172() | ||
|
||
def test_rename_boundaries(self, AbbottStJudeDirected6172_electrode): | ||
@pytest.fixture | ||
def electrode_name(self): | ||
return "AbbottStJudeDirected6172" | ||
|
||
def test_rename_boundaries(self, electrode, electrode_name): | ||
"""Test whether set_contact_names() works.""" | ||
electrode = AbbottStJudeDirected6172_electrode | ||
electrode.set_contact_names( | ||
{ | ||
"Body": "RenamedBody", | ||
"Contact_1": "RenamedContact_1", | ||
"NonExistingPart": "NonExistingPart", | ||
} | ||
) | ||
geometry = electrode.geometry | ||
netgen_geometry = netgen.occ.OCCGeometry(geometry) | ||
with ngsolve.TaskManager(): | ||
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh()) | ||
desired = { | ||
"RenamedBody", | ||
"RenamedContact_1", | ||
"Contact_2", | ||
"Contact_3", | ||
"Contact_4", | ||
"Contact_5", | ||
"Contact_6", | ||
"Contact_7", | ||
"Contact_8", | ||
} | ||
assert desired == set(mesh.GetBoundaries()) | ||
self.check_rename_boundaries(electrode, electrode_name) | ||
|
||
def test_contacts(self, AbbottStJudeDirected6172_electrode): | ||
def test_contacts(self, electrode, electrode_name): | ||
"""Test the number and names of contacts.""" | ||
electrode = AbbottStJudeDirected6172_electrode | ||
geometry = electrode.geometry | ||
netgen_geometry = netgen.occ.OCCGeometry(geometry) | ||
with ngsolve.TaskManager(): | ||
mesh = ngsolve.Mesh(netgen_geometry.GenerateMesh()) | ||
desired = { | ||
"Body", | ||
"Contact_1", | ||
"Contact_2", | ||
"Contact_3", | ||
"Contact_4", | ||
"Contact_5", | ||
"Contact_6", | ||
"Contact_7", | ||
"Contact_8", | ||
} | ||
assert desired == set(mesh.GetBoundaries()) | ||
self.check_contacts(electrode, electrode_name) | ||
|
||
def test_electrode_volume(self, AbbottStJudeDirected6172_electrode): | ||
def test_electrode_volume(self, electrode, electrode_name): | ||
"""Test volume of the entire electrode.""" | ||
electrode = AbbottStJudeDirected6172_electrode | ||
|
||
total_length = electrode._parameters.total_length | ||
tip_length = electrode._parameters.tip_length | ||
radius = electrode._parameters.lead_diameter * 0.5 | ||
height = total_length - tip_length | ||
|
||
desired = (np.pi * radius**2 * height) + (4 / 3 * np.pi * radius**3 * 0.5) | ||
actual = electrode.geometry.mass | ||
tolerance = 1e-5 | ||
self.check_electrode_volume(electrode, electrode_name) | ||
|
||
np.testing.assert_allclose(actual, desired, atol=tolerance) | ||
|
||
def test_contacts_volume(self, AbbottStJudeDirected6172_electrode): | ||
def test_contacts_volume(self, electrode, electrode_name): | ||
"""Test volume of all the contacts.""" | ||
electrode = AbbottStJudeDirected6172_electrode | ||
|
||
contact_length = electrode._parameters.contact_length | ||
radius = electrode._parameters.lead_diameter * 0.5 | ||
|
||
desired = (np.pi * radius**2 * contact_length * 2) + ( | ||
np.pi * radius**2 * contact_length * 90 / 360 | ||
) * 6 | ||
|
||
actual = electrode._contacts().mass | ||
tolerance = 1e-5 | ||
|
||
np.testing.assert_allclose(actual, desired, atol=tolerance) | ||
self.check_contacts_volume(electrode, electrode_name) |
Oops, something went wrong.