Code covered by the BSD License

### Highlights fromHow Computer Models Help Break Records?

from How Computer Models Help Break Records? by Coorous Mohtadi
Article on use of MATLAB to build a simplified model of the BLOODHOUND Super Sonic Car.

Bloodhound
```classdef Bloodhound
% Simplified Bloodhound model for examination of performance of the car
% Copyright 2012 - 2012 The MathWorks Inc.

properties
Rocket;                  % Rocket Properties
Jet;                     % Jet Properties
Drag;                    % Drag Parameters
RollResistance;          % RollResistance Parameters
AirBrake;                % Air Brake Parameters
InitialMass;             % kg      - Initial Mass of the Bloodhound car
Mass    ;                % kg      - Calculated Mass of the Bloodhound car
MeasuredMileStart ;      % - Distance at which the measured mile starts
MeasuredMileStop  ;      % - Distance where the measured mile ends
Thrust;                  % Newtons - Thrust of the Jet & Rocket
Decel;                   %         - Deceleration started
Position;                % m       - Bloodhound Position in metres
Velocity;                % Velocity- Bloodhound Velocity in metres
ElapsedTime;
end

methods
function obj=Bloodhound()
obj.Rocket.maxThrust    = 122000;   % Newtons - Maximum Thrust of the Hybrid Rocket
obj.Rocket.firingtime   = 11;       % Seconds - Time to fire the rocket
obj.Rocket.massflow     = 45;       % kg/s    - Approximate fuel usage of the rocket
obj.Rocket.duration     = 25;       % Seconds - Total duration of the rocket

obj.Jet.maxThrust       = 90000;    % Newtons - Maximum Thrust of the EJ200 jet
obj.Jet.massflow        = 5;        % kg/s    - Approximate fuel usage of the jet

obj.Drag.Coefficient    = 0.7;      % DimLess - Cd coefficient of aerodynamic drag
obj.Drag.Area           = 1.937;    % m^2     - Incident area for drag calculation
obj.Drag.Density        = 1.2;      % kg/m^3  - Air density
obj.Drag.Force          = 0;        % Newtons - Calculated Drag Force

obj.RollResistance.Coefficient= 0.4;% DimLess - Roll Resistance Coefficient
obj.RollResistance.Force= 0;        % Newtons - Calculated Roll Resistance Force

obj.InitialMass = 6500;  % kg      - Initial Mass of the Bloodhound car
obj.Mass     = 0;        % kg      - Calculated Mass of the Bloodhound car

obj.AirBrake.Activation = 0.7;%    - Mach no at which the Airbrake is activated
obj.AirBrake.Coefficient= 1.0;%    - Coefficient of the effect of the Airbrake
obj.MeasuredMileStart = 4.5*1609;% - Distance at which the measured mile starts
obj.MeasuredMileStop  = 5.5*1609;% - Distance where the measured mile ends
obj.Decel = false;       %         - Deceleration started
obj.Position=0;          % m       - Bloodhound Position in metres
obj.Velocity=0;          % Velocity- Bloodhound Velocity in metres
obj.ElapsedTime = 0;     % s       - Elapsed time since start of the mission
obj.Thrust = 0;
end

function [MassVal] = computeMass(obj)
% Mass is assumed to be linearly decreasing with time.
% Mass = InitialMass - Time x Rate
% Rate is set to
%   5 kg/s when the Jet is on
%   50kg/s when the Jet and the Rocket are on
%   0 when the car is decelerating.

Time = obj.ElapsedTime;
if ~obj.Decel,
if Time < obj.Rocket.firingtime,
MassVal= obj.InitialMass - Time*obj.Jet.massflow;
else
MassVal= obj.InitialMass - obj.Rocket.firingtime * obj.Jet.massflow ...
- (obj.Jet.massflow+obj.Rocket.massflow)*(Time - obj.Rocket.firingtime);
end
else
MassVal = obj.Mass;
end
return
end

function Drag = computeDrag(obj)
% AeroDrag = 0.5 * Cd * Density  * Area * Velocity ^2
% RollResistance = Mass * g * Coefficient of Resistance
% Drag = AeroDrag + Roll Resistance;
% AirBrake = AirBrakeGain * Velocity^2;

g = 9.81;           % m/s^2
SoundSpeed = 340;   % m/s
V= obj.Velocity;

AeroDrag = 0.5 * obj.Drag.Coefficient * obj.Drag.Density * ...
obj.Drag.Area * V^2;

RollResist = obj.Mass * g * obj.RollResistance.Coefficient;

AirBrakeForce = obj.Decel * obj.AirBrake.Coefficient * ...
V^2 * (V < obj.AirBrake.Activation*SoundSpeed);

Drag = AeroDrag + RollResist + AirBrakeForce;

return
end

function TotalThrust = computeThrust(obj)
% At the begining thrust is given by the Jet alone.
% Once the Rocket is fired we also have the additional thrust from the
% Rocket. Rocket can only operate for a limited time of around 24.5
% seconds. Both the jet and rocket are turned off once we go through the
% measured mile and deceleration begins.
%
Time = obj.ElapsedTime;
RocketStart = obj.Rocket.firingtime;
RocketEnd = RocketStart + obj.Rocket.duration;
if Time < RocketStart || Time > RocketEnd,
TotalThrust = obj.Jet.maxThrust;
else
TotalThrust = obj.Jet.maxThrust + obj.Rocket.maxThrust;
end
TotalThrust = TotalThrust* ~obj.Decel;
return
end

function [dv]=BloodhoundEQ(obj,t,v)
persistent MassVal;
obj.Velocity= v(1);                                  % Store new velocity
obj.Position = v(2);                                 % Store Position
obj.ElapsedTime = t;                                 % Elapsed time since start of mission
obj.Mass = MassVal;
obj.Decel = obj.Position > ...                       % Start Deceleration after the measured mile
obj.MeasuredMileStop;
ThrustVal = computeThrust(obj);                      % Compute the Thrust from the Jet and the Rocket
MassVal   = computeMass(obj);                        % Compute the Mass of the car
obj.Drag.Force = computeDrag(obj);                   % Compute the Drag and Braking forces
dv =[(ThrustVal - obj.Drag.Force)/MassVal;v(1)];     % Newton's 2nd law of motion
% Speed of the car
return
end

end

end

```