peterdsharpe / AeroSandbox

Aircraft design optimization made fast through modern automatic differentiation. Composable analysis tools for aerodynamics, propulsion, structures, trajectory design, and much more.
https://peterdsharpe.github.io/AeroSandbox/
MIT License
687 stars 111 forks source link

AeroSandbox use for aero/hydrostructural model #67

Closed cdhainaut closed 2 years ago

cdhainaut commented 2 years ago

Hi all,

First thank you for this great package. I am used to use various lifting lines or VLM programs such as AVL and the integrated optimization feature looks really cool to use. I have a few questions related to the usage of aerosandbox for mainly two things:

  1. Modelling ground effect / freesurface Is there a possibility within aerosandbox to include symmetry/anti symmetry planes ? This kind of feature can be included in AVL for instance, which enables me to estimate the influence of the freesurface (constant pressure i.e zero lift boundary) an hydrofoil
  2. Doing aeroelastic loops I checked the example "simple_beam_opt.py" in aerosandbox/structures which gives somes insights about how to evaluate deformation on a wing. However, Its not clear to me how to integrate this into a loop with lifting line/VLM fluid calculations. I tried to recycle this script imagining how it could be integrated in a loop, but its not clear to me how to get the result coming from aero model to the structural problem:
    
    import aerosandbox.numpy as np
    import casadi as cas
    from aerosandbox import *

loops = 2

def trapz(x): out = (x[:-1] + x[1:]) / 2 out[0] += x[0] / 2 out[-1] += x[-1] / 2 return out

Constants

E = 228e9 # Pa, modulus of CF I = 1e4 EI = E*I n_sections = 6 n_panels_per_section = 4

n = n_sections + 1

x_les_ini = cas.linspace(0,-0.25,n) # og one this one y_les_ini = cas.linspace(0, 1, n) z_les_ini = cas.linspace(0,0.5,n) chords = cas.linspace(1,1,n) dx = np.zeros(n) dy = np.zeros(n) dz = np.zeros(n) for i in range(loops): opti = cas.Opti()

x_les = x_les_ini + dx
y_les = y_les_ini + dy
z_les = z_les_ini + dz

airplane = Airplane(
    name="Spanload Optimization Test",
    x_ref=0,  # CG location
    y_ref=0,  # CG location
    z_ref=0,  # CG location
    fuselages=[],
    wings=[
        Wing(
            name="Main Wing",
            x_le=0,  # Coordinates of the wing's leading edge
            y_le=0,  # Coordinates of the wing's leading edge
            z_le=0,  # Coordinates of the wing's leading edge
            symmetric=True,
            xsecs=[
                WingXSec(
                    x_le=x_les[i],
                    y_le=y_les[i],
                    z_le=z_les[i],
                    chord=chords[i],  # variable(1,0.01,2),
                    airfoil=generic_airfoil,
                    spanwise_spacing="uniform"
                )
                for i in range(n)
            ],
        ),
    ]
)

ap = Casll1(  # Set up the AeroProblem
    airplane=airplane,
    op_point=OperatingPoint(
        velocity=100,
        alpha=2,
        beta=0,
        p=0,
        q=0,
        r=0,
    )
)

# Defining derivatives
u = 1 * opti.variable(n)
du = 0.1 * opti.variable(n)
ddu = 0.01 * opti.variable(n)
dEIddu = 100 * opti.variable(n)
ddEIddu = ap.solve.get_lift_distribution() # i know this is not existing, but its just to give an example

opti.subject_to([
    cas.diff(u) == trapz(du) * dx,
    cas.diff(du) == trapz(ddu) * dx,
    cas.diff(EI * ddu) == trapz(dEIddu) * dx,
    cas.diff(dEIddu) == trapz(ddEIddu) * dx
])

# Add BCs
opti.subject_to([
    u[0] == 0,
    du[0] == 0,
    ddu[-1] == 0,  # No tip moment
    dEIddu[-1] == 0
])

# dx = ? 
# dy = ?
# dz = ?


Thanks