-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
234 additions
and
87 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,195 @@ | ||
import numpy as np | ||
import pprint | ||
import msgpi.sg as sg | ||
|
||
|
||
class BladeSegment(object): | ||
"""Class for a blade segment. | ||
""" | ||
|
||
def __init__(self): | ||
#: list of ints: Point labels. | ||
#: `[beginning point, ending point]` | ||
self.points = [] | ||
#: list of lists of floats: Coordinates of beginning and ending points. | ||
#: `[[x1, x2, x3], [x1, x2, x3]]` | ||
self.coords = [] | ||
#: list of ints: Cross-section labels. | ||
#: `[beginning, ending]` | ||
self.css = [] | ||
|
||
# {local coord: section name, ...} | ||
self.sections = {} | ||
|
||
#: float: Rotation around a1. | ||
self.rotate_a1 = 0.0 | ||
#: float: Twist. | ||
self.twist = 0.0 | ||
# self.dihedral = 0. | ||
# self.sweep = 0. | ||
#: int: Local frame id. | ||
self.local_frame_id = 0 | ||
#: int: Frame id | ||
self.frame_id = 0 | ||
#: int: Curvature id | ||
self.curv_id = 0 | ||
|
||
#: int: Number of division of the segment. | ||
self.num_divisions = 1 | ||
|
||
#: dict: Parameter distributions | ||
#: `{name: [beginning value, ending value], ...}` | ||
self.cs_parameters = {} | ||
|
||
def summary(self): | ||
print(' points:', self.points) | ||
print(' coords:', self.coords) | ||
print(' cs names:', self.css) | ||
print(' cs templates:', self.cs_template) | ||
print(' cs parameters:', self.cs_parameters) | ||
|
||
def calcLengthSq(self): | ||
"""Calculate the square of the segment length. | ||
Returns | ||
------- | ||
float | ||
Squred length of the segment. | ||
""" | ||
return ((np.array(self.coords[0]) - np.array(self.coords[1]))**2).sum() | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
class Blade(object): | ||
"""Class for a rotor blade. | ||
""" | ||
|
||
def __init__(self): | ||
#: str: Name of the beam. | ||
self.name = '' | ||
|
||
# Design | ||
|
||
#: dict of {int, list of floats}: Key point id and coordinates. | ||
#: `{ptid: [x1, x2, x3], ...}` | ||
self.points = {} | ||
|
||
#: dict of {int, msgpi.ms.beam.BeamSegment}: Beam segments | ||
#: `{bsid: BeamSegment object, ...}` | ||
self.segments = {} | ||
|
||
#: dict of {int, msgpi.sg.BeamProperty}: Effective properties of cross-sections. | ||
#: `{sid: BeamProperty object, ...}` | ||
self.sections = {} | ||
|
||
# {section name: msgpi.sg.CrossSection, ...} | ||
self.section_database = {} | ||
|
||
self.frames = {} #: Local frames | ||
self.distrloads = [] #: Distribution loads | ||
self.timefunctions = [] #: Time functions | ||
self.initcurvatures = [] #: Initial curvatures | ||
|
||
self.functions = {} #: Functions | ||
self.distributions = {} #: Distributions | ||
|
||
|
||
|
||
|
||
def summary(self): | ||
pp = pprint.PrettyPrinter(indent=4, compact=False) | ||
|
||
print('\nAnalysis') | ||
print('analysis type:', self.analysis_type) | ||
print('max iteration:', self.max_iteration) | ||
print('number of steps:', self.num_steps) | ||
if self.analysis_type != 0: | ||
print('angular velocity:', self.angular_velocity) | ||
print('time function:', self.av_tf) | ||
print('linear velocity:', self.linear_velocity) | ||
print('time function:', self.lv_tf) | ||
if self.analysis_type == 3: | ||
print('number of eigen results:', self.num_eigens) | ||
|
||
print('\nPoints') | ||
# pp.pprint(self.points) | ||
for pid, coords in self.points.items(): | ||
print(f'{pid}: ( {coords[0]} , {coords[1]} , {coords[2]} )') | ||
|
||
print('\nSegments') | ||
for k, v in self.segments.items(): | ||
print('segment', k) | ||
v.summary() | ||
|
||
print('\nSection templates') | ||
for sn, st in self.section_templates.items(): | ||
print(f'{sn}: {st}') | ||
|
||
print('\nSectional properties') | ||
for sid, bp in self.sections.items(): | ||
print('Section', sid) | ||
print('Compliance') | ||
pp.pprint(bp.cmpl_t) | ||
if self.analysis_type != 0: | ||
print('Mass') | ||
pp.pprint(bp.mass) | ||
print('') | ||
|
||
print('\nDistributions') | ||
pp.pprint(self.distributions) | ||
|
||
print('\nFunctions') | ||
# pp.pprint(self.functions) | ||
for k, v in self.functions.items(): | ||
print(k, ':', v) | ||
|
||
|
||
|
||
|
||
def findPtCoordByName(self, name): | ||
"""Find key point coordinates by point id. | ||
Parameters | ||
---------- | ||
name : int | ||
Point id. | ||
Returns | ||
------- | ||
list of floats | ||
Point coordinates. | ||
""" | ||
for i, c in self.points.items(): | ||
if i == name: | ||
return c | ||
return None | ||
|
||
|
||
|
||
|
||
def findSectionByName(self, name): | ||
"""Find sectional properties by section id. | ||
Parameters | ||
---------- | ||
name : int | ||
Section id. | ||
Returns | ||
------- | ||
msgpi.sg.MaterialSection | ||
Sectional properties. | ||
""" | ||
for i, s in self.sections.items(): | ||
if s.name == name: | ||
return i | ||
return 0 | ||
|
||
|
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import msgpi.ms.prebeam as prebeam | ||
|
||
beam = prebeam.preBeam2('uh60a_blade.xml') | ||
|
||
beam.summary() |
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