def load_environment(filename): # load df from csv params = pd.read_csv(filename) params = params.iloc[0] # create blade airfoil_dir = params['airfoil_dir'] blade_shaft_dist = params['blade_shaft_dist'] blade_chord_length = params['blade_chord_length'] blade = vb.VawtBlade(blade_chord_length, airfoil_dir, blade_shaft_dist) # create environment wind_direction = params['wind_direction'] wind_speed = params['wind_speed'] rotor_speed = params['rotor_speed'] theta_resolution = params['theta_resolution'] pitch_resolution = params['pitch_resolution'] steps = params['steps'] tsr = params['tsr'] env = VawtRLEnvironment(blade, wind_direction, wind_speed, rotor_speed, theta_resolution, pitch_resolution, steps=steps) return env
def __init__(self, joint_name, chord_length, height, offset, sa_radius, airfoil_dir, op_interpolator_dir): self.joint_name = joint_name self.height = height self.sa_radius = sa_radius self.vb = vb.VawtBlade(chord_length, airfoil_dir, sa_radius) self.opi = OptimalPathInterpolate(op_interpolator_dir) self.offset = offset self.pitch = 0
def __init__(self): self.blades = [ # offset, pitch {'offset':0, 'pitch':0}, {'offset':math.pi, 'pitch':0} ] self.theta = 0 # airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/naca0018_360' self.blade = vb.VawtBlade(0.2, airfoil_dir, 1)
def test__rel_tang_angle(self): airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/naca0018_360' blade = vb.VawtBlade(0.2, airfoil_dir, 1) # VECTORS rel_wind, blade_tangent_vector test_values = [ [vec.Vector2(r=1, theta=1), vec.Vector2(r=1, theta=1.2), -0.2], [vec.Vector2(r=1, theta=1), vec.Vector2(r=1, theta=1.2), -0.2] ] for rel_wind, blade_tangent, rel_tang_angle in test_values: self.assertAlmostEqual(blade._rel_tang_angle(rel_wind, blade_tangent), rel_tang_angle, 5, 'Wrong _rel_tang_angle')
def test_get_cl_cd_coeffs(self): airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' blade = vb.VawtBlade(0.2, airfoil_dir, 1) test_values = [ # aoa_360, re_number, cl, cd [-78.00, 20000, -0.3640, 1.7268], [26.00, 50000, 0.5911, 0.3391], [176.00, 200000, -0.3291, 0.0145], [-149.00, 1000000, 0.3591, 0.4565] ] for tc in test_values: cl, cd = blade.get_coeffs(tc[0], tc[1]) self.assertAlmostEqual(cl, tc[2], 5, 'Wrong cl coeff') self.assertAlmostEqual(cd, tc[3], 5, 'Wrong cd coeff')
def test_angle_of_attack(self): airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' blade = vb.VawtBlade(0.2, airfoil_dir, 1) test_values = [ # rel_wind_vector, blade_chord_vector, aoa_rad, aoa_360 [vec.Vector2(r=1, theta=-2.356194490192345), vec.Vector2(r=1, theta=-1.5707963267948966), -0.785398163397, -45], [vec.Vector2(r=1, theta=-1), vec.Vector2(r=1, theta=-0.0007162025873375634), -0.9992837974126625, -57.25474412755153], [vec.Vector2(r=1, theta=0.1), vec.Vector2(r=1, theta=-2), 2.1, 120.3211369], [vec.Vector2(r=1, theta=3), vec.Vector2(r=1, theta=-2), -1.28318530, -73.5211024] ] for tc in test_values: aoa_rad, aoa_360 = blade._angle_of_attack(tc[0], tc[1]) self.assertAlmostEqual(aoa_rad, tc[2], 5, 'Wrong aoa_rad') self.assertAlmostEqual(aoa_360, tc[3], 5, 'Wrong aoa_360')
def test_airfoil_coeff_interpolataion(self): blade = vb.VawtBlade( 0.2, '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360', 1) test_values = [[20000, 10, 0.5611, 0.0918], [20000, -121.00, 0.7944, 1.3225], [100000, -175.00, 0.5238, 0.0192], [100000, 78.00, 0.4203, 1.7694], [500000, 27.00, 1.1704, 0.3691], [500000, 111.00, -0.7287, 1.6107]] for test_case in test_values: act = blade.cl_interpolate(test_case[1], test_case[0])[0] self.assertAlmostEqual(act, test_case[2], 8) act = blade.cd_interpolate(test_case[1], test_case[0])[0] self.assertAlmostEqual(act, test_case[3], 8)
def test_blade_tangent_line_angle(self): airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' blade = vb.VawtBlade(0.2, airfoil_dir, 1) # blade theta, blade tangent line angle test_values = [ [-1, -2.5707963268], [1, -0.570796327], [2, 0.429203673205], [3, 1.42920367321], [-2, 2.712388980384] ] for test_case in test_values: answer = blade._blade_tangent_line_angle(test_case[0]) self.assertAlmostEqual(answer, test_case[1], 7, 'Wrong blade_tangent_line_angle')
def __init__(self, env_params): self.env_params = env_params self.pitch_resolution = self.env_params['pitch_resolution'] self.theta_resolution = self.env_params['theta_resolution'] self.wind_speed = self.env_params['wind_speed'] self.wind_direction = self.env_params['wind_direction'] self.blade = vb.VawtBlade(self.env_params['blade_chord_length'], self.env_params['airfoil_dir'], self.env_params['blade_shaft_dist']) # for given blade create a function of (tsr,theta) that gives optimum pitch position # for given amount/set of TSR's range(0.1,6.0, step=0.1) # for each TSR create ct=f(pitch,theta) than RL the optimum pitch set in rl1_qtables # save q_table as csv DataFrame self.tsr_start = self.env_params['tsr_start'] self.tsr_stop = self.env_params['tsr_stop'] self.tsr_step = self.env_params['tsr_step']
def test_blade_chord_vec(self): # calculate blade chord angle on blade_tangent_angle and pitch airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' blade = vb.VawtBlade(0.2, airfoil_dir, 1) test_values = [ # pitch positive - rotates clockwise # positive pitch - 'takes wind under the wing of ascending plane' # positive pitch must be substracted from blade tangent to give actual blade chord vector # blade_tangent_vector, pitch, blade_chord_vector.theta [vec.Vector2(r=1, theta=-2), 1, -1], [vec.Vector2(r=1, theta=-1), -0.5, -1.5], [vec.Vector2(r=1, theta=0.1), 1, 1.1], [vec.Vector2(r=1, theta=3), -1, 2] ] for tc in test_values: answer = blade._blade_chord_vec(tc[0], tc[1]) self.assertAlmostEqual(answer.theta, tc[2], 5, 'Wrong blade chord vector')
def test_blade_tangent_line_angle(self): wind_direction = 0 wind_speed = 3 wind_vector = bc.get_wind_vector(wind_direction, wind_speed) # rotor_speed = 0.0001 rotor_speed = 3 # airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/naca0018_360' blade = vb.VawtBlade(0.2, airfoil_dir, 1) theta_pitch = [(-2, 0, 0.252998783), (-1, 0, -0.1313296584), (-1, 20 * math.tau / 360, -1.4047434233043994), (-2, -2, -5.047621777237812)] for theta, pitch, ft in theta_pitch: self.assertAlmostEqual( blade.get_tangential_force(wind_vector, rotor_speed, theta, pitch), ft, 7, 'tangent_line_angle')
def test_tangential_force(self): wind_direction = 0 wind_speed = 3 wind_vector = bc.get_wind_vector(wind_direction, wind_speed) # rotor_speed = 0.0001 rotor_speed = 3 # airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/naca0018_360' blade = vb.VawtBlade(0.2, airfoil_dir, 1) theta_pitch = [ (-1, 0.5, -0.70448212), (-2, 0, 0.252998783), (-1, 0, -0.13132965), (-2, -2, -6.32908050) ] for theta, pitch, ft in theta_pitch: self.assertAlmostEqual(blade.get_tangential_force(wind_vector, rotor_speed, theta, pitch), ft, 7, 'Wrong Ft calculation')
import vec import learn.airfoil_dynamics.ct_plot.vawt_blade as vb import math import learn.airfoil_dynamics.ct_plot.base_calculus as bc # plots tangential force in function of aoa and rotora blade theta wind_direction = 0 wind_speed = 3 wind_vector = bc.get_wind_vector(wind_direction, wind_speed) # rotor_speed = 0.0001 rotor_speed = 3 # airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/naca0018_360' blade = vb.VawtBlade(0.2, airfoil_dir, 1) theta_range = [x * math.tau / 360 for x in range(-180, 180, 5)] pitch_range = [x * math.tau / 360 for x in range(-180, 180, 5)] # theta_range = [x*math.tau/360 for x in range(-180, 179, 5)] # theta_range = [x*math.tau/360 for x in range(-540, 540, 10)] # pitch_range = [x*math.tau/360 for x in range(-180, 179, 5)] # pitch_range = [x*math.tau/360 for x in range(-90, 90, 5)] # pitch_range = [x*math.tau/360 for x in range(-20, 20, 1)] # pitch_range = [x*math.tau/360 for x in range(-60, 60, 1)] # theta_range = [x for x in range(0, 10, 1)] # pitch_range = [x for x in range(-8, 7, 1)] thetas = []
import pandas as pd import numpy as np import matplotlib.pyplot as plt import vec import learn.airfoil_dynamics.ct_plot.vawt_blade as vb import math wind_vector = vec.Vector2(r=3, theta=0) # rotor_speed = 0.0001 rotor_speed = 0.0001 cp10_airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/cp10_360' naca0018_airfoil_dir = '/home/aa/vawt_env/learn/AeroDyn polars/naca0018_360' cp10_blade = vb.VawtBlade(0.2, cp10_airfoil_dir, 1) naca0018_blade = vb.VawtBlade(0.2, naca0018_airfoil_dir, 1) theta_range = [x * math.tau / 360 for x in range(-180, 180, 10)] # theta_range = [vec.normalize_angle(theta) for theta in theta_range] pitch_range = [x * math.tau / 360 for x in range(-90, 90, 10)] # pitch_range = [x*math.tau/360 for x in range(-30, 30, 1)] # theta_range = [x for x in range(0, 10, 1)] # pitch_range = [x for x in range(-8, 7, 1)] thetas = [] for theta in theta_range: theta_ct_polar = [ cp10_blade.get_tangential_force(wind_vector, rotor_speed, theta, pitch) for pitch in pitch_range ] thetas.append(theta_ct_polar)