Example 2: Vector inputΒΆ

This example shows how to use the JARUS model with a vector input to generate a vector output. Using this feature it is possible to generate graphs for variations on one input parameter without resorting to a loop.

This example shows this for the following parameters:

  • width

  • impact angle

  • impact speed

  • lethal area overlap

  • fuel quantity

  • friction coefficient

We begin with setup, which was also done in example 1.

# Instantiate necessary classes.
FC = FrictionCoefficients()
CA = CriticalAreaModels()

# Set aircraft values.
aircraft_type = enums.AircraftType.FIXED_WING
width = 4
mass = 25
friction_coefficient = FC.get_coefficient(enums.AircraftMaterial.ALUMINUM,
                                          enums.GroundMaterial.CONCRETE)

# Instantiate and add data to AircraftSpecs class.
aircraft = AircraftSpecs(aircraft_type, width, mass)
aircraft.set_fuel_type(enums.FuelType.GASOLINE)
aircraft.set_fuel_quantity(5)
aircraft.set_friction_coefficient(friction_coefficient)

# Set impact speed and angle.
impact_speed = 50
impact_angle = 25

First, we set the width to an array instead of a scalar. Here we choose the width to vary from 1 to 5 meters over 100 steps. The input is set via the aircraft class. We collect the result in the p array.

v_width = np.linspace(1, 5, 100)
aircraft.set_width(v_width)
p.append(CA.critical_area(aircraft, impact_speed, impact_angle))

The we set the impact speed as a vector. Since only one parameters at a time can be a vector input, we reset the width to a scalar value.

v_impact_angle = np.linspace(10, 80, 100)
aircraft.set_width(width)
p.append(CA.critical_area(aircraft, impact_speed, v_impact_angle))

Since the impact angle is not set through the aircraft class, but directly as an input to critical_area, we do not need to reset the impact angle. We simply use the original variable impact_angle. And we set the impact speed to be an array.

v_impact_speed = np.linspace(5, 40, 100)
p.append(CA.critical_area(aircraft, v_impact_speed, impact_angle))

We do the same with the critical area overlap.

v_critical_areas_overlap = np.linspace(0, 1, 100)
p.append(CA.critical_area(aircraft, impact_speed, impact_angle))

The fuel quantity is set as an array.

v_fuel_quantity = np.linspace(0, 10, 100)
aircraft.set_fuel_quantity(v_fuel_quantity)
p.append(CA.critical_area(aircraft, impact_speed, impact_angle))

We can also set the friction coefficient as an array.

aircraft.set_fuel_quantity(5)
v_friction_coefficient = np.linspace(0.2, 0.9, 100)
aircraft.set_friction_coefficient(v_friction_coefficient)
p.append(CA.critical_area(aircraft, impact_speed, impact_angle))

Finally, we plot all the outputs.

../_images/example_2.png