Aircraft

The aircraft: the disciplines that describe an airframe, and the routing between them.

An Aircraft is a composition of discipline objects, not a bag of numbers. Given the parameters a case file declares, it hands each one to the discipline that owns it and refuses any that no discipline owns or that two would claim. What comes out is an object where aircraft["geometry"].value("ac|geom|wing|S_ref") is the question you ask, rather than a flat dictionary where a wing area and a cabin pressure sit side by side.

Routing is the point. It is what makes the ownership map testable: if the black box publishes a settable variable that no discipline claims, building an aircraft that sets it fails by name, and a contract test walks the box’s whole settable set to prove that never happens silently.

class cdadt.aircraft.Aircraft(parameters, disciplines=(<class 'cdadt.disciplines.geometry.Geometry'>, <class 'cdadt.disciplines.aerodynamics.Aerodynamics'>, <class 'cdadt.disciplines.propulsion.Propulsion'>, <class 'cdadt.disciplines.stability.Stability'>, <class 'cdadt.disciplines.structures.Structures'>, <class 'cdadt.disciplines.weights.Weights'>))[source]

Bases: object

One airframe, described by its disciplines.

Parameters:
  • parameters (sequence of Parameter) – The design parameters to route. Every one must be owned by exactly one discipline.

  • disciplines (sequence of type, optional) – Discipline classes to compose. Default AIRCRAFT_DISCIPLINES. Passing a different set is how a study adds a domain: subclass Discipline, declare what it owns and reports, and include it here.

Raises:

AircraftError – If a parameter is owned by no discipline or by more than one, or if two disciplines share a name.

Examples

>>> aircraft = Aircraft([Parameter("ac|geom|wing|AR", 9.45)])
>>> aircraft["geometry"].value("ac|geom|wing|AR")
9.45
>>> aircraft.owner("ac|geom|wing|AR").discipline_name
'geometry'
owner(variable)[source]

Return the discipline that owns variable.

Raises:

AircraftError – If none does, or more than one does.

Parameters:

variable (str)

Return type:

Discipline

unowned(variables)[source]

Return the members of variables that no discipline owns.

Used by the contract test that walks every settable variable of the black box: an input cdadt can set but no discipline claims is a gap in the model of the interface, whether or not any case file happens to set it.

Parameters:

variables (Sequence[str])

Return type:

tuple[str, …]

property disciplines: Mapping[str, Discipline]

Return the disciplines, keyed by name, in composition order.

property parameters: dict[str, Parameter]

Return every held parameter, flattened, keyed by variable name.

value(variable)[source]

Return the value of one parameter, wherever it lives.

Parameters:

variable (str)

Return type:

float

set(variable, value)[source]

Set the value of one parameter, in its existing units.

Parameters:
  • variable (str)

  • value (float)

Return type:

None

apply(box)[source]

Write every parameter of every discipline into the black box.

Parameters:

box (Any)

Return type:

None

collect(box)[source]

Read every discipline’s responses back out of the black box.

Returns:

dictdiscipline name -> {response name -> value}.

Parameters:

box (Any)

Return type:

dict[str, dict[str, Any]]

missing(box)[source]

Return, per discipline, the optional responses this black box does not publish.

Parameters:

box (Any)

Return type:

dict[str, tuple[str, …]]

exception cdadt.aircraft.AircraftError[source]

Bases: Exception

Raised when a parameter cannot be routed to exactly one discipline.