summaryrefslogtreecommitdiff
path: root/creator/wing.py
diff options
context:
space:
mode:
Diffstat (limited to 'creator/wing.py')
-rw-r--r--creator/wing.py50
1 files changed, 24 insertions, 26 deletions
diff --git a/creator/wing.py b/creator/wing.py
index 8178366..59f5bbe 100644
--- a/creator/wing.py
+++ b/creator/wing.py
@@ -11,14 +11,15 @@ Functions:
plot_geom(airfoil): generates a 2D plot of the airfoil & any components.
"""
-import creator.base as base
-
import logging
import numpy as np
from math import sin, cos, atan
import bisect as bi
import matplotlib.pyplot as plt
+import creator.base as base
+import resources.materials as mt
+
class Airfoil(base.Component):
"""This class represents a single NACA airfoil.
@@ -32,23 +33,20 @@ class Airfoil(base.Component):
to 3D CAD packages like SolidWorks, which can import such
geometry as coordinates written in a CSV file.
"""
-
- # TODO: default values in separate module
- def __init__(self, chord, semi_span, material):
- super().__init__()
- # self.x = np.array([])
- # self.z = np.array([])
- # self.chord = chord
- """Create airfoil from its chord and semi-span."""
- self.chord = chord if chord > 20 else 20
- if chord <= 20:
+ def __init__(self,
+ parent,
+ name,
+ chord=68,
+ semi_span=150,
+ material=mt.aluminium):
+ super().__init__(parent, name)
+ if chord > 20:
+ self.chord = chord
+ else:
+ self.chord = 20
logging.debug('Chord too small, using minimum value of 20.')
self.semi_span = semi_span
self.material = material
- self.naca_num = int()
-
- def __str__(self):
- return type(self).__name__
def add_naca(self, naca_num):
"""Generate surface geometry for a NACA airfoil.
@@ -138,22 +136,22 @@ class Airfoil(base.Component):
class Spar(base.Component):
"""Contains a single spar's data."""
- def __init__(self, airfoil, loc_percent, material):
+ def __init__(self, parent, name, loc_percent=0.30, material=mt.aluminium):
"""Set spar location as percent of chord length."""
- super().__init__()
+ super().__init__(parent, name)
super().set_material(material)
self.cap_area = float()
- loc = loc_percent * airfoil.chord
- # bi.bisect_left: returns index of first value in airfoil.x > loc
+ loc = loc_percent * parent.chord
+ # bi.bisect_left: returns index of first value in parent.x > loc
# This ensures that spar geom intersects with airfoil geom.
# Spar upper coordinates
- spar_u = bi.bisect_left(airfoil.x, loc) - 1
- self.x = np.append(self.x, airfoil.x[spar_u])
- self.z = np.append(self.z, airfoil.z[spar_u])
+ spar_u = bi.bisect_left(parent.x, loc) - 1
+ self.x = np.append(self.x, parent.x[spar_u])
+ self.z = np.append(self.z, parent.z[spar_u])
# Spar lower coordinates
- spar_l = bi.bisect_left(airfoil.x[::-1], loc)
- self.x = np.append(self.x, airfoil.x[-spar_l])
- self.z = np.append(self.z, airfoil.z[-spar_l])
+ spar_l = bi.bisect_left(parent.x[::-1], loc)
+ self.x = np.append(self.x, parent.x[-spar_l])
+ self.z = np.append(self.z, parent.z[-spar_l])
return None
def set_cap_area(self, cap_area):
Copyright 2019--2024 Marius PETER