def naca_4_digit(camber, xcamber, thick, npointside): camber_p = xi.copy_doublep(camber) xcamber_p = xi.copy_doublep(xcamber) thick_p = xi.copy_doublep(thick) npointside_p = xi.copy_intp(npointside) xout_a = xi.new_doublea(2 * npointside) zout_a = xi.new_doublea(2 * npointside) nout_p = xi.new_intp() xi.naca_4_digit(camber_p, xcamber_p, thick_p, npointside_p, xout_a, zout_a, nout_p) nout = xi.intp_value(nout_p) xout = nout * [0] zout = nout * [0] for i in range(nout): xout[i] = xi.doublea_getitem(xout_a, i) zout[i] = xi.doublea_getitem(zout_a, i) xi.delete_doublep(camber_p) xi.delete_doublep(xcamber_p) xi.delete_doublep(thick_p) xi.delete_intp(npointside_p) xi.delete_doublea(xout_a) xi.delete_doublea(zout_a) xi.delete_intp(nout_p) return xout, zout, nout
def xfoil_eval_spline(x, z, s, xs, zs, npt, sc): x_a = xi.new_doublea(npt) z_a = xi.new_doublea(npt) s_a = xi.new_doublea(npt) xs_a = xi.new_doublea(npt) zs_a = xi.new_doublea(npt) npt_p = xi.copy_intp(npt) sc_p = xi.copy_doublep(sc) xc_p = xi.new_doublep() zc_p = xi.new_doublep() for i in range(npt): xi.doublea_setitem(x_a, i, x[i]) xi.doublea_setitem(z_a, i, z[i]) xi.doublea_setitem(s_a, i, s[i]) xi.doublea_setitem(xs_a, i, xs[i]) xi.doublea_setitem(zs_a, i, zs[i]) xi.xfoil_eval_spline(x_a, z_a, s_a, xs_a, zs_a, npt_p, sc_p, xc_p, zc_p) xc = xi.doublep_value(xc_p) zc = xi.doublep_value(zc_p) xi.delete_doublea(x_a) xi.delete_doublea(z_a) xi.delete_doublea(s_a) xi.delete_doublea(xs_a) xi.delete_doublea(zs_a) xi.delete_doublep(sc_p) xi.delete_doublep(xc_p) xi.delete_doublep(zc_p) return xc, zc
def xfoil_speccl(xdg, cl_spec): cl_spec_p = xi.copy_doublep(cl_spec) alpha_p = xi.new_doublep() lift_p = xi.new_doublep() drag_p = xi.new_doublep() moment_p = xi.new_doublep() converged_p = xi.new_boolp() stat_p = xi.new_intp() xi.xfoil_speccl(xdg, cl_spec_p, alpha_p, lift_p, drag_p, moment_p, converged_p, stat_p) alpha = xi.doublep_value(alpha_p) lift = xi.doublep_value(lift_p) drag = xi.doublep_value(drag_p) moment = xi.doublep_value(moment_p) converged = xi.boolp_value(converged_p) stat = xi.intp_value(stat_p) xi.delete_doublep(cl_spec_p) xi.delete_doublep(alpha_p) xi.delete_doublep(lift_p) xi.delete_doublep(drag_p) xi.delete_doublep(moment_p) xi.delete_boolp(converged_p) xi.delete_intp(stat_p) return alpha, lift, drag, moment, converged, stat
def xfoil_set_mach_number(xdg, mach): mach_p = xi.copy_doublep(mach) xi.xfoil_set_mach_number(xdg, mach_p) xi.delete_doublep(mach_p)
def xfoil_set_reynolds_number(xdg, re): re_p = xi.copy_doublep(re) xi.xfoil_set_reynolds_number(xdg, re_p) xi.delete_doublep(re_p)
def xfoil_modify_tegap(xdg, gap, blendloc): stat_p = xi.new_intp() gap_p = xi.copy_doublep(gap) blendloc_p = xi.copy_doublep(blendloc) npointout_p = xi.new_intp() xi.xfoil_modify_tegap(xdg, gap_p, blendloc_p, npointout_p, stat_p) npointout = xi.intp_value(npointout_p) stat = xi.intp_value(stat_p) xi.delete_doublep(gap_p) xi.delete_doublep(blendloc_p) xi.delete_intp(npointout_p) xi.delete_intp(stat_p) return npointout, stat
def xfoil_apply_flap_deflection(xdg, xflap, zflap, z_flap_spec, degrees): xflap_p = xi.copy_doublep(xflap) zflap_p = xi.copy_doublep(zflap) z_flap_spec_p = xi.copy_intp(z_flap_spec) degrees_p = xi.copy_doublep(degrees) npointout_p = xi.new_intp() stat_p = xi.new_intp() xi.xfoil_apply_flap_deflection(xdg, xflap_p, zflap_p, z_flap_spec_p, degrees_p, npointout_p, stat_p) npointout = xi.intp_value(npointout_p) stat = xi.intp_value(stat_p) xi.delete_doublep(xflap_p) xi.delete_doublep(zflap_p) xi.delete_intp(z_flap_spec_p) xi.delete_intp(npointout_p) xi.delete_intp(stat_p) return npointout, stat
def run_xfoil(npointin, xin, zin, geom_opts, noppoint, operating_points, op_modes, reynolds_numbers, mach_numbers, use_flap, x_flap, z_flap, z_flap_spec, flap_degrees, xfoil_opts, reinitialize, fix_unconverged): npointin_p = xi.copy_intp(npointin) xin_a = xi.new_doublea(npointin) zin_a = xi.new_doublea(npointin) noppoint_p = xi.copy_intp(noppoint) operating_points_a = xi.new_doublea(noppoint) op_modes_a = xi.new_inta(noppoint) reynolds_numbers_a = xi.new_doublea(noppoint) mach_numbers_a = xi.new_doublea(noppoint) use_flap_p = xi.copy_boolp(use_flap) if use_flap: x_flap_p = xi.copy_doublep(x_flap) z_flap_p = xi.copy_doublep(z_flap) z_flap_spec_p = xi.copy_intp(z_flap_spec) else: x_flap_p = xi.new_doublep() z_flap_p = xi.new_doublep() z_flap_spec_p = xi.new_intp() flap_degrees_a = xi.new_doublea(noppoint) reinitialize_p = xi.copy_boolp(reinitialize) fix_unconverged_p = xi.copy_boolp(fix_unconverged) lift_a = xi.new_doublea(noppoint) drag_a = xi.new_doublea(noppoint) moment_a = xi.new_doublea(noppoint) viscrms_a = xi.new_doublea(noppoint) alpha_a = xi.new_doublea(noppoint) xtrt_a = xi.new_doublea(noppoint) xtrb_a = xi.new_doublea(noppoint) stat_p = xi.new_intp() for i in range(npointin): xi.doublea_setitem(xin_a, i, xin[i]) xi.doublea_setitem(zin_a, i, zin[i]) for i in range(noppoint): xi.doublea_setitem(operating_points_a, i, operating_points[i]) xi.inta_setitem(op_modes_a, i, op_modes[i]) xi.doublea_setitem(reynolds_numbers_a, i, reynolds_numbers[i]) xi.doublea_setitem(mach_numbers_a, i, mach_numbers[i]) if use_flap: xi.doublea_setitem(flap_degrees_a, i, flap_degrees[i]) xi.run_xfoil(npointin_p, xin_a, zin_a, geom_opts, noppoint_p, operating_points_a, op_modes_a, reynolds_numbers_a, mach_numbers_a, use_flap_p, x_flap_p, z_flap_p, z_flap_spec_p, flap_degrees_a, xfoil_opts, reinitialize_p, fix_unconverged_p, lift_a, drag_a, moment_a, viscrms_a, alpha_a, xtrt_a, xtrb_a, stat_p) stat = xi.intp_value(stat_p) lift = noppoint * [0] drag = noppoint * [0] moment = noppoint * [0] viscrms = noppoint * [0] alpha = noppoint * [0] xtrt = noppoint * [0] xtrb = noppoint * [0] for i in range(noppoint): lift[i] = xi.doublea_getitem(lift_a, i) drag[i] = xi.doublea_getitem(drag_a, i) moment[i] = xi.doublea_getitem(moment_a, i) viscrms[i] = xi.doublea_getitem(viscrms_a, i) alpha[i] = xi.doublea_getitem(alpha_a, i) xtrt[i] = xi.doublea_getitem(xtrt_a, i) xtrb[i] = xi.doublea_getitem(xtrb_a, i) xi.delete_intp(npointin_p) xi.delete_doublea(xin_a) xi.delete_doublea(zin_a) xi.delete_intp(noppoint_p) xi.delete_doublea(operating_points_a) xi.delete_inta(op_modes_a) xi.delete_doublea(reynolds_numbers_a) xi.delete_doublea(mach_numbers_a) xi.delete_boolp(use_flap_p) xi.delete_doublep(x_flap_p) xi.delete_doublep(z_flap_p) xi.delete_intp(z_flap_spec_p) xi.delete_doublea(flap_degrees_a) xi.delete_doublea(lift_a) xi.delete_doublea(drag_a) xi.delete_doublea(moment_a) xi.delete_doublea(viscrms_a) xi.delete_doublea(alpha_a) xi.delete_doublea(xtrt_a) xi.delete_doublea(xtrb_a) xi.delete_intp(stat_p) return lift, drag, moment, viscrms, alpha, xtrt, xtrb, stat