diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-01-20 17:56:39 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-01-20 17:56:39 -0500 |
| commit | 3aaae870ba76d8f0907b10a61d829ad353936306 (patch) | |
| tree | 8be8cb950d0aa8039cd977c72e2f9438cae4a1e8 /main.go | |
| parent | db183cf7570e0f4e448ab5ced0ae41969261a815 (diff) | |
| download | volute-3aaae870ba76d8f0907b10a61d829ad353936306.zip | |
flatten source directory structure by removing modules
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 64 |
1 files changed, 27 insertions, 37 deletions
@@ -7,13 +7,6 @@ import ( "image/draw" _ "image/jpeg" "os" - - "volute/compressor" - "volute/mass" - "volute/pressure" - "volute/temperature" - "volute/util" - "volute/volume" ) const ( @@ -21,33 +14,31 @@ const ( airMolarMass = 0.0289647 // kg/mol ) -// numPoints is the number of datapoints on the compressor map. +// Number of data points on the compressor map. var numPoints = 1 var ( - displacement = 2000 * volume.CubicCentimetre - // volumeUnitIndex is used to index volume.UnitStrings(). - volumeUnitIndex = volume.DefaultUnitIndex + displacement = 2000 * CubicCentimetre + volumeUnitIndex int32 - engineSpeed = []int32{2000} + // Angular crankshaft speed in RPM. + speed = []int32{2000} volumetricEfficiency = []int32{80} - intakeAirTemperature = []temperature.Temperature{{25, temperature.Celcius}} - // temperatureUnitIndex is used to index temperature.UnitStrings(). - temperatureUnitIndex = temperature.DefaultUnitIndex + intakeAirTemperature = []Temperature{{25, Celcius}} + temperatureUnitIndex int32 - manifoldPressure = []pressure.Pressure{pressure.Atmospheric()} - // pressureUnitIndex is used to index pressure.UnitStrings(). - pressureUnitIndex = pressure.DefaultUnitIndex + manifoldPressure = []Pressure{AtmosphericPressure()} + pressureUnitIndex int32 ) var pressureRatio []float32 func pressureRatioAt(point int) float32 { - u := pressure.Pascal + u := Pascal m := manifoldPressure[point] / u - a := pressure.Atmospheric() / u + a := AtmosphericPressure() / u return float32(m / a) } func init() { @@ -55,42 +46,41 @@ func init() { } var ( - engineMassFlowRate []mass.FlowRate - // selectedMassFlowRateUnit is used to index mass.FlowRateUnitStrings(). - selectedMassFlowRateUnit = mass.DefaultFlowRateUnitIndex + massFlowRateAir []MassFlowRate + massFlowRateUnitIndex int32 ) -func massFlowRateAt(point int) mass.FlowRate { - rpm := float32(engineSpeed[point]) - disp := float32(displacement / volume.CubicMetre) +func massFlowRateAt(point int) MassFlowRate { + rpm := float32(speed[point]) + disp := float32(displacement / CubicMetre) ve := float32(volumetricEfficiency[point]) / 100.0 cubicMetresPerMin := (rpm / 2.0) * disp * ve - iat, err := intakeAirTemperature[point].AsUnit(temperature.Kelvin) - util.Check(err) - pres := manifoldPressure[point] / pressure.Pascal + iat, err := intakeAirTemperature[point].AsUnit(Kelvin) + Check(err) + pres := manifoldPressure[point] / Pascal molsPerMin := (float32(pres) * cubicMetresPerMin) / (gasConstant * iat) kgPerMin := molsPerMin * airMolarMass - mfr := mass.FlowRate(kgPerMin/60.0) * mass.KilogramsPerSecond + mfr := MassFlowRate(kgPerMin/60.0) * KilogramsPerSecond return mfr } func init() { - engineMassFlowRate = append(engineMassFlowRate, massFlowRateAt(0)) + massFlowRateAir = append(massFlowRateAir, massFlowRateAt(0)) } var ( compressorImage *image.RGBA compressorTexture *g.Texture - selectedCompressor compressor.Compressor + selectedCompressor Compressor ) func init() { manufacturer := "garrett" series := "g" model := "25-660" - c, ok := compressor.Compressors()[manufacturer][series][model] + c, ok := Compressors[manufacturer][series][model] if !ok { fmt.Printf("compressor.Compressors()[\"%s\"][\"%s\"][\"%s\"] does not exist.\n", manufacturer, series, model, @@ -113,13 +103,13 @@ func main() { wnd.Run(loop) } -func setCompressor(c compressor.Compressor) { +func setCompressor(c Compressor) { f, err := os.Open(c.FileName) - util.Check(err) + Check(err) defer f.Close() j, _, err := image.Decode(f) - util.Check(err) + Check(err) b := j.Bounds() m := image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy())) @@ -137,7 +127,7 @@ func loop() { g.Table(). Size(g.Auto, 190). Rows( - engineSpeedRow(), + speedRow(), volumetricEfficiencyRow(), intakeAirTemperatureRow(), manifoldPressureRow(), |