Skip to content

Commit

Permalink
test that type of element is loci is float
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar-21 committed Jul 2, 2024
1 parent 327fa20 commit bc90c8d
Showing 1 changed file with 31 additions and 37 deletions.
68 changes: 31 additions & 37 deletions tests/test_invessel_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import numpy as np
import pytest

# import this before read_vmec to deal with conflicting
# import this before read_vmec to deal with conflicting
# dependencies correctly
import parastell.invessel_build as ivb

import src.pystell.read_vmec as read_vmec


def remove_files():
if Path('chamber.step').exists():
Path.unlink('chamber.step')
if Path('component.step').exists():
Path.unlink('component.step')
if Path('dagmc.h5m').exists():
Path.unlink('dagmc.h5m')
if Path('stellarator.log').exists():
Path.unlink('stellarator.log')

if Path("chamber.step").exists():
Path.unlink("chamber.step")
if Path("component.step").exists():
Path.unlink("component.step")
if Path("dagmc.h5m").exists():
Path.unlink("dagmc.h5m")
if Path("stellarator.log").exists():
Path.unlink("stellarator.log")


@pytest.fixture
Expand All @@ -29,35 +29,29 @@ def radial_build():
poloidal_angles = [0.0, 120.0, 240.0, 360.0]
wall_s = 1.08
radial_build_dict = {
'component': {
'thickness_matrix': np.ones(
"component": {
"thickness_matrix": np.ones(
(len(toroidal_angles), len(poloidal_angles))
)*10
)
* 10
}
}

radial_build_obj = ivb.RadialBuild(
toroidal_angles,
poloidal_angles,
wall_s,
radial_build_dict
toroidal_angles, poloidal_angles, wall_s, radial_build_dict
)

return radial_build_obj


@pytest.fixture
def invessel_build(radial_build):
vmec_file = Path('files_for_tests') / 'wout_vmec.nc'

vmec_file = Path("files_for_tests") / "wout_vmec.nc"
vmec = read_vmec.VMECData(vmec_file)
num_ribs = 11

ivb_obj = ivb.InVesselBuild(
vmec,
radial_build,
num_ribs=num_ribs
)
ivb_obj = ivb.InVesselBuild(vmec, radial_build, num_ribs=num_ribs)

return ivb_obj

Expand All @@ -72,10 +66,10 @@ def test_ivb_basics(invessel_build):
num_ribs_exp = 11
num_rib_pts_exp = 67
scale_exp = 100
chamber_mat_tag_exp = 'Vacuum'
chamber_mat_tag_exp = "Vacuum"

remove_files()

invessel_build.populate_surfaces()

assert np.allclose(
Expand All @@ -85,13 +79,13 @@ def test_ivb_basics(invessel_build):
invessel_build.radial_build.poloidal_angles, poloidal_angles_exp
)
assert (
len(invessel_build.radial_build.radial_build.keys()) ==
num_components_exp
len(invessel_build.radial_build.radial_build.keys())
== num_components_exp
)
assert invessel_build.radial_build.wall_s == wall_s_exp
assert (
invessel_build.radial_build.radial_build['chamber']['mat_tag'] ==
chamber_mat_tag_exp
invessel_build.radial_build.radial_build["chamber"]["mat_tag"]
== chamber_mat_tag_exp
)
assert invessel_build.repeat == repeat_exp
assert invessel_build.num_ribs == num_ribs_exp
Expand All @@ -112,17 +106,17 @@ def test_ivb_construction(invessel_build):
invessel_build.calculate_loci()
invessel_build.generate_components()

rib_loci = invessel_build.Surfaces['component'].get_loci()[0]

rib_loci = invessel_build.Surfaces["component"].get_loci()[0]

assert len(invessel_build.Components) == num_components_exp
assert len(rib_loci[0]) == len_loci_pt_exp
assert isinstance(rib_loci[0][0], float)

remove_files()


def test_ivb_exports(invessel_build):

remove_files()

invessel_build.populate_surfaces()
Expand All @@ -131,8 +125,8 @@ def test_ivb_exports(invessel_build):
invessel_build.export_step()
invessel_build.export_cad_to_dagmc()

assert Path('chamber.step').exists()
assert Path('component.step').exists()
assert Path('dagmc.h5m').exists()
assert Path("chamber.step").exists()
assert Path("component.step").exists()
assert Path("dagmc.h5m").exists()

remove_files()
remove_files()

0 comments on commit bc90c8d

Please sign in to comment.