Skip to content

Commit

Permalink
Fixing shell to work with new stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
kbonney committed Aug 30, 2023
1 parent dc463f9 commit b5bdb9c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
39 changes: 20 additions & 19 deletions src/pynumad/objects/stackdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from numpy import ndarray
import numpy as np
from pynumad.objects.keypoints import KeyPoints
from pynumad.objects.bom import BillOfMaterials

class StackDatabase:
def __init__(self):
self.stacks: ndarray = None
self.swstacks: ndarray = None

def generate(self, keypoints: KeyPoints):
def generate(self, keypoints: KeyPoints, bom: BillOfMaterials):
# build the material stack for each area
n_segments = keypoints.key_areas.shape[0]
n_stations = keypoints.key_areas.shape[1]
Expand Down Expand Up @@ -44,33 +45,33 @@ def generate(self, keypoints: KeyPoints):
k_seg + 1,
]

for k in range(len(self.bom["hp"])):
for k in range(len(bom["hp"])):
# for each row in the BOM, get the ply definition ...
cur_ply = Ply()
cur_ply.component = self.bom["hp"][k].name
cur_ply.materialid = self.bom["hp"][k].materialid
cur_ply.thickness = self.bom["hp"][k].thickness
cur_ply.angle = 0 # TODO, set to 0 for now, self.bom['lp'](k, );
cur_ply.component = bom["hp"][k].name
cur_ply.materialid = bom["hp"][k].materialid
cur_ply.thickness = bom["hp"][k].thickness
cur_ply.angle = 0 # TODO, set to 0 for now, bom['lp'](k, );
cur_ply.nPlies = 1 # default to 1, modified in addply() if necessary

# ... and add the ply to every area that is part of the region
ind = self.bomIndices["hp"][k]
ind = bom.indices["hp"][k]
for k_seg in range(ind[2], ind[3]):
for k_stat in range(ind[0], ind[1]):
# deepcopy is important to keep make ply object unique in each stack
self.stacks[k_seg, k_stat].addply(deepcopy(cur_ply))

for k in range(len(self.bom["lp"])):
for k in range(len(bom["lp"])):
# for each row in the BOM, get the ply definition ...
cur_ply = Ply()
cur_ply.component = self.bom["lp"][k].name
cur_ply.materialid = self.bom["lp"][k].materialid
cur_ply.thickness = self.bom["lp"][k].thickness
cur_ply.angle = 0 # TODO, set to 0 for now, self.bom['lp'](k, );
cur_ply.component = bom["lp"][k].name
cur_ply.materialid = bom["lp"][k].materialid
cur_ply.thickness = bom["lp"][k].thickness
cur_ply.angle = 0 # TODO, set to 0 for now, bom['lp'](k, );
cur_ply.nPlies = 1 # default to 1, modified in addply() if necessary

# ... and add the ply to every area that is part of the region
ind = self.bomIndices["lp"][k]
ind = bom.indices["lp"][k]
for k_seg in range(ind[2], ind[3]):
for k_stat in range(ind[0], ind[1]):
self.stacks[k_seg, k_stat].addply(deepcopy(cur_ply))
Expand All @@ -92,17 +93,17 @@ def generate(self, keypoints: KeyPoints):
ind[1],
]
for k_web in range(n_webs):
for k in range(len(self.bom["sw"][k_web])):
for k in range(len(bom["sw"][k_web])):
# for each row in the BOM, get the ply definition ...
cur_ply = Ply()
cur_ply.component = self.bom["sw"][k_web][k].name
cur_ply.materialid = self.bom["sw"][k_web][k].materialid
cur_ply.thickness = self.bom["sw"][k_web][k].thickness
cur_ply.angle = 0 # TODO, set to 0 for now, self.bom['lp'](k, );
cur_ply.component = bom["sw"][k_web][k].name
cur_ply.materialid = bom["sw"][k_web][k].materialid
cur_ply.thickness = bom["sw"][k_web][k].thickness
cur_ply.angle = 0 # TODO, set to 0 for now, bom['lp'](k, );
cur_ply.nPlies = 1 # default to 1, modified in addply() if necessary

# ... and add the ply to every area that is part of the region
ind = self.bomIndices["sw"][k_web][k]
ind = bom.indices["sw"][k_web][k]
for k_stat in range(ind[0], ind[1]):
self.swstacks[k_web, k_stat].addply(deepcopy(cur_ply))

Expand Down
31 changes: 17 additions & 14 deletions src/pynumad/shell/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def shell_mesh_general(blade, forSolid, includeAdhesive, elementSize):
coordinates = geometry.coordinates
profiles = geometry.profiles
key_points = blade.keypoints.key_points
stacks = blade.stackdb.stacks
swstacks = blade.stackdb.swstacks

