Skip to content

Commit

Permalink
Updated training material.
Browse files Browse the repository at this point in the history
  • Loading branch information
seidewitz committed Jul 14, 2020
1 parent c329c1c commit 1bb61d3
Show file tree
Hide file tree
Showing 58 changed files with 604 additions and 68 deletions.
294 changes: 294 additions & 0 deletions sysml/src/examples/Analysis Examples/Vehicle Analysis Demo.sysml
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
package 'Vehicle Analysis Demo' {
package VehicleQuantities {
import ScalarValues::*;
import Quantities::*;
import UnitsAndScales::*;
import ISQ::*;
import USCustomaryUnits::*;

attribute def VolumeUnit :> SIDerivedUnit {
:>> lengthPowerFactor { :>> exponent = 3; }
}
attribute def VolumeValue :> QuantityValue {
:>> num : Real;
:>> mRef : VolumeUnit;
}

attribute def PowerUnit :> SIDerivedUnit {
:>> massPowerFactor { :>> exponent = 1; }
:>> lengthPowerFactor { :>> exponent = 2; }
:>> timePowerFactor { :>> exponent = -3; }
}
attribute def PowerValue :> QuantityValue {
:>> num : Real;
:>> mRef : PowerUnit;
}

attribute def DistancePerVolumeUnit :> SIDerivedUnit {
:>> lengthPowerFactor { :>> exponent = -2; }
}
attribute def DistancePerVolumeValue :> QuantityValue {
:>> num : Real;
:>> mRef : DistancePerVolumeUnit;
}

attribute gallon : VolumeUnit = 231.0 * 'in' ** 3;
attribute mpg : DistancePerVolumeUnit = 'mi' / gallon;
}

package VehicleModel {
import VehicleQuantities::*;

item def Fuel;

port def FuelPort {
out item fuel: Fuel;
}

part def FuelTank {
attribute volumeMax : VolumeValue;
attribute fuelVolume : VolumeValue;
attribute fuelLevel : Real = fuelVolume / volumeMax;

port fuelInPort : ~FuelPort;
port fuelOutPort : FuelPort;
}

part def Wheel {
attribute diameter : LengthValue;
}

part def Vehicle {
attribute mass : MassValue;
attribute cargoMass : MassValue;

attribute wheelDiameter : LengthValue;
attribute driveTrainEfficiency : Real;

attribute fuelEconomy_city : DistancePerVolumeValue;
attribute fuelEconomy_highway : DistancePerVolumeValue;

port fuelInPort : ~FuelPort;
}

part vehicle_c1 : Vehicle {
port :>> fuelInPort {
in item :>> fuel;
}

part fuelTank : FuelTank {
port :>> fuelInPort {
in item :>> fuel;
}
}

bind fuelInPort::fuel = fuelTank::fuelInPort::fuel;

part wheel : Wheel[4] {
:>> diameter = wheelDiameter;
}
}
}

package FuelEconomyRequirementsModel {
import VehicleQuantities::*;

requirement def FuelEconomyRequirement {
attribute actualFuelEconomy : DistancePerVolumeValue;
attribute requiredFuelEconomy : DistancePerVolumeValue;

require constraint { actualFuelEconomy >= requiredFuelEconomy }
}

requirement cityFuelEconomyRequirement : FuelEconomyRequirement {
:>> requiredFuelEconomy = 25@[mpg];
}

requirement highwayFuelEconomyRequirement : FuelEconomyRequirement {
:>> requiredFuelEconomy = 30@[mpg];
}
}

package DynamicsModel {
import VehicleQuantities::*;

calc def Acceleration(p : PowerValue, m : MassValue, v : SpeedValue) : AccelerationValue =
p / (m * v);

calc def Velocity(v0 : SpeedValue, a : AccelerationValue, dt : TimeValue) : SpeedValue =
v0 + a * dt;

calc def Position(x0 : LengthValue, v : SpeedValue, dt : TimeValue) : LengthValue =
x0 + v * dt;

constraint def StraightLineDynamicsEquations(
p : PowerValue,
m : MassValue,
dt : TimeValue,
x_i : LengthValue,
v_i : SpeedValue,
x_f : LengthValue,
v_f : SpeedValue,
a : AccelerationValue
) {
attribute v_avg : SpeedValue = (v_i + v_f)/2;

a == Acceleration(p, m, v_avg) &
v_f == Velocity(v_i, a, dt) &
x_f == Position(x_i, v_avg, dt)
}

action def StraightLineDynamics (
in power : PowerValue,
in mass : MassValue,
in delta_t : TimeValue,
in x_in : LengthValue,
in v_in : SpeedValue,
out x_out : LengthValue,
out v_out : SpeedValue,
out a_out : AccelerationValue
) {
assert constraint dynamics : StraightLineDynamicsEquations (
p = power,
m = mass,
dt = delta_t,
x_i = x_in,
v_i = v_in,
x_f = x_out,
v_f = v_out,
a = a_out
);
}
}

package FuelEconomyAnalysisModel {
import VehicleModel::*;
import FuelEconomyRequirementsModel::*;
import DynamicsModel::*;
import BaseFunctions::size;
import NonScalarValues::SampledFunctionValue;

attribute def ScenarioState {
position : LengthValue;
velocity : SpeedValue;
}

attribute def NominalScenario :> SampledFunctionValue {
t : TimeValue[*] :>> domain;
s : ScenarioState[*] :>> range;
n : Natural = size(t);
}

analysis def FuelEconomyAnalysis (vehicle : Vehicle) calculatedFuelEconomy : DistancePerVolumeValue {
in attribute scenario : NominalScenario;
in ref requirement fuelEconomyRequirement : FuelEconomyRequirement;

objective fuelEconomyAnalysisObjective {
/*
* The objective of this analysis is to determine whether the
* current vehicle design configuration can satisfy the fuel
* economy requirement.
*/

assume constraint {
vehicle::wheelDiameter == 33@['in'] &
vehicle::driveTrainEfficiency == 0.4
}

require fuelEconomyRequirement {
:>> actualFuelEconomy = calculatedFuelEconomy;
}
}

import scenario::*;

action dynamicsAnalysis(
out power : PowerValue[*],
out acceleration : AccelerationValue[*]
) {
/*
* Solve for the required engine power as a function of time
* to support the scenarios.
*/
assert constraint {
{1..n-1}->forAll i (
StraightLineDynamicsEquations (
p => power[i],
m => vehicle::mass,
dt => t[i+1] - t[i],
x_i => s.position[i],
v_i => s.velocity[i],
x_f => s.position[i+1],
v_f => s.velocity[i+1],
a => acceleration[i]
)
)
}
}

action fuelConsumptionAnalysis(
in power : PowerValue[*] = dynamicsAnalysis::power,
in acceleration : AccelerationValue[*] = dynamicsAnalysis::acceleration,
out fuelEconomy : DistancePerVolumeValue = calculatedFuelEconomy
) {
/*
* Solve the engine equations to determine how much fuel is
* consumed. The engine RPM is a function of the speed of the
* vehicle and the gear state.
*/
}
}
}


part vehicleFuelEconomyAnalysisContext {
import FuelEconomyAnalysisModel::*;

requirement vehicleFuelEconomyRequirementsGroup (vehicle : Vehicle) {
import FuelEconomyRequirementsModel::*;

requirement vehicleFuelEconomyRequirement_city :> cityFuelEconomyRequirement {
/* The vehicle shall provide a fuel economy that is greater than or equal to
* 25 miles per gallon for the nominal city driving scenarios.
*/

:>> actualFuelEconomy = vehicle::fuelEconomy_city;

assume constraint { vehicle::cargoMass == 1000@[lb] }
}

requirement vehicleFuelEconomyRequirement_highway :> highwayFuelEconomyRequirement {
/* The vehicle shall provide a fuel economy that is greater than or equal to
* 30 miles per gallon for the nominal highway driving scenarios.
*/

:>> actualFuelEconomy = vehicle::fuelEconomy_highway;

assume constraint { vehicle::cargoMass == 1000@[lb] }
}

}

attribute cityScenario : NominalScenario;
attribute highwayScenario : NominalScenario;

analysis cityFuelEconomyAnalysis : FuelEconomyAnalysis {
part :>> vehicle = vehicle_c1;
attribute :>> scenario = cityScenario;
requirement :>> fuelEconomyRequirement = cityFuelEconomyRequirement;
} cityFuelEconomy;

analysis highwayFuelEconomyAnalysis : FuelEconomyAnalysis {
part :>> vehicle = vehicle_c1;
attribute :>> scenario = highwayScenario;
requirement :>> fuelEconomyRequirement = highwayFuelEconomyRequirement;
} highwayFuelEconomy;

part vehicle_c1_analysized :> vehicle_c1 {
attribute :>> fuelEconomy_city = cityFuelEconomy;
attribute :>> fuelEconomy_highway = highwayFuelEconomy;
}

satisfy vehicleFuelEconomyRequirementsGroup by vehicle_c1_analysized;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package 'Part Definition Example' {

part eng : Engine;

ref driver : Person;
ref part driver : Person;
}

attribute def VehicleStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package 'Generalization Example' {
abstract part def Vehicle;

part def HumanDrivenVehicle specializes Vehicle {
ref driver : Person;
ref part driver : Person;
}

part def PoweredVehicle :> Vehicle {
Expand Down
17 changes: 17 additions & 0 deletions sysml/src/training/07. Items/Items Example.sysml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package 'Items Example' {
import ScalarValues::*;

item def Fuel;
item def Person;

part def Vehicle {
attribute mass : Real;

ref item driver : Person;

part fuelTank {
item fuel: Fuel;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package 'Connectors Example' {
package 'Connections Example' {

part def WheelHubAssembly;
part def WheelAssembly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package 'Port Conjugation Example' {

port def FuelPort {
attribute temperature : Temp;
out ref fuelSupply : Fuel;
in ref fuelReturn : Fuel;
out ref item fuelSupply : Fuel;
in ref item fuelReturn : Fuel;
}

part def FuelTank {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ package 'Port Example' {

port def FuelOutPort {
attribute temperature : Temp;
out ref fuelSupply : Fuel;
in ref fuelReturn : Fuel;
out ref item fuelSupply : Fuel;
in ref item fuelReturn : Fuel;
}

port def FuelInPort {
attribute temperature : Temp;
out ref fuelSupply : Fuel;
in ref fuelReturn : Fuel;
out ref item fuelSupply : Fuel;
in ref item fuelReturn : Fuel;
}

part def FuelTankAssembly {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ package 'Binding Connectors Example-1' {
part vehicle : Vehicle {
part tank : FuelTankAssembly {
port redefines fuelTankPort {
out ref redefines fuelSupply;
in ref redefines fuelReturn;
out ref item redefines fuelSupply;
in ref item redefines fuelReturn;
}

bind fuelTankPort::fuelSupply = pump::pumpOut;
bind fuelTankPort::fuelReturn = tank::fuelIn;

part pump : FuelPump {
out ref pumpOut : Fuel;
in ref pumpIn : Fuel;
out ref item pumpOut : Fuel;
in ref item pumpIn : Fuel;
}

part tank : FuelTank {
out ref fuelOut : Fuel;
in ref fuelIn : Fuel;
out ref item fuelOut : Fuel;
in ref item fuelIn : Fuel;
}
}
}
Expand Down
Loading

0 comments on commit 1bb61d3

Please sign in to comment.