summaryrefslogtreecommitdiff
path: root/main.py
blob: acaf77477310402be1fe434b1d4512c13fd52943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# This file is part of Marius Peter's airfoil analysis package (this program).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.


import creator  # Create geometry
import evaluator  # Evaluate geometry
import generator  # Iteratevely evaluate instances of geometry and optimize
import random

import time
start_time = time.time()

# Airfoil dimensions
NACA_NUM = 2412
CHORD_LENGTH = 40
SEMI_SPAN = 50

# Airfoil thickness
T_UPPER = 0.1
T_LOWER = 0.1

# Component masses
AIRFOIL_MASS = 10  # lbs
SPAR_MASS = 10  # lbs
STRINGER_MASS = 5  # lbs

# Area
SPAR_CAP_AREA = 0.3  # sqin
STRINGER_AREA = 0.1  # sqin

# Amount of stringers
TOP_STRINGERS = 7
BOTTOM_STRINGERS = 6
NOSE_TOP_STRINGERS = 4
NOSE_BOTTOM_STRINGERS = 5

# population information & save path
POP_SIZE = 1
SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save'


def main():
    '''
    Create an airfoil;
    Evaluate an airfoil;
    Generate a population of airfoils & optimize.
    '''

    # Create coordinate system specific to our airfoil dimensions.
    # TODO: imperial + metric unit setting
    creator.Coordinates(CHORD_LENGTH, SEMI_SPAN)

    # Interate through all wings in population, creating and evaluating them.
    for _ in range(1, POP_SIZE + 1):

        # Create airfoil instance
        af = creator.Airfoil()
        # Define NACA airfoil coordinates and mass
        af.add_naca(NACA_NUM)
        af.add_mass(AIRFOIL_MASS)
        # af.info_print(2)
        # af.info_save(SAVE_PATH, _)

        # Create spar instance
        af.spar = creator.Spar()
        # Define the spar coordinates and mass, stored in single spar object
        af.spar.add_coord(af, 0.15)
        af.spar.add_coord(af, 0.55)
        # Automatically adds spar caps for all spars previously defined
        af.spar.add_spar_caps(SPAR_CAP_AREA)
        af.spar.add_mass(SPAR_MASS)
        # af.spar.info_print(2)
        # af.spar.info_save(SAVE_PATH, _)

        # Create stringer instance
        af.stringer = creator.Stringer()
        # Compute the stringer coordinates from their quantity in each zone
        af.stringer.add_coord(af,
                              NOSE_TOP_STRINGERS,
                              TOP_STRINGERS,
                              NOSE_BOTTOM_STRINGERS,
                              BOTTOM_STRINGERS)
        af.stringer.add_area(STRINGER_AREA)
        af.stringer.add_mass(STRINGER_MASS)
        # af.stringer.info_print(2)
        # af.stringer.info_save(SAVE_PATH, _)

        # Plot components with matplotlib
        # creator.plot_geom(af)

        # Evaluator object contains airfoil analysis results.
        eval = evaluator.Evaluator(af)
        # The analysis is performed in the evaluator.py module.
        eval.analysis()
        # eval.info_print(2)
        eval.info_save(SAVE_PATH, _)
        evaluator.plot_geom(eval)
        # evaluator.plot_lift(eval)

    # Print final execution time
    print("--- %s seconds ---" % (time.time() - start_time))


if __name__ == '__main__':
    main()
Copyright 2019--2024 Marius PETER