def createEquivalentBeam(self): """ Takes the wing positions at every time step and creates an equivalent beam description """ # distance following the form of the wing r_OC = np.linspace(0.0, self.wdef.front.OC, np.round(self.n*self.wdef.front.OC/(self.wdef.front.OC+self.wdef.front.CD))) r_CD = np.linspace(0.0, self.wdef.front.CD, np.round(self.n*self.wdef.front.CD/(self.wdef.front.OC+self.wdef.front.CD))+1) # calculate vector from O to C and from C to D for angular step of the mechanism OCf_vec = (self.wpos.front.C-self.wpos.front.O).T CDf_vec = (self.wpos.front.D-self.wpos.front.C).T OCb_vec = (self.wpos.back.C-self.wpos.back.O).T CDb_vec = (self.wpos.back.D-self.wpos.back.C).T for ocf, cdf, ocb, cdb in zip(OCf_vec, CDf_vec, OCb_vec, CDb_vec): # make unit vectors ocf = ocf/np.linalg.norm(ocf) cdf = cdf/np.linalg.norm(cdf) ocb = ocb/np.linalg.norm(ocb) cdb = cdb/np.linalg.norm(cdb) # beam position beam_pos = np.array([[0.0, 0.0, 0.0]]) for r in r_OC[1:]: beam_pos = np.vstack((beam_pos, [ocf*r])) # beam_pos[-1][2] = self.wpos.front.O[2][0] for r in r_CD[1:]: beam_pos = np.vstack((beam_pos, [beam_pos[len(r_OC)-1]+cdf*r])) # beam_pos[-1][2] = self.wpos.front.O[2][0] # put position into correct structure beam = BeamGeometryVT() beam.x = beam_pos.T[2] beam.y = beam_pos.T[1] beam.z = beam_pos.T[0] # print beam_pos.T[2] # beam twist beam_pos_back = np.array([[0.0, 0.0, self.wpos.back.O[2][0]]]) z = np.array([0, 0, 1]) x = np.array([ocf]) for r in r_OC[1:]: beam_pos_back = np.vstack((beam_pos_back, [ocb*r])) # Assumption: no taper, no sweep beam_pos_back[-1][2] = self.wpos.back.O[2][0] #rot_x.append(np.rad2deg(np.arccos(np.dot(ocf, np.array([1, 0, 0]))/np.linalg.norm(ocf)))) z = np.vstack((z, [0, 0, 1])) x = np.vstack((x, [ocf])) for r in r_CD[1:]: beam_pos_back = np.vstack((beam_pos_back, [beam_pos_back[len(r_OC)-1]+cdb*r])) # Assumption: no taper, no sweep # beam_pos_back[-1][2] = self.wpos.back.O[2][0] #rot_x.append(np.rad2deg(np.arccos(np.dot(cdf, np.array([1, 0, 0]))/np.linalg.norm(cdf)))) z = np.vstack((z, [0, 0, 1])) x = np.vstack((x, [cdf])) y = np.cross(x, z) y = y/((y*y).sum(axis=1)**0.5)[:, np.newaxis] v = beam_pos-beam_pos_back v_y = (v*y).sum(axis=1) v_x = (v*x).sum(axis=1) v_z = (v*z).sum(axis=1) #v_z = beam_pos-beam_pos_back #v_z[:,1] = np.zeros(len(v_z)) #v_z = v_z/((v_z*v_z).sum(axis=1)**0.5)[:,np.newaxis] beam.rot_x = np.zeros(len(beam_pos.T[0])) #np.array(rot_x) beam.rot_y = np.zeros(len(beam_pos.T[0])) #np.rad2deg(np.arctan((beam_pos.T[0]-beam_pos_back.T[0])/(beam_pos.T[2]-beam_pos_back.T[2]))) beam.rot_z = -np.rad2deg(np.arctan(v_y/v_z)) #np.sign(v[:,1])*np.rad2deg(np.arccos((v*v_z).sum(axis=1)/(v*v).sum(axis=1)**0.5)) # np.rad2deg(np.arctan((beam_pos.T[1]-beam_pos_back.T[1])/(beam_pos.T[2]-beam_pos_back.T[2]))) beam.s = calculate_length(np.array([beam.x, beam.y, beam.z]).T) if (len(self.wpos.eqspar_geom) == 0): print "v_y ", v_y print "v_z ", v_z print "rot_z ", beam.rot_z # beam speed if len(self.wpos.eqspar_geom)>0: beam_previous = self.wpos.eqspar_geom[-1] beam_previous.vel_x = (beam.x-beam_previous.x)/self.dt beam_previous.vel_y = (beam.y-beam_previous.y)/self.dt beam_previous.vel_z = (beam.z-beam_previous.z)/self.dt self.wpos.eqspar_geom[-1] = beam_previous self.wpos.eqspar_geom.append(beam) self.wpos.eqspar_geom.pop()
from BISDEM.lib.vartrees import WingPlanformVT from openmdao.main.api import Component from openmdao.lib.datatypes.api import Float, List, Slot, File, FileRef from fusedwind.turbine.geometry_vt import BeamGeometryVT, BladePlanformVT from fusedwind.lib.geom_tools import calculate_length from os.path import expanduser home = expanduser("~") surface = WingSurface() beam = BeamGeometryVT() beam.x = np.array([0, 0.0, -0.05]); beam.y = np.array([0, -0.01, -0.02]); beam.z = np.array([0, 0.1, 0.2]); beam.s = calculate_length(np.array([beam.x, beam.y, beam.z]).T) beam.rot_x = [0, 0, 0]; beam.rot_y = [0, 0, 0]; beam.rot_z = [0, 0, 0]; surface.eqspar_geom = [beam] planform = WingPlanformVT(); planform.blade_length = .2; planform.chord = [1, 1, 0.5]; planform.rthick = np.array([0.05, 0.05, 0.05]); planform.p_le = [0.0, 0.0, 0.0]; surface.planform_in = [planform]; surface.airfoils = [home+'/git/BISDEM/data/ffaw3241.dat', home+'/git/BISDEM/data/ffaw3301.dat']; surface.span_ni = 3;