Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/ansys_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


blade=pynumad.Blade()
yamlName='myBlade_Modified'
yamlName='BAR0_5MW'
blade.read_yaml('example_data/'+yamlName+'.yaml')

log=setup_logging(yamlName+'_ansys')
Expand Down
2 changes: 1 addition & 1 deletion examples/cubit_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_cs_params():

blade=pynumad.Blade()

yamlName='myBlade_Modified'
yamlName='BAR0_5MW'
blade.read_yaml('example_data/'+yamlName+'.yaml')


Expand Down
2 changes: 1 addition & 1 deletion examples/cubit_solid.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_cs_params():

blade=pynumad.Blade()

yamlName='myBlade_Modified'
yamlName='BAR0_5MW'
blade.read_yaml('example_data/'+yamlName+'.yaml')


Expand Down
2 changes: 1 addition & 1 deletion examples/develop_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pynumad.graphics.graphics import plot_blade_geometry_pv, plot_segment_mass

yaml_file = os.path.join(
os.path.dirname(__file__), "example_data", "IEA-22-280-RWT.yaml"
os.path.dirname(__file__), "example_data", "IEA-15-240-RWT.yaml"
)

# Choose a segmentation case: 'one-piece', 'two-piece', 'chord-wise', 'three-piece'
Expand Down
File renamed without changes.
1,131 changes: 1,131 additions & 0 deletions examples/example_data/IEA-15-240-RWT_windIO2.yaml

Large diffs are not rendered by default.

654 changes: 0 additions & 654 deletions examples/example_data/myBlade_Modified.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/plot_blade.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pynumad.mesh_gen.mesh_gen import get_shell_mesh
from pynumad.graphics.graphics import plot_blade_geometry_pv, plot_shell_mesh_pv

yaml_file = os.path.join(os.path.dirname(__file__), "example_data", "blade.yaml")
yaml_file = os.path.join(os.path.dirname(__file__), "example_data", "BAR0_5MW.yaml")

blade = pynu.Blade()
blade.read_yaml(yaml_file)
Expand Down
2 changes: 1 addition & 1 deletion examples/readyaml_buildmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pynumad.mesh_gen.mesh_gen import get_shell_mesh

blade = pynu.Blade()
file_name = join("example_data","blade.yaml")
file_name = join("example_data","BAR0_5MW.yaml")
blade.read_yaml(file_name)

elementSize = 0.2
Expand Down
2 changes: 1 addition & 1 deletion examples/write_abaqus_shell_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pynumad.analysis.abaqus.write import *

## Define inputs
bladeYaml = join("example_data","blade.yaml")
bladeYaml = join("example_data","BAR0_5MW.yaml")
meshYaml = "BAR0.yaml"
abqFileName = "BAR0.inp"
abqScriptName = "runModalAnalysis.py"
Expand Down
2 changes: 1 addition & 1 deletion examples/write_abaqus_solid_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

## Read blade data from yaml file
blade = pynu.Blade()
file_name = join("example_data","blade.yaml")
file_name = join("example_data","BAR0_5MW.yaml")
blade.read_yaml(file_name)

## Set the airfoil point resolution
Expand Down
6 changes: 3 additions & 3 deletions src/pynumad/graphics/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ def plot_segment_mass(bom, segments):
seg_num = str(i + 1)
if not bom.hp.empty:
mask = bom.hp["segment_id"].str.endswith(seg_num)
hp_mass[i] = bom.hp.loc[mask, "weight"].sum() * g_to_kg
hp_mass[i] = bom.hp.loc[mask, "dryweight"].sum()
if not bom.lp.empty:
mask = bom.lp["segment_id"].str.endswith(seg_num)
lp_mass[i] = bom.lp.loc[mask, "weight"].sum() * g_to_kg
lp_mass[i] = bom.lp.loc[mask, "dryweight"].sum()
if not bom.sw.empty:
mask = bom.sw["segment_id"].str.contains(f"_{seg_num}_SW|^{seg_num}_SW", regex=True)
sw_mass[i] = bom.sw.loc[mask, "weight"].sum() * g_to_kg
sw_mass[i] = bom.sw.loc[mask, "dryweight"].sum()

x = np.arange(n_segs)
fig, ax = plt.subplots()
Expand Down
50 changes: 21 additions & 29 deletions src/pynumad/io/yaml_to_blade.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import yaml
import numpy as np
import logging
from scipy.stats import mode

from pynumad.utils.misc_utils import (
LARCetaT,
Expand Down Expand Up @@ -40,7 +39,7 @@ def yaml_to_blade(blade, filename: str, write_airfoils: bool = False):
# Read in yaml file as a nested dictionary
with open(filename) as blade_yaml:
# data = yaml.load(blade_yaml,Loader=yaml.FullLoader)
data = yaml.load(blade_yaml, Loader=yaml.Loader)
data = yaml.load(blade_yaml, Loader=yaml.FullLoader)

# initialize definition
definition = Definition()
Expand Down Expand Up @@ -74,6 +73,8 @@ def yaml_to_blade(blade, filename: str, write_airfoils: bool = False):
filename,
write_airfoils,
)
blade.ispan = definition.ispan

### MATERIALS
_add_materials(definition, mat_data)

Expand Down Expand Up @@ -117,13 +118,11 @@ def _add_stations(
write_airfoils,
):
# Obtaining some parameters not explicitly given in YAML file
L = np.ceil(blade_outer_shape_bem["reference_axis"]["z"]["values"][-1])
R = L + hub_outer_shape_bem["diameter"] / 2
L = R - hub_outer_shape_bem["diameter"] / 2
L = blade_outer_shape_bem["reference_axis"]["z"]["values"][-1]
definition.span = np.multiply(
np.transpose(blade_outer_shape_bem["reference_axis"]['z']['grid']), L
)
definition.ispan = definition.span
definition.ispan = definition.span.copy()

# Aerodynamic properties
# using interp because yaml can have different r/R for twist and chord
Expand Down Expand Up @@ -161,14 +160,11 @@ def _add_stations(
y = np.array(af_data[IAF]["coordinates"]["y"], dtype=float)
xf_coords = np.stack((x, y), 1)

# find coordinate direction (clockwise or counter-clockwise) Winding
# Number. clockwise starting at (1,0) is correct
with np.errstate(divide="ignore", invalid="ignore"):
if (
np.nanmean(np.gradient(np.arctan(xf_coords[:, 1] / xf_coords[:, 0])))
> 0
):
xf_coords = np.flipud(xf_coords)
# Ensure clockwise winding starting at (1,0) using signed area (shoelace).
# Positive signed area means counter-clockwise; flip to make it clockwise.
x, y = xf_coords[:, 0], xf_coords[:, 1]
if np.sum(x[:-1] * y[1:] - x[1:] * y[:-1]) > 0:
xf_coords = np.flipud(xf_coords)

if write_airfoils:
import os
Expand Down Expand Up @@ -268,9 +264,6 @@ def _add_materials(definition, material_data):
logging.debug(msg)
cur_mat.layerthickness = 1

finally:
pass

# first
cur_mat.uts = _parse_data(material_data[i]["Xt"])
cur_mat.ucs = -_parse_data(material_data[i]["Xc"])
Expand Down Expand Up @@ -322,8 +315,7 @@ def _add_materials(definition, material_data):
msg = f"No fatigue exponent found for material: {material_data[i]['name']}"
logging.debug(msg)
cur_mat.density = material_data[i]["rho"]
# cur_mat.dens = mat_data[i]['rho']
cur_mat.drydensity = material_data[i]["rho"]
cur_mat.drydensity = material_data[i].get("area_density_dry", float("nan"))
if (
"description" in material_data[i].keys()
and "source" in material_data[i].keys()
Expand Down Expand Up @@ -358,8 +350,8 @@ def _add_components(definition, blade_internal_structure, blade_structure_dict):
cur_comp.fabricangle = np.mean(
i_component_data["fiber_orientation"]["values"]
)
finally:
pass
except (KeyError, TypeError):
cur_comp.fabricangle = 0
if "spar" in i_component_data["name"].lower():
cur_comp.imethod = "pchip"
else:
Expand Down Expand Up @@ -426,13 +418,13 @@ def _add_components(definition, blade_internal_structure, blade_structure_dict):
if len(tempKeyList) == 1:
component_dict[tempKeyList[0]].lpextents = ["d", "te"]
else:
ValueError("Incorrect number of te reinf ss components")
raise ValueError("Incorrect number of te reinf ss components")

tempKeyList = full_keys_from_substrings(key_list, ["ps"])
if len(tempKeyList) == 1:
component_dict[tempKeyList[0]].hpextents = ["d", "te"]
else:
ValueError("Incorrect number of te reinf ps components")
raise ValueError("Incorrect number of te reinf ps components")
else:
raise ValueError("Invalid number of LE reinforcements")

Expand All @@ -446,13 +438,13 @@ def _add_components(definition, blade_internal_structure, blade_structure_dict):
if len(tempKeyList) == 1:
component_dict[tempKeyList[0]].lpextents = ["le", "a"]
else:
ValueError("Incorrect number of te reinf ss components")
raise ValueError("Incorrect number of le reinf ss components")

tempKeyList = full_keys_from_substrings(key_list, ["ps"])
if len(tempKeyList) == 1:
component_dict[tempKeyList[0]].hpextents = ["le", "a"]
else:
ValueError("Incorrect number of te reinf ps components")
raise ValueError("Incorrect number of le reinf ps components")
else:
raise ValueError("Invalid number of LE reinforcements")

Expand Down Expand Up @@ -591,10 +583,10 @@ def _add_spar_caps(definition, blade_structure_dict):
* 1000
)
except KeyError:
definition.sparcap_start_nd_arc = blade_structure_dict[
definition.sparcap_start_nd_arc_lp = blade_structure_dict[
sparCapKeys[lpSideIndex]
]["start_nd_arc"]["values"]
definition.sparcap_end_nd_arc = blade_structure_dict[sparCapKeys[lpSideIndex]][
definition.sparcap_end_nd_arc_lp = blade_structure_dict[sparCapKeys[lpSideIndex]][
"end_nd_arc"
]["values"]

Expand All @@ -607,10 +599,10 @@ def _add_spar_caps(definition, blade_structure_dict):
* 1000
)
except KeyError:
definition.sparcap_start_nd_arc = blade_structure_dict[
definition.sparcap_start_nd_arc_hp = blade_structure_dict[
sparCapKeys[hpSideIndex]
]["start_nd_arc"]["values"]
definition.sparcap_end_nd_arc = blade_structure_dict[sparCapKeys[hpSideIndex]][
definition.sparcap_end_nd_arc_hp = blade_structure_dict[sparCapKeys[hpSideIndex]][
"end_nd_arc"
]["values"]
return definition
Expand Down
Loading
Loading