geomSz = coordinates.shape
lenGeom = geomSz[0]
numXsec = geomSz[2]
Expand Down Expand Up @@ -300,19 +303,19 @@ def shell_mesh_general(blade, forSolid, includeAdhesive, elementSize):
"quad3",
shellKp,
nEl,
name=blade.stacks[j, i].name,
name=stacks[j, i].name,
elType="quad",
meshMethod="structured",
)
newSec = dict()
newSec["type"] = "shell"
layup = list()
for pg in blade.stacks[j, i].plygroups:
for pg in stacks[j, i].plygroups:
totThick = pg.thickness * pg.nPlies
ply = [pg.materialid, totThick, pg.angle]
layup.append(ply)
newSec["layup"] = layup
newSec["elementSet"] = blade.stacks[j, i].name
newSec["elementSet"] = stacks[j, i].name
secList.append(newSec)
stSp = stSp + 3
stPt = stPt + 3
Expand All @@ -328,8 +331,8 @@ def shell_mesh_general(blade, forSolid, includeAdhesive, elementSize):
for j in range(rws - 1):
totalThick = 0
for k in range(3):
tpp = 0.001 * blade.stacks[sec, j].plygroups[k].thickness
npls = blade.stacks[sec, j].plygroups[k].nPlies
tpp = 0.001 * stacks[sec, j].plygroups[k].thickness
npls = stacks[sec, j].plygroups[k].nPlies
totalThick = totalThick + tpp * npls
for k in range(3):
vx = splineXi[stPt, tgtSp] - splineXi[stPt, spl]
Expand All @@ -349,7 +352,7 @@ def shell_mesh_general(blade, forSolid, includeAdhesive, elementSize):
web1Sets = np.array([])
web2Sets = np.array([])
for i in range(rws - 1):
if blade.swstacks[0][i].plygroups:
if swstacks[0][i].plygroups:
shellKp = np.zeros((16, 3))
shellKp[0, :] = np.array(
[splineXi[stPt, 12], splineYi[stPt, 12], splineZi[stPt, 12]]
Expand Down Expand Up @@ -403,21 +406,21 @@ def shell_mesh_general(blade, forSolid, includeAdhesive, elementSize):
"quad3",
shellKp,
nEl,
name=blade.swstacks[0][i].name,
name=swstacks[0][i].name,
elType="quad",
meshMethod="structured",
)
newSec = dict()
newSec["type"] = "shell"
layup = list()
for pg in blade.swstacks[0][i].plygroups:
for pg in swstacks[0][i].plygroups:
totThick = pg.thickness * pg.nPlies
ply = [pg.materialid, totThick, pg.angle]
layup.append(ply)
newSec["layup"] = layup
newSec["elementSet"] = blade.swstacks[0][i].name
newSec["elementSet"] = swstacks[0][i].name
secList.append(newSec)
if blade.swstacks[1][i].plygroups:
if swstacks[1][i].plygroups:
shellKp = np.zeros((16, 3))
shellKp[0, :] = np.array(
[splineXi[stPt, 27], splineYi[stPt, 27], splineZi[stPt, 27]]
Expand Down Expand Up @@ -471,19 +474,19 @@ def shell_mesh_general(blade, forSolid, includeAdhesive, elementSize):
"quad3",
shellKp,
nEl,
name=blade.swstacks[1][i].name,
name=swstacks[1][i].name,
elType="quad",
meshMethod="structured",
)
newSec = dict()
newSec["type"] = "shell"
layup = list()
for pg in blade.swstacks[1][i].plygroups:
for pg in swstacks[1][i].plygroups:
totThick = pg.thickness * pg.nPlies
ply = [pg.materialid, totThick, pg.angle]
layup.append(ply)
newSec["layup"] = layup
newSec["elementSet"] = blade.swstacks[1][i].name
newSec["elementSet"] = swstacks[1][i].name
secList.append(newSec)
stPt = stPt + 3

Expand Down Expand Up @@ -671,7 +674,7 @@ def solidMeshFromShell(blade, shellMesh, layerNumEls=[]):
for i in range(0, len(layerNumEls)):
nodeDist = np.zeros(numNds)
nodeHitCt = np.zeros(numNds, dtype=int)
numSec, numStat = blade.stacks.shape
numSec, numStat = stacks.shape
j = 0
for es in elSets:
layerThick = 0.001 * sectns[j]["layup"][i][1]
Expand Down

0 comments on commit b5bdb9c

Please sign in to comment.