def get_planar_dmc(vec_u_eff, variables, kite, architecture): parent = architecture.parent_map[kite] # get relevant variables for kite n q = variables['xd']['q' + str(kite) + str(parent)] # in kite body: if parent > 0: grandparent = architecture.parent_map[parent] q_parent = variables['xd']['q' + str(parent) + str(grandparent)] else: q_parent = np.array([0., 0., 0.]) vec_t = q - q_parent # should be roughly "up-wards", ie, act like vec_w vec_v = vect_op.cross(vec_t, vec_u_eff) vec_w = vect_op.cross(vec_u_eff, vec_v) uhat = vect_op.smooth_normalize(vec_u_eff) vhat = vect_op.smooth_normalize(vec_v) what = vect_op.smooth_normalize(vec_w) planar_dcm = cas.horzcat(uhat, vhat, what) return planar_dcm
def get_segment_force(diam, q_upper, q_lower, dq_upper, dq_lower, atmos, wind, cd_tether_fun): q_average = (q_upper + q_lower) / 2. zz = q_average[2] uw_average = wind.get_velocity(zz) density = atmos.get_density(zz) dq_average = (dq_upper + dq_lower) / 2. ua = uw_average - dq_average ua_norm = vect_op.smooth_norm(ua, 1e-6) ehat_ua = vect_op.smooth_normalize(ua, 1e-6) tether = q_upper - q_lower length = vect_op.norm(tether) length_parallel_to_wind = cas.mtimes(tether.T, ehat_ua) length_perp_to_wind = (length**2. - length_parallel_to_wind**2.)**0.5 reynolds = get_reynolds_number(atmos, ua, diam, q_upper, q_lower) cd = cd_tether_fun(reynolds) drag = cd * 0.5 * density * ua_norm * diam * length_perp_to_wind * ua return drag
def get_wind_dcm(vec_u, kite_dcm): ehat_span = kite_dcm[:, 1] Dhat = vect_op.smooth_normalize(vec_u) Lhat = vect_op.smooth_normed_cross(vec_u, ehat_span) Shat = vect_op.smooth_normed_cross(Lhat, Dhat) wind_dcm = cas.horzcat(Dhat, Shat, Lhat) return wind_dcm
def approx_normal_axis(parent, variables, architecture): children = architecture.kites_map[parent] normal_sum = np.zeros((3, 1)) for kite in children: normal_sum = normal_sum + approx_kite_normal_vector( variables, architecture, kite) nhat = vect_op.smooth_normalize(normal_sum) return nhat
def approx_normal_axis(model_options, siblings, variables, architecture): parent_map = architecture.parent_map normal = np.zeros((3, 1)) for kite in siblings: parent = parent_map[kite] binormal = get_trajectory_binormal(variables, kite, parent) normal = normal + binormal nhat = vect_op.smooth_normalize(normal) return nhat
def get_element_drag_and_moment_fun(wind, atmos, cd_tether_fun): info_sym = cas.SX.sym('info_sym', (16, 1)) q_upper = info_sym[:3] q_lower = info_sym[3:6] dq_upper = info_sym[6:9] dq_lower = info_sym[9:12] diam = info_sym[12] q_seg_avg = info_sym[13:16] q_average = (q_upper + q_lower) / 2. zz = q_average[2] ua = get_uapp(q_upper, q_lower, dq_upper, dq_lower, wind) epsilon = 1.e-6 ua_norm = vect_op.smooth_norm(ua, epsilon) ehat_ua = vect_op.smooth_normalize(ua, epsilon) tether = q_upper - q_lower length_sq = cas.mtimes(tether.T, tether) length_parallel_to_wind = cas.mtimes(tether.T, ehat_ua) length_perp_to_wind = vect_op.smooth_sqrt( length_sq - length_parallel_to_wind**2., epsilon) re_number = reynolds.get_reynolds_number(atmos, ua, diam, q_upper, q_lower) cd = cd_tether_fun(re_number) density = atmos.get_density(zz) drag = cd * 0.5 * density * ua_norm * diam * length_perp_to_wind * ua moment_arm = q_average - q_seg_avg moment = vect_op.cross(moment_arm, drag) element_drag_fun = cas.Function('element_drag_fun', [info_sym], [drag]) element_moment_fun = cas.Function('element_moment_fun', [info_sym], [moment]) return element_drag_fun, element_moment_fun
def get_trajectory_normal(variables, kite, parent): ddq = variables['xddot']['ddq' + str(kite) + str(parent)] normal = vect_op.smooth_normalize(ddq) return normal
def get_trajectory_tangent(variables, kite, parent): dq = variables['xd']['dq' + str(kite) + str(parent)] tangent = vect_op.smooth_normalize(dq) return tangent
def get_kite_radial_vector(model_options, kite, variables, architecture): radius_vec = get_kite_radius_vector(model_options, kite, variables, architecture) rhat = vect_op.smooth_normalize(radius_vec) return rhat