-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
604 additions
and
68 deletions.
There are no files selected for viewing
294 changes: 294 additions & 0 deletions
294
sysml/src/examples/Analysis Examples/Vehicle Analysis Demo.sysml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...g/08. Connectors/Connectors Example.sysml → ...09. Connections/Connections Example.sysml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.