Skip to content
This repository has been archived by the owner on Mar 14, 2021. It is now read-only.

AC: struct refactor #26

Open
AlexS12 opened this issue Jan 6, 2019 · 0 comments
Open

AC: struct refactor #26

AlexS12 opened this issue Jan 6, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@AlexS12
Copy link
Owner

AlexS12 commented Jan 6, 2019

Current situation
Currently, each aircraft implements its own structure as it is a mean to dispatch the adequate method for functions like: get_arp, get_empty_cg, get_fuel_tanks... This is nonsense because:

  • some of this methods need to be called before or during the aircraft object construction (see ugly workarounds in: C310() and F16())
  • even there is a struct for each aircraft, they share the same attributes
  • some ac variables are stored in methods to benefit from constant propagation (http://www.stochasticlifestyle.com/type-dispatch-design-post-object-oriented-programming-julia/) but this prevents from making variations in these parameters (ie. empty cg position is changed in many F16 validation examples)

Objective

  • Create a unique struct to be shared by every aircraft
  • Separate aircraft parameters in a different struct that will be part of the aircraft object.
    • These parameters struct can be specific to each aircraft until a good generalization is found. However, a set of general methods to access common attributes must be provided.
    • For each aircraft a default configuration will be provided.

Solution proposal

abstract type Parameters end

get_name(p) = p.name
get_wing_area(p) = p.wing_area
get_wing_span(p) = p.b
get_chord(p) = p.mac
get_arp(p) = p.arp
struct Aircraft
    parameters::T where T<:Parameters
    mass_props::RigidSolid
    pfm::PointForcesMoments
    aerodynamics::T where T<:Aerodynamics
    propulsion::Propulsion
end
F16(params, mass_props, pfm, aero, prop) = Aircraft(params, mass_props, pfm, aero, prop)

function F16()
    # default initialization of params, mass_props, pfm, aero, prop
    # ...
    Aircraft(params, mass_props, pfm, aero, prop)
end

Concerns
This will not benefit from constant propagation anymore.

@AlexS12 AlexS12 added the enhancement New feature or request label Jan 6, 2019
This was referenced Jan 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant