diff options
| author | sam-anthony <samanthony6@protonmail.com> | 2022-03-26 19:39:39 -0230 |
|---|---|---|
| committer | sam-anthony <samanthony6@protonmail.com> | 2022-03-26 19:39:39 -0230 |
| commit | 722ab14ee5c2bc70b880c4dec74d1b546ae144b2 (patch) | |
| tree | 243b8e4fc2327b4ad1269a2761b23454d681bd29 /main.go | |
| parent | 42f2f6419bbff03931654e52a885b0600eec9b9b (diff) | |
| download | volute-722ab14ee5c2bc70b880c4dec74d1b546ae144b2.zip | |
mass flow rate
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 47 |
1 files changed, 45 insertions, 2 deletions
@@ -4,10 +4,16 @@ import ( "fmt" g "github.com/AllenDang/giu" "os" + "time" ) -// numPoints is the number of datapoints on the compressor map. -const numPoints = 6 +const ( + // numPoints is the number of datapoints on the compressor map. + numPoints = 6 + + gasConstant = 8.314472 + airMolarMass = 0.0289647 // kg/mol +) func check(err error) { if err != nil { @@ -69,6 +75,42 @@ func init() { } } +var ( + engineMassFlowRate [numPoints]massFlowRate + + // selectedMassFlowRateUnit is used to index massFlowRateUnitStrings. + selectedMassFlowRateUnit = defaultMassFlowRateUnitIndex +) + +func massFlowRateAt(point int) massFlowRate { + rpm := float32(engineSpeed[point]) + disp := displacement.asUnit(cubicMetre) + ve := float32(volumetricEfficiency[point]) / 100.0 + cubicMetresPerMin := (rpm / 2.0) * disp * ve + + iat, err := intakeAirTemperature[point].asUnit(kelvin) + check(err) + pres := manifoldPressure[point].asUnit(pascal) + molsPerMin := (pres * cubicMetresPerMin) / (gasConstant * iat) + + kgPerMin := molsPerMin * airMolarMass + + massPerMin := mass{kgPerMin, kilogram} + + u, err := massFlowRateUnitFromString(massFlowRateUnitStrings()[selectedMassFlowRateUnit]) + check(err) + + mfr, err := newMassFlowRate(massPerMin, time.Minute, u) + check(err) + return mfr +} + +func init() { + for i := 0; i < numPoints; i++ { + engineMassFlowRate[i] = massFlowRateAt(i) + } +} + func loop() { g.SingleWindow().Layout( engineDisplacementRow(), @@ -79,6 +121,7 @@ func loop() { intakeAirTemperatureRow(), manifoldPressureRow(), pressureRatioRow(), + massFlowRateRow(), ). Columns( g.TableColumn("Parameter"), |