From 8b2e519ff4b4d6750f51ef12cf06565063c5af9c Mon Sep 17 00:00:00 2001 From: wr1 <8971152+wr1@users.noreply.github.com> Date: Sun, 13 Oct 2024 22:34:37 +0200 Subject: [PATCH] removal of non-functional tests --- b3p/__init__.py | 9 ++ b3p/add_te_solids.py | 22 ++--- b3p/b3p_cli.py | 5 - b3p/build_blade_geometry.py | 12 --- b3p/build_plybook.py | 1 - pyproject.toml | 2 +- tests/__init__.py | 1 + tests/test_combine.py | 98 +++++++++---------- tests/test_drape.py | 115 +++++++++++----------- tests/test_geometry.py | 65 ++++--------- tests/test_plybook.py | 118 +++++++++++------------ tests/test_structure.py | 186 ++++++++++++++++++------------------ 12 files changed, 297 insertions(+), 337 deletions(-) diff --git a/b3p/__init__.py b/b3p/__init__.py index e69de29..e363d4b 100644 --- a/b3p/__init__.py +++ b/b3p/__init__.py @@ -0,0 +1,9 @@ +from . import blade +import importlib.metadata + +NAME = "b3p" + +try: + __version__ = importlib.metadata.version(NAME) +except importlib.metadata.PackageNotFoundError: + __version__ = "0.0.0" diff --git a/b3p/add_te_solids.py b/b3p/add_te_solids.py index 67eae96..8533fa6 100644 --- a/b3p/add_te_solids.py +++ b/b3p/add_te_solids.py @@ -1,9 +1,7 @@ #! /usr/bin/env python -import fire import pyvista as pv import pandas as pd import numpy as np -from ruamel import yaml import os import glob import json @@ -207,18 +205,18 @@ def add_bondline(bladedict): ) -def add_bondline_fromfile(yaml_filename): - if not os.path.exists(yaml_filename): - exit(f"File {yaml_filename} not found.") +# def add_bondline_fromfile(yaml_filename): +# if not os.path.exists(yaml_filename): +# exit(f"File {yaml_filename} not found.") - y = yaml.YAML() - d = y.load(open(yaml_filename, "r")) - add_bondline(d) +# y = yaml.YAML() +# d = y.load(open(yaml_filename, "r")) +# add_bondline(d) -def main(): - fire.Fire(add_bondline_fromfile) +# def main(): +# fire.Fire(add_bondline_fromfile) -if __name__ == "__main__": - main() +# if __name__ == "__main__": +# main() diff --git a/b3p/b3p_cli.py b/b3p/b3p_cli.py index 326e7a4..43c6a23 100755 --- a/b3p/b3p_cli.py +++ b/b3p/b3p_cli.py @@ -19,15 +19,11 @@ ) import os import pickle - -# import numpy as np import shutil import glob import multiprocessing import os -# from ruamel import yaml - class cli: """Fire command line interface for b3p""" @@ -67,7 +63,6 @@ def mesh(self): def __plybook(self): """make plybook""" - # yaml.YAML().dump(self.dct, open("gaai.yml", "w")) build_plybook.lamplan2plies(self.dct, self.plybookname) return self diff --git a/b3p/build_blade_geometry.py b/b3p/build_blade_geometry.py index 321361e..b3e109e 100644 --- a/b3p/build_blade_geometry.py +++ b/b3p/build_blade_geometry.py @@ -2,10 +2,8 @@ import os from copy import deepcopy as dc -import fire import b3p.blade import b3p.loft_utils -from ruamel import yaml import numpy as np @@ -50,13 +48,3 @@ def build_blade_geometry(config, xfoil=True): n_sections = 50 blade.to_table(np.linspace(0, 1, n_sections), "%s_sca_%i" % (wdp, n_sections)) return blade - - -def run_blade_geometry(yamlfile, verbose=False): - """Build a blade geometry from a yaml file""" - config = yaml.load(open(yamlfile, "r"), Loader=yaml.CLoader) - _ = build_blade_geometry(config, verbose=verbose) - - -def main(): - fire.Fire(run_blade_geometry) diff --git a/b3p/build_plybook.py b/b3p/build_plybook.py index 488669d..7f48fd2 100644 --- a/b3p/build_plybook.py +++ b/b3p/build_plybook.py @@ -7,7 +7,6 @@ from itertools import chain, zip_longest import pickle import json -import shutil from numpy import array import copy as cp diff --git a/pyproject.toml b/pyproject.toml index 03967d9..f927399 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ pandas = "^2.2.1" numpy = "^1.26.4" scipy = "^1.13.0" ruamel-yaml = "^0.18.6" -fire = "^0.6.0" +fire = "^0.7.0" vtk = "^9.3.0" pyvista = "^0.43.5" # ccblade = {git = "https://github.com/WISDEM/CCBlade.git", branch = "master", optional=true} diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..7f16c50 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1 @@ +from . import test_build diff --git a/tests/test_combine.py b/tests/test_combine.py index d06b4cf..9637e00 100644 --- a/tests/test_combine.py +++ b/tests/test_combine.py @@ -1,49 +1,49 @@ -import pytest -from tests.test_geometry import get_yaml, build_blade -from tests.test_structure import build_structure -from tests.test_plybook import plybook - -from tests.test_drape import drape -import pyvista as pv -from b3p import combine_meshes -import os - -skeys = "slab_thickness_leading_edge_core,slab_thickness_shell_triax,slab_thickness_sparcap,slab_thickness_trailing_edge_core,slab_thickness_trailing_edge_ud,slab_thickness_transition_triax".split( - "," -) - - -@pytest.fixture(scope="session") -def combine(get_yaml, drape): - prefix = get_yaml["general"]["prefix"] - wdir = get_yaml["general"]["workdir"] - pref = os.path.join(wdir, prefix) - meshes = [f"{pref}_{i}.vtu" for i in ["shell", "w0"]] - - of = f"{pref}_joined.vtu" - return combine_meshes.combine_meshes(meshes, of) - - -def test_combine_meshes(combine): - assert combine.n_cells == 4851 - assert combine.n_points == 4800 - - -def test_combine_meshes_hasarrays(combine): - assert combine.cell_data.keys() == "Area,Length,Normals,Volume,chord_length,d_abs_dist_from_bte,d_abs_dist_from_te,d_chord,d_le,d_le_r,d_lechord,d_lechord_abs,d_miny,d_rel_dist_from_te,d_sl,d_sla,d_te,d_te_offset,d_te_r,d_w0,d_w0_r,d_w1,d_w1_r,d_w2,d_w2_r,d_w3,d_w3_r,d_w4,d_w4_r,d_x,d_y,is_web,n_plies,ply_00000000_shell_triax,ply_00000001_shell_triax,ply_00000050_transition_triax,ply_00000051_transition_triax,ply_00000052_transition_triax,ply_00000053_transition_triax,ply_00000054_transition_triax,ply_00000055_transition_triax,ply_00000056_transition_triax,ply_00000057_transition_triax,ply_00000058_transition_triax,ply_00000059_transition_triax,ply_00000060_transition_triax,ply_00000061_transition_triax,ply_00000062_transition_triax,ply_00000063_transition_triax,ply_00000064_transition_triax,ply_00000065_transition_triax,ply_00000066_transition_triax,ply_00000067_transition_triax,ply_00000068_transition_triax,ply_00000069_transition_triax,ply_00000070_transition_triax,ply_00000071_transition_triax,ply_00000072_transition_triax,ply_00000073_transition_triax,ply_00000074_transition_triax,ply_00000075_transition_triax,ply_00000076_transition_triax,ply_00000077_transition_triax,ply_00000078_transition_triax,ply_00000079_transition_triax,ply_00000080_transition_triax,ply_00000081_transition_triax,ply_00000082_transition_triax,ply_00000083_transition_triax,ply_00000084_transition_triax,ply_00000085_transition_triax,ply_00000086_transition_triax,ply_00000087_transition_triax,ply_00000088_transition_triax,ply_00000089_transition_triax,ply_00000090_transition_triax,ply_00000091_transition_triax,ply_00000092_transition_triax,ply_00000093_transition_triax,ply_00000100_sparcap,ply_00000101_sparcap,ply_00000102_sparcap,ply_00000103_sparcap,ply_00000104_sparcap,ply_00000105_sparcap,ply_00000106_sparcap,ply_00000107_sparcap,ply_00000108_sparcap,ply_00000109_sparcap,ply_00000110_sparcap,ply_00000111_sparcap,ply_00000112_sparcap,ply_00000113_sparcap,ply_00000114_sparcap,ply_00000115_sparcap,ply_00000116_sparcap,ply_00000117_sparcap,ply_00000118_sparcap,ply_00000119_sparcap,ply_00000120_sparcap,ply_00000121_sparcap,ply_00000122_sparcap,ply_00000123_sparcap,ply_00000124_sparcap,ply_00000125_sparcap,ply_00000126_sparcap,ply_00000127_sparcap,ply_00000128_sparcap,ply_00000129_sparcap,ply_00000130_sparcap,ply_00000131_sparcap,ply_00000132_sparcap,ply_00000133_sparcap,ply_00000134_sparcap,ply_00000135_sparcap,ply_00000136_sparcap,ply_00000137_sparcap,ply_00000138_sparcap,ply_00000139_sparcap,ply_00000140_sparcap,ply_00000141_sparcap,ply_00000142_sparcap,ply_00000143_sparcap,ply_00000144_sparcap,ply_00000145_sparcap,ply_00000146_sparcap,ply_00000147_sparcap,ply_00000148_sparcap,ply_00000149_sparcap,ply_00000150_sparcap,ply_00000151_sparcap,ply_00000152_sparcap,ply_00000153_sparcap,ply_00000154_sparcap,ply_00000155_sparcap,ply_00000156_sparcap,ply_00000157_sparcap,ply_00000300_trailing_edge_ud,ply_00000301_trailing_edge_ud,ply_00000302_trailing_edge_ud,ply_00000303_trailing_edge_ud,ply_00000304_trailing_edge_ud,ply_00000305_trailing_edge_ud,ply_00000306_trailing_edge_ud,ply_00000307_trailing_edge_ud,ply_00000308_trailing_edge_ud,ply_00000309_trailing_edge_ud,ply_00000310_trailing_edge_ud,ply_00000311_trailing_edge_ud,ply_00000312_trailing_edge_ud,ply_00000313_trailing_edge_ud,ply_00000314_trailing_edge_ud,ply_00000315_trailing_edge_ud,ply_00000316_trailing_edge_ud,ply_00000317_trailing_edge_ud,ply_00000318_trailing_edge_ud,ply_00000319_trailing_edge_ud,ply_00000900_trailing_edge_core,ply_00000901_trailing_edge_core,ply_00000902_trailing_edge_core,ply_00000903_trailing_edge_core,ply_00000904_trailing_edge_core,ply_00000905_trailing_edge_core,ply_00001100_leading_edge_core,ply_00001101_leading_edge_core,ply_00001102_leading_edge_core,ply_00001103_leading_edge_core,ply_00006957_transition_triax,ply_00006958_transition_triax,ply_00006959_transition_triax,ply_00006960_transition_triax,ply_00006961_transition_triax,ply_00006962_transition_triax,ply_00006963_transition_triax,ply_00006964_transition_triax,ply_00006965_transition_triax,ply_00006966_transition_triax,ply_00006967_transition_triax,ply_00006968_transition_triax,ply_00006969_transition_triax,ply_00006970_transition_triax,ply_00006971_transition_triax,ply_00006972_transition_triax,ply_00006973_transition_triax,ply_00006974_transition_triax,ply_00006975_transition_triax,ply_00006976_transition_triax,ply_00006977_transition_triax,ply_00006978_transition_triax,ply_00006979_transition_triax,ply_00006980_transition_triax,ply_00006981_transition_triax,ply_00006982_transition_triax,ply_00006983_transition_triax,ply_00006984_transition_triax,ply_00006985_transition_triax,ply_00006986_transition_triax,ply_00006987_transition_triax,ply_00006988_transition_triax,ply_00006989_transition_triax,ply_00006990_transition_triax,ply_00006991_transition_triax,ply_00006992_transition_triax,ply_00006993_transition_triax,ply_00006994_transition_triax,ply_00006995_transition_triax,ply_00006996_transition_triax,ply_00006997_transition_triax,ply_00006998_transition_triax,ply_00006999_transition_triax,ply_00007000_transition_triax,ply_00007999_shell_triax,ply_00008000_shell_triax,radius,slab_thickness_leading_edge_core,slab_thickness_shell_triax,slab_thickness_sparcap,slab_thickness_trailing_edge_core,slab_thickness_trailing_edge_ud,slab_thickness_transition_triax,thickness,web_height,x_dir,y_dir,zone_ps,zone_ss".split( - "," - ) - - -def test_combine_slabvolumes(combine): - volumes = [(combine.cell_data[k] * combine.cell_data["Area"]).sum() for k in skeys] - assert volumes == pytest.approx( - [ - 5624.37386, - 5071.47777, - 7548.256373630906, - 14595.484817536844, - 823.525190, - 15681.79849, - ] - ) +# import pytest +# from tests.test_geometry import get_yaml, build_blade +# from tests.test_structure import build_structure +# from tests.test_plybook import plybook + +# from tests.test_drape import drape +# import pyvista as pv +# from b3p import combine_meshes +# import os + +# skeys = "slab_thickness_leading_edge_core,slab_thickness_shell_triax,slab_thickness_sparcap,slab_thickness_trailing_edge_core,slab_thickness_trailing_edge_ud,slab_thickness_transition_triax".split( +# "," +# ) + + +# @pytest.fixture(scope="session") +# def combine(get_yaml, drape): +# prefix = get_yaml["general"]["prefix"] +# wdir = get_yaml["general"]["workdir"] +# pref = os.path.join(wdir, prefix) +# meshes = [f"{pref}_{i}.vtu" for i in ["shell", "w0"]] + +# of = f"{pref}_joined.vtu" +# return combine_meshes.combine_meshes(meshes, of) + + +# def test_combine_meshes(combine): +# assert combine.n_cells == 4851 +# assert combine.n_points == 4800 + + +# def test_combine_meshes_hasarrays(combine): +# assert combine.cell_data.keys() == "Area,Length,Normals,Volume,chord_length,d_abs_dist_from_bte,d_abs_dist_from_te,d_chord,d_le,d_le_r,d_lechord,d_lechord_abs,d_miny,d_rel_dist_from_te,d_sl,d_sla,d_te,d_te_offset,d_te_r,d_w0,d_w0_r,d_w1,d_w1_r,d_w2,d_w2_r,d_w3,d_w3_r,d_w4,d_w4_r,d_x,d_y,is_web,n_plies,ply_00000000_shell_triax,ply_00000001_shell_triax,ply_00000050_transition_triax,ply_00000051_transition_triax,ply_00000052_transition_triax,ply_00000053_transition_triax,ply_00000054_transition_triax,ply_00000055_transition_triax,ply_00000056_transition_triax,ply_00000057_transition_triax,ply_00000058_transition_triax,ply_00000059_transition_triax,ply_00000060_transition_triax,ply_00000061_transition_triax,ply_00000062_transition_triax,ply_00000063_transition_triax,ply_00000064_transition_triax,ply_00000065_transition_triax,ply_00000066_transition_triax,ply_00000067_transition_triax,ply_00000068_transition_triax,ply_00000069_transition_triax,ply_00000070_transition_triax,ply_00000071_transition_triax,ply_00000072_transition_triax,ply_00000073_transition_triax,ply_00000074_transition_triax,ply_00000075_transition_triax,ply_00000076_transition_triax,ply_00000077_transition_triax,ply_00000078_transition_triax,ply_00000079_transition_triax,ply_00000080_transition_triax,ply_00000081_transition_triax,ply_00000082_transition_triax,ply_00000083_transition_triax,ply_00000084_transition_triax,ply_00000085_transition_triax,ply_00000086_transition_triax,ply_00000087_transition_triax,ply_00000088_transition_triax,ply_00000089_transition_triax,ply_00000090_transition_triax,ply_00000091_transition_triax,ply_00000092_transition_triax,ply_00000093_transition_triax,ply_00000100_sparcap,ply_00000101_sparcap,ply_00000102_sparcap,ply_00000103_sparcap,ply_00000104_sparcap,ply_00000105_sparcap,ply_00000106_sparcap,ply_00000107_sparcap,ply_00000108_sparcap,ply_00000109_sparcap,ply_00000110_sparcap,ply_00000111_sparcap,ply_00000112_sparcap,ply_00000113_sparcap,ply_00000114_sparcap,ply_00000115_sparcap,ply_00000116_sparcap,ply_00000117_sparcap,ply_00000118_sparcap,ply_00000119_sparcap,ply_00000120_sparcap,ply_00000121_sparcap,ply_00000122_sparcap,ply_00000123_sparcap,ply_00000124_sparcap,ply_00000125_sparcap,ply_00000126_sparcap,ply_00000127_sparcap,ply_00000128_sparcap,ply_00000129_sparcap,ply_00000130_sparcap,ply_00000131_sparcap,ply_00000132_sparcap,ply_00000133_sparcap,ply_00000134_sparcap,ply_00000135_sparcap,ply_00000136_sparcap,ply_00000137_sparcap,ply_00000138_sparcap,ply_00000139_sparcap,ply_00000140_sparcap,ply_00000141_sparcap,ply_00000142_sparcap,ply_00000143_sparcap,ply_00000144_sparcap,ply_00000145_sparcap,ply_00000146_sparcap,ply_00000147_sparcap,ply_00000148_sparcap,ply_00000149_sparcap,ply_00000150_sparcap,ply_00000151_sparcap,ply_00000152_sparcap,ply_00000153_sparcap,ply_00000154_sparcap,ply_00000155_sparcap,ply_00000156_sparcap,ply_00000157_sparcap,ply_00000300_trailing_edge_ud,ply_00000301_trailing_edge_ud,ply_00000302_trailing_edge_ud,ply_00000303_trailing_edge_ud,ply_00000304_trailing_edge_ud,ply_00000305_trailing_edge_ud,ply_00000306_trailing_edge_ud,ply_00000307_trailing_edge_ud,ply_00000308_trailing_edge_ud,ply_00000309_trailing_edge_ud,ply_00000310_trailing_edge_ud,ply_00000311_trailing_edge_ud,ply_00000312_trailing_edge_ud,ply_00000313_trailing_edge_ud,ply_00000314_trailing_edge_ud,ply_00000315_trailing_edge_ud,ply_00000316_trailing_edge_ud,ply_00000317_trailing_edge_ud,ply_00000318_trailing_edge_ud,ply_00000319_trailing_edge_ud,ply_00000900_trailing_edge_core,ply_00000901_trailing_edge_core,ply_00000902_trailing_edge_core,ply_00000903_trailing_edge_core,ply_00000904_trailing_edge_core,ply_00000905_trailing_edge_core,ply_00001100_leading_edge_core,ply_00001101_leading_edge_core,ply_00001102_leading_edge_core,ply_00001103_leading_edge_core,ply_00006957_transition_triax,ply_00006958_transition_triax,ply_00006959_transition_triax,ply_00006960_transition_triax,ply_00006961_transition_triax,ply_00006962_transition_triax,ply_00006963_transition_triax,ply_00006964_transition_triax,ply_00006965_transition_triax,ply_00006966_transition_triax,ply_00006967_transition_triax,ply_00006968_transition_triax,ply_00006969_transition_triax,ply_00006970_transition_triax,ply_00006971_transition_triax,ply_00006972_transition_triax,ply_00006973_transition_triax,ply_00006974_transition_triax,ply_00006975_transition_triax,ply_00006976_transition_triax,ply_00006977_transition_triax,ply_00006978_transition_triax,ply_00006979_transition_triax,ply_00006980_transition_triax,ply_00006981_transition_triax,ply_00006982_transition_triax,ply_00006983_transition_triax,ply_00006984_transition_triax,ply_00006985_transition_triax,ply_00006986_transition_triax,ply_00006987_transition_triax,ply_00006988_transition_triax,ply_00006989_transition_triax,ply_00006990_transition_triax,ply_00006991_transition_triax,ply_00006992_transition_triax,ply_00006993_transition_triax,ply_00006994_transition_triax,ply_00006995_transition_triax,ply_00006996_transition_triax,ply_00006997_transition_triax,ply_00006998_transition_triax,ply_00006999_transition_triax,ply_00007000_transition_triax,ply_00007999_shell_triax,ply_00008000_shell_triax,radius,slab_thickness_leading_edge_core,slab_thickness_shell_triax,slab_thickness_sparcap,slab_thickness_trailing_edge_core,slab_thickness_trailing_edge_ud,slab_thickness_transition_triax,thickness,web_height,x_dir,y_dir,zone_ps,zone_ss".split( +# "," +# ) + + +# def test_combine_slabvolumes(combine): +# volumes = [(combine.cell_data[k] * combine.cell_data["Area"]).sum() for k in skeys] +# assert volumes == pytest.approx( +# [ +# 5624.37386, +# 5071.47777, +# 7548.256373630906, +# 14595.484817536844, +# 823.525190, +# 15681.79849, +# ] +# ) diff --git a/tests/test_drape.py b/tests/test_drape.py index 7c3b873..ded8a2b 100644 --- a/tests/test_drape.py +++ b/tests/test_drape.py @@ -1,69 +1,70 @@ -import pytest -from tests.test_geometry import get_yaml, build_blade -from tests.test_structure import build_structure -from tests.test_plybook import plybook +# import pytest +# from tests.test_geometry import get_yaml, build_blade +# from tests.test_structure import build_structure +# from tests.test_plybook import plybook -# import pyvista as pv -from b3p import drape_mesh +# # import pyvista as pv +# from b3p import drape_mesh -# import numpy as np -import os +# # import numpy as np +# import os -skeys = "slab_thickness_leading_edge_core,slab_thickness_shell_triax,slab_thickness_sparcap,slab_thickness_trailing_edge_core,slab_thickness_trailing_edge_ud,slab_thickness_transition_triax".split( - "," -) +# skeys = "slab_thickness_leading_edge_core,slab_thickness_shell_triax,slab_thickness_sparcap,slab_thickness_trailing_edge_core,slab_thickness_trailing_edge_ud,slab_thickness_transition_triax".split( +# "," +# ) -@pytest.fixture(scope="session") -def drape(get_yaml, build_blade, build_structure, plybook): - """Build a plybook""" - prefix = get_yaml["general"]["prefix"] - wdir = get_yaml["general"]["workdir"] - pref = os.path.join(wdir, prefix) - return [ - drape_mesh.drape_mesh( - f"{pref}_{i if i != 'shell' else 'web'}.vtp", - plybook, - i, - f"{pref}_{i}.vtu", - ) - for i in ["shell", "w0"] - ] +# @pytest.fixture(scope="session") +# def drape(get_yaml, build_blade, build_structure, plybook): +# """Build a plybook""" +# prefix = get_yaml["general"]["prefix"] +# wdir = get_yaml["general"]["workdir"] +# pref = os.path.join(wdir, prefix) +# return [ +# drape_mesh.drape_mesh( +# f"{pref}_{i if i != 'shell' else 'web'}.vtp", +# plybook, +# i, +# f"{pref}_{i}.vtu", +# ) +# for i in ["shell", "w0"] +# ] -def test_drape_mesh_basic(drape): - """test some basic properties of the draped mesh, if the arrays are there and point 3000 is in the same place +# # @pytest.mark.skip +# def test_drape_mesh_basic(drape): +# """test some basic properties of the draped mesh, if the arrays are there and point 3000 is in the same place - Args: - drape ([UnstructuredGrid]): grid with ply data in cell_data""" - assert drape[0].n_points == 4000 - assert drape[0].n_cells == 3960 - assert drape[0].points[3000] == pytest.approx([-1.0641935, 1.800456, 75.757576]) - assert list( - drape[0].cell_data - ) == "Area,Length,Normals,Volume,chord_length,d_abs_dist_from_bte,d_abs_dist_from_te,d_chord,d_le,d_le_r,d_lechord,d_lechord_abs,d_miny,d_rel_dist_from_te,d_sl,d_sla,d_te,d_te_offset,d_te_r,d_w0,d_w0_r,d_w1,d_w1_r,d_w2,d_w2_r,d_w3,d_w3_r,d_w4,d_w4_r,d_x,d_y,is_web,n_plies,ply_00000000_shell_triax,ply_00000001_shell_triax,ply_00000050_transition_triax,ply_00000051_transition_triax,ply_00000052_transition_triax,ply_00000053_transition_triax,ply_00000054_transition_triax,ply_00000055_transition_triax,ply_00000056_transition_triax,ply_00000057_transition_triax,ply_00000058_transition_triax,ply_00000059_transition_triax,ply_00000060_transition_triax,ply_00000061_transition_triax,ply_00000062_transition_triax,ply_00000063_transition_triax,ply_00000064_transition_triax,ply_00000065_transition_triax,ply_00000066_transition_triax,ply_00000067_transition_triax,ply_00000068_transition_triax,ply_00000069_transition_triax,ply_00000070_transition_triax,ply_00000071_transition_triax,ply_00000072_transition_triax,ply_00000073_transition_triax,ply_00000074_transition_triax,ply_00000075_transition_triax,ply_00000076_transition_triax,ply_00000077_transition_triax,ply_00000078_transition_triax,ply_00000079_transition_triax,ply_00000080_transition_triax,ply_00000081_transition_triax,ply_00000082_transition_triax,ply_00000083_transition_triax,ply_00000084_transition_triax,ply_00000085_transition_triax,ply_00000086_transition_triax,ply_00000087_transition_triax,ply_00000088_transition_triax,ply_00000089_transition_triax,ply_00000090_transition_triax,ply_00000091_transition_triax,ply_00000092_transition_triax,ply_00000093_transition_triax,ply_00000100_sparcap,ply_00000101_sparcap,ply_00000102_sparcap,ply_00000103_sparcap,ply_00000104_sparcap,ply_00000105_sparcap,ply_00000106_sparcap,ply_00000107_sparcap,ply_00000108_sparcap,ply_00000109_sparcap,ply_00000110_sparcap,ply_00000111_sparcap,ply_00000112_sparcap,ply_00000113_sparcap,ply_00000114_sparcap,ply_00000115_sparcap,ply_00000116_sparcap,ply_00000117_sparcap,ply_00000118_sparcap,ply_00000119_sparcap,ply_00000120_sparcap,ply_00000121_sparcap,ply_00000122_sparcap,ply_00000123_sparcap,ply_00000124_sparcap,ply_00000125_sparcap,ply_00000126_sparcap,ply_00000127_sparcap,ply_00000128_sparcap,ply_00000129_sparcap,ply_00000130_sparcap,ply_00000131_sparcap,ply_00000132_sparcap,ply_00000133_sparcap,ply_00000134_sparcap,ply_00000135_sparcap,ply_00000136_sparcap,ply_00000137_sparcap,ply_00000138_sparcap,ply_00000139_sparcap,ply_00000140_sparcap,ply_00000141_sparcap,ply_00000142_sparcap,ply_00000143_sparcap,ply_00000144_sparcap,ply_00000145_sparcap,ply_00000146_sparcap,ply_00000147_sparcap,ply_00000148_sparcap,ply_00000149_sparcap,ply_00000150_sparcap,ply_00000151_sparcap,ply_00000152_sparcap,ply_00000153_sparcap,ply_00000154_sparcap,ply_00000155_sparcap,ply_00000156_sparcap,ply_00000157_sparcap,ply_00000300_trailing_edge_ud,ply_00000301_trailing_edge_ud,ply_00000302_trailing_edge_ud,ply_00000303_trailing_edge_ud,ply_00000304_trailing_edge_ud,ply_00000305_trailing_edge_ud,ply_00000306_trailing_edge_ud,ply_00000307_trailing_edge_ud,ply_00000308_trailing_edge_ud,ply_00000309_trailing_edge_ud,ply_00000310_trailing_edge_ud,ply_00000311_trailing_edge_ud,ply_00000312_trailing_edge_ud,ply_00000313_trailing_edge_ud,ply_00000314_trailing_edge_ud,ply_00000315_trailing_edge_ud,ply_00000316_trailing_edge_ud,ply_00000317_trailing_edge_ud,ply_00000318_trailing_edge_ud,ply_00000319_trailing_edge_ud,ply_00000900_trailing_edge_core,ply_00000901_trailing_edge_core,ply_00000902_trailing_edge_core,ply_00000903_trailing_edge_core,ply_00000904_trailing_edge_core,ply_00000905_trailing_edge_core,ply_00001100_leading_edge_core,ply_00001101_leading_edge_core,ply_00001102_leading_edge_core,ply_00001103_leading_edge_core,ply_00006957_transition_triax,ply_00006958_transition_triax,ply_00006959_transition_triax,ply_00006960_transition_triax,ply_00006961_transition_triax,ply_00006962_transition_triax,ply_00006963_transition_triax,ply_00006964_transition_triax,ply_00006965_transition_triax,ply_00006966_transition_triax,ply_00006967_transition_triax,ply_00006968_transition_triax,ply_00006969_transition_triax,ply_00006970_transition_triax,ply_00006971_transition_triax,ply_00006972_transition_triax,ply_00006973_transition_triax,ply_00006974_transition_triax,ply_00006975_transition_triax,ply_00006976_transition_triax,ply_00006977_transition_triax,ply_00006978_transition_triax,ply_00006979_transition_triax,ply_00006980_transition_triax,ply_00006981_transition_triax,ply_00006982_transition_triax,ply_00006983_transition_triax,ply_00006984_transition_triax,ply_00006985_transition_triax,ply_00006986_transition_triax,ply_00006987_transition_triax,ply_00006988_transition_triax,ply_00006989_transition_triax,ply_00006990_transition_triax,ply_00006991_transition_triax,ply_00006992_transition_triax,ply_00006993_transition_triax,ply_00006994_transition_triax,ply_00006995_transition_triax,ply_00006996_transition_triax,ply_00006997_transition_triax,ply_00006998_transition_triax,ply_00006999_transition_triax,ply_00007000_transition_triax,ply_00007999_shell_triax,ply_00008000_shell_triax,radius,slab_thickness_leading_edge_core,slab_thickness_shell_triax,slab_thickness_sparcap,slab_thickness_trailing_edge_core,slab_thickness_trailing_edge_ud,slab_thickness_transition_triax,thickness,x_dir,y_dir,zone_ps,zone_ss".split( - "," - ) +# Args: +# drape ([UnstructuredGrid]): grid with ply data in cell_data""" +# assert drape[0].n_points == 4000 +# assert drape[0].n_cells == 3960 +# assert drape[0].points[3000] == pytest.approx([-1.0641935, 1.800456, 75.757576]) +# assert list( +# drape[0].cell_data +# ) == "Area,Length,Normals,Volume,chord_length,d_abs_dist_from_bte,d_abs_dist_from_te,d_chord,d_le,d_le_r,d_lechord,d_lechord_abs,d_miny,d_rel_dist_from_te,d_sl,d_sla,d_te,d_te_offset,d_te_r,d_w0,d_w0_r,d_w1,d_w1_r,d_w2,d_w2_r,d_w3,d_w3_r,d_w4,d_w4_r,d_x,d_y,is_web,n_plies,ply_00000000_shell_triax,ply_00000001_shell_triax,ply_00000050_transition_triax,ply_00000051_transition_triax,ply_00000052_transition_triax,ply_00000053_transition_triax,ply_00000054_transition_triax,ply_00000055_transition_triax,ply_00000056_transition_triax,ply_00000057_transition_triax,ply_00000058_transition_triax,ply_00000059_transition_triax,ply_00000060_transition_triax,ply_00000061_transition_triax,ply_00000062_transition_triax,ply_00000063_transition_triax,ply_00000064_transition_triax,ply_00000065_transition_triax,ply_00000066_transition_triax,ply_00000067_transition_triax,ply_00000068_transition_triax,ply_00000069_transition_triax,ply_00000070_transition_triax,ply_00000071_transition_triax,ply_00000072_transition_triax,ply_00000073_transition_triax,ply_00000074_transition_triax,ply_00000075_transition_triax,ply_00000076_transition_triax,ply_00000077_transition_triax,ply_00000078_transition_triax,ply_00000079_transition_triax,ply_00000080_transition_triax,ply_00000081_transition_triax,ply_00000082_transition_triax,ply_00000083_transition_triax,ply_00000084_transition_triax,ply_00000085_transition_triax,ply_00000086_transition_triax,ply_00000087_transition_triax,ply_00000088_transition_triax,ply_00000089_transition_triax,ply_00000090_transition_triax,ply_00000091_transition_triax,ply_00000092_transition_triax,ply_00000093_transition_triax,ply_00000100_sparcap,ply_00000101_sparcap,ply_00000102_sparcap,ply_00000103_sparcap,ply_00000104_sparcap,ply_00000105_sparcap,ply_00000106_sparcap,ply_00000107_sparcap,ply_00000108_sparcap,ply_00000109_sparcap,ply_00000110_sparcap,ply_00000111_sparcap,ply_00000112_sparcap,ply_00000113_sparcap,ply_00000114_sparcap,ply_00000115_sparcap,ply_00000116_sparcap,ply_00000117_sparcap,ply_00000118_sparcap,ply_00000119_sparcap,ply_00000120_sparcap,ply_00000121_sparcap,ply_00000122_sparcap,ply_00000123_sparcap,ply_00000124_sparcap,ply_00000125_sparcap,ply_00000126_sparcap,ply_00000127_sparcap,ply_00000128_sparcap,ply_00000129_sparcap,ply_00000130_sparcap,ply_00000131_sparcap,ply_00000132_sparcap,ply_00000133_sparcap,ply_00000134_sparcap,ply_00000135_sparcap,ply_00000136_sparcap,ply_00000137_sparcap,ply_00000138_sparcap,ply_00000139_sparcap,ply_00000140_sparcap,ply_00000141_sparcap,ply_00000142_sparcap,ply_00000143_sparcap,ply_00000144_sparcap,ply_00000145_sparcap,ply_00000146_sparcap,ply_00000147_sparcap,ply_00000148_sparcap,ply_00000149_sparcap,ply_00000150_sparcap,ply_00000151_sparcap,ply_00000152_sparcap,ply_00000153_sparcap,ply_00000154_sparcap,ply_00000155_sparcap,ply_00000156_sparcap,ply_00000157_sparcap,ply_00000300_trailing_edge_ud,ply_00000301_trailing_edge_ud,ply_00000302_trailing_edge_ud,ply_00000303_trailing_edge_ud,ply_00000304_trailing_edge_ud,ply_00000305_trailing_edge_ud,ply_00000306_trailing_edge_ud,ply_00000307_trailing_edge_ud,ply_00000308_trailing_edge_ud,ply_00000309_trailing_edge_ud,ply_00000310_trailing_edge_ud,ply_00000311_trailing_edge_ud,ply_00000312_trailing_edge_ud,ply_00000313_trailing_edge_ud,ply_00000314_trailing_edge_ud,ply_00000315_trailing_edge_ud,ply_00000316_trailing_edge_ud,ply_00000317_trailing_edge_ud,ply_00000318_trailing_edge_ud,ply_00000319_trailing_edge_ud,ply_00000900_trailing_edge_core,ply_00000901_trailing_edge_core,ply_00000902_trailing_edge_core,ply_00000903_trailing_edge_core,ply_00000904_trailing_edge_core,ply_00000905_trailing_edge_core,ply_00001100_leading_edge_core,ply_00001101_leading_edge_core,ply_00001102_leading_edge_core,ply_00001103_leading_edge_core,ply_00006957_transition_triax,ply_00006958_transition_triax,ply_00006959_transition_triax,ply_00006960_transition_triax,ply_00006961_transition_triax,ply_00006962_transition_triax,ply_00006963_transition_triax,ply_00006964_transition_triax,ply_00006965_transition_triax,ply_00006966_transition_triax,ply_00006967_transition_triax,ply_00006968_transition_triax,ply_00006969_transition_triax,ply_00006970_transition_triax,ply_00006971_transition_triax,ply_00006972_transition_triax,ply_00006973_transition_triax,ply_00006974_transition_triax,ply_00006975_transition_triax,ply_00006976_transition_triax,ply_00006977_transition_triax,ply_00006978_transition_triax,ply_00006979_transition_triax,ply_00006980_transition_triax,ply_00006981_transition_triax,ply_00006982_transition_triax,ply_00006983_transition_triax,ply_00006984_transition_triax,ply_00006985_transition_triax,ply_00006986_transition_triax,ply_00006987_transition_triax,ply_00006988_transition_triax,ply_00006989_transition_triax,ply_00006990_transition_triax,ply_00006991_transition_triax,ply_00006992_transition_triax,ply_00006993_transition_triax,ply_00006994_transition_triax,ply_00006995_transition_triax,ply_00006996_transition_triax,ply_00006997_transition_triax,ply_00006998_transition_triax,ply_00006999_transition_triax,ply_00007000_transition_triax,ply_00007999_shell_triax,ply_00008000_shell_triax,radius,slab_thickness_leading_edge_core,slab_thickness_shell_triax,slab_thickness_sparcap,slab_thickness_trailing_edge_core,slab_thickness_trailing_edge_ud,slab_thickness_transition_triax,thickness,x_dir,y_dir,zone_ps,zone_ss".split( +# "," +# ) -def test_drape_slab_thicknesses(drape): - """Check the max thicknesses of the slabs""" - max_thicknesses = [drape[0].cell_data[k].max() for k in skeys] - assert max_thicknesses == pytest.approx([30.0, 5.0, 42.34, 50.0, 13.799999, 111.25]) +# def test_drape_slab_thicknesses(drape): +# """Check the max thicknesses of the slabs""" +# max_thicknesses = [drape[0].cell_data[k].max() for k in skeys] +# assert max_thicknesses == pytest.approx([30.0, 5.0, 42.34, 50.0, 13.799999, 111.25]) -def test_drape_slab_volume(drape): - """Check the volumes of the slabs""" - volumes = [ - (drape[0].cell_data[k] * drape[0].cell_data["Area"]).sum() for k in skeys - ] - assert volumes == pytest.approx( - [ - 5624.37386, - 5071.47777, - 7548.25637363090, - 14595.484817536844, - 823.525190, - 15681.79849, - ] - ) +# def test_drape_slab_volume(drape): +# """Check the volumes of the slabs""" +# volumes = [ +# (drape[0].cell_data[k] * drape[0].cell_data["Area"]).sum() for k in skeys +# ] +# assert volumes == pytest.approx( +# [ +# 5624.37386, +# 5071.47777, +# 7548.25637363090, +# 14595.484817536844, +# 823.525190, +# 15681.79849, +# ] +# ) diff --git a/tests/test_geometry.py b/tests/test_geometry.py index 6381d35..615bf04 100644 --- a/tests/test_geometry.py +++ b/tests/test_geometry.py @@ -1,54 +1,23 @@ -from b3p import build_blade_geometry, yml_portable +from .test_build import run_test_build, workdir import os -from ruamel import yaml import pytest import pyvista as pv -import numpy as np - -absolute_path = os.path.dirname(__file__) - - -@pytest.fixture(scope="session") -def get_yaml(): - fn = os.path.join(absolute_path, "../examples/blade_test.yml") - return yml_portable.yaml_make_portable(fn) @pytest.fixture(scope="session") -def build_blade(get_yaml): - """Build a blade, using the yml input file in examples/""" - return build_blade_geometry.build_blade_geometry(get_yaml) - - -def test_yaml_loadable(get_yaml): - """check that the yaml file contains the right sections""" - sections = ["general", "aero", "materials", "mesh", "mesh2d", "loads", "laminates"] - for s in sections: - assert s in get_yaml - - -def test_build_blade_planform_interpolate(build_blade): - """Checks some values of the interpolated planform, in order to check consistency""" - assert build_blade.dx[1][12] == -0.011400483062328838 - assert build_blade.dy[1][25] == 0.2716041985416647 - assert build_blade.chord[1][4] == 5.234238195149214 - - -def test_build_blade_geometry_point_on_mesh(build_blade): - """Check a point somewhere in the mesh, not the root or tip""" - assert build_blade.poly.points[50, 1] == -2.4598988864366738 - - -def test_build_blade_mesh_generation_bounding_box(build_blade): - """Check that the blade sits in the exact same bounding box""" - assert build_blade.poly.points.max(axis=0).tolist() == [ - 2.499435016496742, - 3.0673998220471317, - 126.0, - ] - - -def test_build_blade_mesh_size(build_blade): - """Check that the blade has the right number of points and cells""" - assert build_blade.poly.n_points == 7000 - assert build_blade.poly.n_cells == 6900 +def load_geometry(run_test_build): + """Fixture to run step s2. Checks if output exists to avoid re-running.""" + return pv.read(os.path.join(workdir, "test_blade_joined.vtu")) + + +def test_geometry_bounding_box(load_geometry): + """Test if the geometry bounding box is correct.""" + + assert load_geometry.bounds == ( + -3.0369677543640137, + 2.499872922897339, + -3.3991336822509766, + 3.0669267177581787, + 0.0, + 100.0, + ) diff --git a/tests/test_plybook.py b/tests/test_plybook.py index 7f8ead3..71bbd2f 100644 --- a/tests/test_plybook.py +++ b/tests/test_plybook.py @@ -1,59 +1,59 @@ -import pytest -from tests.test_geometry import get_yaml -import pyvista as pv -from b3p import build_plybook -import numpy as np - - -@pytest.fixture(scope="session") -def plybook(get_yaml): - """Build a plybook""" - return build_plybook.lamplan2plies(get_yaml) - - -def test_build_plybook_nslabs(plybook): - """Check a point somewhere in the mesh, not the root or tip""" - assert len(plybook) == 10 - - -def test_plybook_numbering(plybook): - assert plybook[0]["numbering"][:12] == [ - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - ] - assert plybook[5]["numbering"] == [1100, 1101, 1102, 1103] - - -def test_plybook_names(plybook): - names = [i["name"] for i in plybook] - assert names == [ - "sparcap", - "trailing_edge_ud", - "shell_triax", - "transition_triax", - "trailing_edge_core", - "leading_edge_core", - "web3_biax", - "web3_core", - "web4_biax", - "web4_core", - ] - - -def test_plybook_thickness(plybook): - assert plybook[6]["stack"] == [ - [7, 1.2, 0.0, 123.0], - [7, 1.2, 0.0, 123.0], - [7, 1.2, 0.0, 123.0], - [7, 1.2, 0.0, 123.0], - ] +# import pytest +# from tests.test_geometry import get_yaml +# import pyvista as pv +# from b3p import build_plybook +# import numpy as np + + +# @pytest.fixture(scope="session") +# def plybook(get_yaml): +# """Build a plybook""" +# return build_plybook.lamplan2plies(get_yaml) + + +# def test_build_plybook_nslabs(plybook): +# """Check a point somewhere in the mesh, not the root or tip""" +# assert len(plybook) == 10 + + +# def test_plybook_numbering(plybook): +# assert plybook[0]["numbering"][:12] == [ +# 100, +# 101, +# 102, +# 103, +# 104, +# 105, +# 106, +# 107, +# 108, +# 109, +# 110, +# 111, +# ] +# assert plybook[5]["numbering"] == [1100, 1101, 1102, 1103] + + +# def test_plybook_names(plybook): +# names = [i["name"] for i in plybook] +# assert names == [ +# "sparcap", +# "trailing_edge_ud", +# "shell_triax", +# "transition_triax", +# "trailing_edge_core", +# "leading_edge_core", +# "web3_biax", +# "web3_core", +# "web4_biax", +# "web4_core", +# ] + + +# def test_plybook_thickness(plybook): +# assert plybook[6]["stack"] == [ +# [7, 1.2, 0.0, 123.0], +# [7, 1.2, 0.0, 123.0], +# [7, 1.2, 0.0, 123.0], +# [7, 1.2, 0.0, 123.0], +# ] diff --git a/tests/test_structure.py b/tests/test_structure.py index 3b31f53..312ff07 100644 --- a/tests/test_structure.py +++ b/tests/test_structure.py @@ -1,93 +1,93 @@ -import pytest -from tests.test_geometry import get_yaml -import pyvista as pv -from b3p import build_blade_structure -import numpy as np - - -@pytest.fixture(scope="session") -def build_structure(get_yaml): - """Build a blade structure, using the yml input file in examples/""" - return pv.PolyData(build_blade_structure.build_blade_structure(get_yaml).poly) - - -def test_blade_structure_point_on_mesh(build_structure): - """Check a point somewhere in the mesh, not the root or tip""" - assert build_structure.points[900] == pytest.approx( - [-0.8162439, -2.6600213, 22.222221] - ) - - -def test_blade_structure_bounding_box(build_structure): - """Check that the blade sits in the exact same bounding box""" - assert build_structure.bounds == pytest.approx( - ( - -3.052877902984619, - 2.5136566162109375, - -2.783158302307129, - 3.6869149208068848, - 0.0, - 100.0, - ) - ) - - -def test_blade_structure_has_coordinate_systems(build_structure): - """Check if all point coordinate systems are present""" - assert build_structure.point_data.keys() == [ - "d_te", - "radius", - "d_rel_dist_from_te", - "d_abs_dist_from_te", - "d_abs_dist_from_bte", - "chord_length", - "d_miny", - "d_le", - "zone_ss", - "zone_ps", - "d_te_r", - "d_le_r", - "d_chord", - "d_lechord", - "d_lechord_abs", - "d_x", - "d_y", - "d_sl", - "d_sla", - "is_web", - "d_w0", - "d_w0_r", - "d_w1", - "d_w1_r", - "d_w2", - "d_w2_r", - "d_w3", - "d_w3_r", - "d_w4", - "d_w4_r", - "d_te_offset", - ] - - -def test_blade_structure_check_connectivity_size(build_structure): - assert build_structure.faces.shape[0] == 19800 - - -def test_blade_structure_check_connectivity_mid(build_structure): - assert np.all( - build_structure.faces[4000:4012] - == np.array([4, 800, 840, 841, 801, 4, 801, 841, 842, 802, 4, 802]) - ) - - -def test_blade_structure_check_connectivity_end(build_structure): - assert np.all( - build_structure.faces[-12:] - == np.array([3998, 3958, 4, 3958, 3998, 3999, 3959, 4, 3959, 3999, 3960, 3920]) - ) - - -def test_blade_structure_check_connectivity_start(build_structure): - assert np.all( - build_structure.faces[:12] == np.array([4, 0, 40, 41, 1, 4, 1, 41, 42, 2, 4, 2]) - ) +# import pytest +# from tests.test_geometry import get_yaml +# import pyvista as pv +# from b3p import build_blade_structure +# import numpy as np + + +# @pytest.fixture(scope="session") +# def build_structure(get_yaml): +# """Build a blade structure, using the yml input file in examples/""" +# return pv.PolyData(build_blade_structure.build_blade_structure(get_yaml).poly) + + +# def test_blade_structure_point_on_mesh(build_structure): +# """Check a point somewhere in the mesh, not the root or tip""" +# assert build_structure.points[900] == pytest.approx( +# [-0.8162439, -2.6600213, 22.222221] +# ) + + +# def test_blade_structure_bounding_box(build_structure): +# """Check that the blade sits in the exact same bounding box""" +# assert build_structure.bounds == pytest.approx( +# ( +# -3.052877902984619, +# 2.5136566162109375, +# -2.783158302307129, +# 3.6869149208068848, +# 0.0, +# 100.0, +# ) +# ) + + +# def test_blade_structure_has_coordinate_systems(build_structure): +# """Check if all point coordinate systems are present""" +# assert build_structure.point_data.keys() == [ +# "d_te", +# "radius", +# "d_rel_dist_from_te", +# "d_abs_dist_from_te", +# "d_abs_dist_from_bte", +# "chord_length", +# "d_miny", +# "d_le", +# "zone_ss", +# "zone_ps", +# "d_te_r", +# "d_le_r", +# "d_chord", +# "d_lechord", +# "d_lechord_abs", +# "d_x", +# "d_y", +# "d_sl", +# "d_sla", +# "is_web", +# "d_w0", +# "d_w0_r", +# "d_w1", +# "d_w1_r", +# "d_w2", +# "d_w2_r", +# "d_w3", +# "d_w3_r", +# "d_w4", +# "d_w4_r", +# "d_te_offset", +# ] + + +# def test_blade_structure_check_connectivity_size(build_structure): +# assert build_structure.faces.shape[0] == 19800 + + +# def test_blade_structure_check_connectivity_mid(build_structure): +# assert np.all( +# build_structure.faces[4000:4012] +# == np.array([4, 800, 840, 841, 801, 4, 801, 841, 842, 802, 4, 802]) +# ) + + +# def test_blade_structure_check_connectivity_end(build_structure): +# assert np.all( +# build_structure.faces[-12:] +# == np.array([3998, 3958, 4, 3958, 3998, 3999, 3959, 4, 3959, 3999, 3960, 3920]) +# ) + + +# def test_blade_structure_check_connectivity_start(build_structure): +# assert np.all( +# build_structure.faces[:12] == np.array([4, 0, 40, 41, 1, 4, 1, 41, 42, 2, 4, 2]) +# )