Skip to content
Snippets Groups Projects
Commit 4017f34c authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

main_body.py

parent e9887975
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -15,12 +15,44 @@ class MainBody(): ...@@ -15,12 +15,44 @@ class MainBody():
def __init__(self, htc_filename, modelpath, body_name): def __init__(self, htc_filename, modelpath, body_name):
self.htcfile = htcfile = HTCFile(htc_filename, modelpath) self.htcfile = htcfile = HTCFile(htc_filename, modelpath)
s = htcfile.new_htc_structure s = htcfile.new_htc_structure
blade_name = htcfile.aero.link[2] main_bodies = {s[k].name[0]:s[k] for k in s.keys() if s[k].name_ == "main_body"}
mainbodies = [s[k] for k in s.keys() if s[k].name_ == "main_body"] self.main_body = main_bodies[body_name]
self.stFile = StFile(os.path.join(htcfile.modelpath, self.main_body.timoschenko_input.filename[0]))
self.c2def = np.array([v.values[1:5] for v in self.main_body.c2_def if v.name_ == "sec"])
self.concentrated_mass = [cm.values for cm in self.main_body if cm.name_.startswith('concentrated_mass')]
def plot_xz_geometry(self, plt=None):
if plt is None:
import matplotlib.pyplot as plt
plt.figure()
plt.xlabel("z")
plt.ylabel("x")
z = np.linspace(self.c2def[0, 2], self.c2def[-1, 2], 100)
plt.plot(self.c2def[:, 2], self.c2def[:, 0],'.-', label='Center line')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 0]) + self.stFile.x_e(z), label='Elastic center')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 0]) + self.stFile.x_cg(z), label='Mass center')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 0]) + self.stFile.x_sh(z), label='Shear center')
for cm in self.concentrated_mass:
plt.plot(self.c2def[cm[0]-1,2]+cm[3],self.c2def[cm[0]-1,0]+cm[1],'x', label='Concentrated mass')
plt.legend()
def plot_yz_geometry(self, plt=None):
if plt is None:
import matplotlib.pyplot as plt
plt.figure()
plt.xlabel("z")
plt.ylabel("y")
z = np.linspace(self.c2def[0, 2], self.c2def[-1, 2], 100)
plt.plot(self.c2def[:, 2], self.c2def[:, 1], label='Center line')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 1]) + self.stFile.y_e(z), label='Elastic center')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 1]) + self.stFile.y_cg(z), label='Mass center')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 1]) + self.stFile.y_sh(z), label='Shear center')
for cm in self.concentrated_mass:
plt.plot(self.c2def[cm[0]-1,2]+cm[3],self.c2def[cm[0]-1,1]+cm[2],'x', label='Concentrated mass')
plt.legend()
blade_main_body = [mb for mb in mainbodies if mb.name[0] == blade_name][0]
self.stFile = StFile(os.path.join(htcfile.modelpath, blade_main_body.timoschenko_input.filename[0]))
self.c2def = np.array([v.values[1:5] for v in blade_main_body.c2_def if v.name_ == "sec"])
class BladeData(object): class BladeData(object):
def plot_xz_geometry(self, plt): def plot_xz_geometry(self, plt):
...@@ -93,62 +125,33 @@ class BladeData(object): ...@@ -93,62 +125,33 @@ class BladeData(object):
class H2BladeData(BladeData): class Blade(MainBody, BladeData):
def __init__(self, htc_filename, modelpath): def __init__(self, htc_filename, modelpath, blade_number=1):
self.htcfile = htcfile = HTCFile(htc_filename, modelpath) self.htcfile = htcfile = HTCFile(htc_filename, modelpath)
blade_name = [link[2] for link in htcfile.aero if link.name_.startswith('link') and link[0]==blade_number][0]
MainBody.__init__(self, htc_filename, modelpath, blade_name)
self.pcFile = PCFile(os.path.join(htcfile.modelpath, htcfile.aero.pc_filename[0]), self.pcFile = PCFile(os.path.join(htcfile.modelpath, htcfile.aero.pc_filename[0]),
os.path.join(htcfile.modelpath, htcfile.aero.ae_filename[0])) os.path.join(htcfile.modelpath, htcfile.aero.ae_filename[0]))
s = htcfile.new_htc_structure
blade_name = htcfile.aero.link[2] def plot_xz_geometry(self, plt=None):
mainbodies = [s[k] for k in s.keys() if s[k].name_ == "main_body"]
blade_main_body = [mb for mb in mainbodies if mb.name[0] == blade_name][0]
self.stFile = StFile(os.path.join(htcfile.modelpath, blade_main_body.timoschenko_input.filename[0]))
self.c2def = np.array([v.values[1:5] for v in blade_main_body.c2_def if v.name_ == "sec"])
def plot_geometry(self, plt=None):
if plt is None: if plt is None:
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
plt.figure()
MainBody.plot_xz_geometry(self, plt)
BladeData.plot_xz_geometry(self, plt=plt) BladeData.plot_xz_geometry(self, plt=plt)
z = np.linspace(self.c2def[0, 2], self.c2def[-1, 2], 100)
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 0]) + self.stFile.x_e(z), label='Elastic center')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 0]) + self.stFile.x_cg(z), label='Mass center')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 0]) + self.stFile.x_sh(z), label='Shear center')
plt.legend() plt.legend()
plt.figure()
BladeData.plot_yz_geometry(self, plt=plt) def plot_geometry_yz(self, plt=None):
z = np.linspace(self.c2def[0, 2], self.c2def[-1, 2], 100)
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 1]) + self.stFile.y_e(z), label='Elastic center')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 1]) + self.stFile.y_cg(z), label='Mass center')
plt.plot(z, np.interp(z, self.c2def[:, 2], self.c2def[:, 1]) + self.stFile.y_sh(z), label='Shear center')
plt.legend()
plt.show()
class H2AeroBladeData(BladeData):
def __init__(self, htc_filename, modelpath):
self.htcfile = htcfile = HTCFile(htc_filename, modelpath)
self.pcFile = PCFile(os.path.join(htcfile.modelpath, htcfile.aero.pc_filename[0]),
os.path.join(htcfile.modelpath, htcfile.aero.ae_filename[0]))
self.c2def = np.array([v.values[1:5] for v in htcfile.blade_c2_def if v.name_ == "sec"])
def plot_geometry(self, plt=None):
if plt is None: if plt is None:
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
plt.figure()
BladeData.plot_xz_geometry(self, plt=plt)
z = np.linspace(self.c2def[0, 2], self.c2def[-1, 2], 100)
plt.legend()
plt.figure()
BladeData.plot_yz_geometry(self, plt=plt) BladeData.plot_yz_geometry(self, plt=plt)
z = np.linspace(self.c2def[0, 2], self.c2def[-1, 2], 100) MainBody.plot_yz_geometry(self, plt)
plt.legend()
plt.show()
...@@ -205,9 +205,9 @@ class TestHtcFile(unittest.TestCase): ...@@ -205,9 +205,9 @@ class TestHtcFile(unittest.TestCase):
'./data/DTU_10MW_RWT_Towertop_st.dat', './data/DTU_10MW_RWT_Towertop_st.dat',
'./data/DTU_10MW_RWT_Shaft_st.dat', './data/DTU_10MW_RWT_Shaft_st.dat',
'./data/DTU_10MW_RWT_Hub_st.dat', './data/DTU_10MW_RWT_Hub_st.dat',
'data/2Bdown-rR1.08_blade_st.dat', './data/dtu_10mw_rwt_blade_st.dat',
'./data/2Bdown-rR1.08_ae.dat', './data/dtu_10mw_rwt_ae.dat',
'./data/2Bup_AEP095_pc.dat', './data/dtu_10mw_rwt_pc.dat',
'./control/risoe_controller.dll', './control/risoe_controller.dll',
'./control/generator_servo.dll', './control/generator_servo.dll',
'./control/mech_brake.dll', './control/mech_brake.dll',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment