diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index a6fd2ee8b..06c703089 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -1098,9 +1098,9 @@ debug_panel::update_section_engine( std::vector &Output ) const { for( int i = 0; i <= 20; ++i ) { std::string parameters = - TMoverParameters::eimc_labels[ i ] + to_string( mover.eimc[ i ], 2, 9 ) + TMoverParameters::eimc_labels[ i ] + to_string( mover.inductionMotor.config[ i ], 2, 9 ) + " | " - + TMoverParameters::eimv_labels[ i ] + to_string( mover.eimv[ i ], 2, 9 ); + + TMoverParameters::eimv_labels[ i ] + to_string( mover.inductionMotor.state[ i ], 2, 9 ); if( i < 10 ) { parameters += @@ -1115,7 +1115,7 @@ debug_panel::update_section_engine( std::vector &Output ) const { Output.emplace_back( parameters, Global.UITextColor ); } - Output.emplace_back( "Inverter:\n frequency: " + to_string( mover.InverterFrequency, 2 ), Global.UITextColor ); + Output.emplace_back( "Inverter:\n frequency: " + to_string( mover.inductionMotor.inverterFrequency, 2 ), Global.UITextColor ); } // diesel engine data if( mover.EngineType == TEngineType::DieselEngine ) { diff --git a/physics/components/body.cpp b/physics/components/body.cpp index 90acf4544..6c700f1ec 100644 --- a/physics/components/body.cpp +++ b/physics/components/body.cpp @@ -136,11 +136,11 @@ TMoverParameters::TMoverParameters(double VelInitial, std::string const &TypeNam cylindermult = 0.0; } - for (auto &eimcvalue : eimc) + for (auto &eimcvalue : inductionMotor.config) { eimcvalue = 0.0; } - eimc[eimc_p_eped] = 1.5; + inductionMotor.config[eimc_p_eped] = 1.5; for (auto &couplerentry : Couplers) { @@ -162,7 +162,7 @@ TMoverParameters::TMoverParameters(double VelInitial, std::string const &TypeNam Vel = abs(VelInitial); V = VelInitial / 3.6; - for (auto &eimvvalue : eimv) + for (auto &eimvvalue : inductionMotor.state) { eimvvalue = 0.0; } @@ -456,7 +456,7 @@ void TMoverParameters::compute_movement_(double const Deltatime) // Prad oddawany na rezystor // Wlacz wentylator jesli prad rekuperacji przekroczy maksymalny dla pasywnego chlodzenia rezystora - if (double Irh = abs(eimv[eimv_Pe]) - abs(eimv[eimv_Ipoj]); Irh > Imaxrpc && eimv[eimv_Ipoj] < 0) + if (double Irh = abs(inductionMotor.state[eimv_Pe]) - abs(inductionMotor.state[eimv_Ipoj]); Irh > Imaxrpc && inductionMotor.state[eimv_Ipoj] < 0) { BRVtimer = 0; BRVentilators = true; @@ -896,9 +896,9 @@ void TMoverParameters::ComputeTotalForce(double dt) FTrain = Power > 0 ? TractionForce(dt) : 0; double FT_factor = 1.0; - if (EngineType == TEngineType::ElectricInductionMotor && InvertersRatio > 0.0) + if (EngineType == TEngineType::ElectricInductionMotor && inductionMotor.inverterRatio > 0.0) { - FT_factor = 1.0 / InvertersRatio; + FT_factor = 1.0 / inductionMotor.inverterRatio; FTrain *= FT_factor; } diff --git a/physics/components/controllers.cpp b/physics/components/controllers.cpp index 0dcfcbe75..df0dca529 100644 --- a/physics/components/controllers.cpp +++ b/physics/components/controllers.cpp @@ -1103,8 +1103,8 @@ void TMoverParameters::CheckEIMIC(double dt) double brakeDemand = SplitEDPneumaticBrake ? DynamicBrakeRatio() : LocalBrakeRatio(); if (SplitEDPneumaticBrake) { - double const vh0 = eimc[eimc_p_Vh0]; - double const vh1 = eimc[eimc_p_Vh1]; + double const vh0 = inductionMotor.config[eimc_p_Vh0]; + double const vh1 = inductionMotor.config[eimc_p_Vh1]; if (vh1 > vh0 + 0.001) { double const vhRamp = std::clamp((Vel - vh0) / (vh1 - vh0), 0.0, 1.0); diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index 16e2c5294..99989e1a2 100644 --- a/physics/components/drive.cpp +++ b/physics/components/drive.cpp @@ -151,7 +151,7 @@ public: case 1: return vehicle.WindingRes * vehicle.Mm / vehicle.Vadd; case 2: - return vehicle.eimv_pr * vehicle.WindingRes; + return vehicle.inductionMotor.forceShare * vehicle.WindingRes; default: return vehicle.ShowCurrentP(ammeter); } diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index 6634c2496..d83b6c560 100644 --- a/physics/components/electrics.cpp +++ b/physics/components/electrics.cpp @@ -804,7 +804,7 @@ void TMoverParameters::GensetCheck(double const Deltatime) } else { - auto const demand{GensetSelected() && Mains ? std::clamp(eimv_pr, 0.0, 1.0) : 0.0}; + auto const demand{GensetSelected() && Mains ? std::clamp(inductionMotor.forceShare, 0.0, 1.0) : 0.0}; auto const target{genset.is_active ? genset.revolutions_idle + (genset.revolutions_max - genset.revolutions_idle) * demand : 0.0}; genset.revolutions += (target - genset.revolutions) * std::min(1.0, Deltatime / genset.spinup_time); if (genset.revolutions < 0.001) diff --git a/physics/components/fizparser.cpp b/physics/components/fizparser.cpp index c4c0fab0a..ebc791caa 100644 --- a/physics/components/fizparser.cpp +++ b/physics/components/fizparser.cpp @@ -387,7 +387,7 @@ bool TMoverParameters::readPmaxList(std::string const &line) double y = 0.0; parser >> x >> y; - EIM_Pmax_Table.emplace(x, y); + inductionMotor.maxPowerTable.emplace(x, y); return true; } diff --git a/physics/components/fizsections.cpp b/physics/components/fizsections.cpp index 440532edf..3b2a4eaaa 100644 --- a/physics/components/fizsections.cpp +++ b/physics/components/fizsections.cpp @@ -1380,48 +1380,48 @@ void TMoverParameters::LoadFIZ_EngineInductionMotor(std::string const &Input) RVentnmax = 1.0; extract_value(NominalVoltage, "Volt", Input, ""); - extract_value(eimc[eimc_s_dfic], "dfic", Input, ""); - extract_value(eimc[eimc_s_dfmax], "dfmax", Input, ""); - extract_value(eimc[eimc_s_p], "p", Input, ""); - extract_value(eimc[eimc_s_cfu], "cfu", Input, ""); - extract_value(eimc[eimc_s_cim], "cim", Input, ""); - extract_value(eimc[eimc_s_icif], "icif", Input, ""); - extract_value(eimc[eimc_f_Uzmax], "Uzmax", Input, ""); - extract_value(eimc[eimc_f_Uzh], "Uzh", Input, ""); - extract_value(eimc[eimc_f_DU], "DU", Input, ""); - extract_value(eimc[eimc_f_I0], "I0", Input, ""); - extract_value(eimc[eimc_f_cfu], "fcfu", Input, ""); - if (false == extract_value(eimc[eimc_f_cfuH], "fcfuH", Input, "")) + extract_value(inductionMotor.config[eimc_s_dfic], "dfic", Input, ""); + extract_value(inductionMotor.config[eimc_s_dfmax], "dfmax", Input, ""); + extract_value(inductionMotor.config[eimc_s_p], "p", Input, ""); + extract_value(inductionMotor.config[eimc_s_cfu], "cfu", Input, ""); + extract_value(inductionMotor.config[eimc_s_cim], "cim", Input, ""); + extract_value(inductionMotor.config[eimc_s_icif], "icif", Input, ""); + extract_value(inductionMotor.config[eimc_f_Uzmax], "Uzmax", Input, ""); + extract_value(inductionMotor.config[eimc_f_Uzh], "Uzh", Input, ""); + extract_value(inductionMotor.config[eimc_f_DU], "DU", Input, ""); + extract_value(inductionMotor.config[eimc_f_I0], "I0", Input, ""); + extract_value(inductionMotor.config[eimc_f_cfu], "fcfu", Input, ""); + if (false == extract_value(inductionMotor.config[eimc_f_cfuH], "fcfuH", Input, "")) { // without its own figure the dynamic brake takes the one of the traction - eimc[eimc_f_cfuH] = eimc[eimc_f_cfu]; + inductionMotor.config[eimc_f_cfuH] = inductionMotor.config[eimc_f_cfu]; } - extract_value(eimc[eimc_p_F0], "F0", Input, ""); - extract_value(eimc[eimc_p_a1], "a1", Input, ""); - extract_value(eimc[eimc_p_Pmax], "Pmax", Input, ""); - extract_value(eimc[eimc_p_Fh], "Fh", Input, ""); - extract_value(eimc[eimc_p_Ph], "Ph", Input, ""); - extract_value(eimc[eimc_p_Vh0], "Vh0", Input, ""); - extract_value(eimc[eimc_p_Vh1], "Vh1", Input, ""); - extract_value(eimc[eimc_p_Imax], "Imax", Input, ""); - extract_value(eimc[eimc_p_abed], "abed", Input, ""); - extract_value(eimc[eimc_p_eped], "edep", Input, ""); - extract_value(EIMCLogForce, "eimclf", Input, ""); - extract_value(InvertersNo, "InvNo", Input, ""); - extract_value(InverterControlCouplerFlag, "InvCtrCplFlag", Input, ""); + extract_value(inductionMotor.config[eimc_p_F0], "F0", Input, ""); + extract_value(inductionMotor.config[eimc_p_a1], "a1", Input, ""); + extract_value(inductionMotor.config[eimc_p_Pmax], "Pmax", Input, ""); + extract_value(inductionMotor.config[eimc_p_Fh], "Fh", Input, ""); + extract_value(inductionMotor.config[eimc_p_Ph], "Ph", Input, ""); + extract_value(inductionMotor.config[eimc_p_Vh0], "Vh0", Input, ""); + extract_value(inductionMotor.config[eimc_p_Vh1], "Vh1", Input, ""); + extract_value(inductionMotor.config[eimc_p_Imax], "Imax", Input, ""); + extract_value(inductionMotor.config[eimc_p_abed], "abed", Input, ""); + extract_value(inductionMotor.config[eimc_p_eped], "edep", Input, ""); + extract_value(inductionMotor.logForce, "eimclf", Input, ""); + extract_value(inductionMotor.inverterCount, "InvNo", Input, ""); + extract_value(inductionMotor.inverterControlCouplings, "InvCtrCplFlag", Input, ""); extract_value(Imaxrpc, "Imaxrpc", Input, ""); extract_value(BRVto, "BRVto", Input, ""); extract_value(Flat, "Flat", Input, ""); - if (eimc[eimc_p_Pmax] > 0 && Power > 0 && InvertersNo == 0) + if (inductionMotor.config[eimc_p_Pmax] > 0 && Power > 0 && inductionMotor.inverterCount == 0) { - InvertersNo = 1; + inductionMotor.inverterCount = 1; } - Inverters.resize(InvertersNo); - /*for (int i = 0; i > InvertersNo; i++) + inductionMotor.inverters.resize(inductionMotor.inverterCount); + /*for (int i = 0; i > inductionMotor.inverterCount; i++) { - inverter x; - Inverters.emplace_back(x); + Inverter x; + inductionMotor.inverters.emplace_back(x); }*/ } diff --git a/physics/components/inductionmotor.h b/physics/components/inductionmotor.h new file mode 100644 index 000000000..0a53ffb5c --- /dev/null +++ b/physics/components/inductionmotor.h @@ -0,0 +1,45 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +// the drive of asynchronous motors fed by inverters (ElectricInductionMotor): its definition from the .fiz and its state + +#pragma once + +#include +#include +#include + +// an inverter of the drive +struct Inverter +{ + double Freal = 0.0; + double Request = 0.0; + bool IsActive = true; + bool Activate = true; + bool Error = false; + bool Failure_Drive = false; + bool Failure_Const = false; +}; + +struct InductionMotor +{ + // the definition + std::array config; // the parameters, indexed by eimc_* (eimc before) + std::map maxPowerTable; /*tablica mocy maksymalnej od predkosci*/ + int inverterCount = 0; // number of inverters + double inverterRatio = 0.0; + int inverterControlCouplings = 4; // the couplings needed to control the inverters, the number of InvCtrCplFlag of the .fiz + bool logForce = false; // EIMCLogForce + + // the state + std::array state; // the values of the drive, indexed by eimv_* (eimv before) + double forceShare = 0; /*realizowany procent dostepnej sily rozruchu/hamowania*/ + double inverterFrequency{0.0}; // current frequency of power inverters + std::vector inverters; // all inverters +}; diff --git a/physics/components/traction.cpp b/physics/components/traction.cpp index ff3051c70..9e6f60d73 100644 --- a/physics/components/traction.cpp +++ b/physics/components/traction.cpp @@ -524,8 +524,8 @@ double TMoverParameters::DynamicBrakeRatio(void) const // ************************************************************************************************* bool TMoverParameters::DynamicBrakeAvailable(void) const { - double const vh0{eimc[eimc_p_Vh0]}; - if (double const vh1{eimc[eimc_p_Vh1]}; vh1 <= 0.001) + double const vh0{inductionMotor.config[eimc_p_Vh0]}; + if (double const vh1{inductionMotor.config[eimc_p_Vh1]}; vh1 <= 0.001) { // brak zdefiniowanej strefy - ED dziala zawsze return true; @@ -1062,15 +1062,15 @@ void TMoverParameters::InductionMotorTractionForce(double dt) double PosRatio; double tmp; double ActiveInverters = 0.0; - for (auto const &inv : Inverters) + for (auto const &inv : inductionMotor.inverters) { if (inv.IsActive) ActiveInverters += 1.0; } - InvertersRatio = ActiveInverters / (double)InvertersNo; - if (EIM_Pmax_Table.size() > 1) + inductionMotor.inverterRatio = ActiveInverters / (double)inductionMotor.inverterCount; + if (inductionMotor.maxPowerTable.size() > 1) { - eimc[eimc_p_Pmax] = TableInterpolation(EIM_Pmax_Table, Vel); + inductionMotor.config[eimc_p_Pmax] = TableInterpolation(inductionMotor.maxPowerTable, Vel); } InductionMotorSpeedControl(dt); InductionMotorBrakeBlending(ActiveInverters, PosRatio, tmp); @@ -1090,10 +1090,10 @@ void TMoverParameters::InductionMotorTractionForce(double dt) if (ActiveInverters == 0.0) { PosRatio = 0; - eimv_pr = 0; + inductionMotor.forceShare = 0; } - eimv_pr += std::max(std::min(PosRatio - eimv_pr, 0.02), -0.02) * 12 * tmp /*2{+4*byte(PosRatioGetEDBCP() * eimc[eimc_p_abed]}; // stala napedu + auto const edBCP{Hamulec->GetEDBCP() * inductionMotor.config[eimc_p_abed]}; // stala napedu if (DynamicBrakeFlag) { PosRatio = InductionMotorBrakeRatio(ActiveInverters, edBCP); @@ -1204,9 +1204,9 @@ void TMoverParameters::InductionMotorBrakeBlending(double const ActiveInverters, else { PosRatio = std::max(eimic_real, 0.); - eimv[eimv_Fzad] = PosRatio; - if (Flat && eimc[eimc_p_F0] * eimv[eimv_Fful] > 0) - PosRatio = std::min(PosRatio * eimc[eimc_p_F0] / eimv[eimv_Fful], 1.); + inductionMotor.state[eimv_Fzad] = PosRatio; + if (Flat && inductionMotor.config[eimc_p_F0] * inductionMotor.state[eimv_Fful] > 0) + PosRatio = std::min(PosRatio * inductionMotor.config[eimc_p_F0] / inductionMotor.state[eimv_Fful], 1.); /* if (ScndCtrlActualPos > 0) //speed control if (Vmax < 250) PosRatio = std::min(PosRatio, std::max(-1, 0.5 * (ScndCtrlActualPos - Vel))); @@ -1248,9 +1248,9 @@ double TMoverParameters::InductionMotorBrakeRatio(double const ActiveInverters, { double PosRatio; // ustalanie współczynnika blendingu do luzowania hamulca PN - if (eimv[eimv_Fmax] * Sign(V) * DirAbsolute < -1) + if (inductionMotor.state[eimv_Fmax] * Sign(V) * DirAbsolute < -1) { - PosRatio = -Sign(V) * DirAbsolute * eimv[eimv_Fr] / (eimc[eimc_p_Fh] * std::max(edBCP, std::max(0.01, Hamulec->GetEDBCP())) / MaxBrakePress[0]); + PosRatio = -Sign(V) * DirAbsolute * inductionMotor.state[eimv_Fr] / (inductionMotor.config[eimc_p_Fh] * std::max(edBCP, std::max(0.01, Hamulec->GetEDBCP())) / MaxBrakePress[0]); PosRatio = std::clamp(PosRatio, 0.0, 1.0); } else @@ -1262,27 +1262,27 @@ double TMoverParameters::InductionMotorBrakeRatio(double const ActiveInverters, PosRatio *= 0.9; Hamulec->SetED(std::max(0.0, std::min(PosRatio, 1.0))); // ustalenie stopnia zmniejszenia ciśnienia // ustalanie siły hamowania ED - if (Hamulec->GetEDBCP() > 0.25 && eimc[eimc_p_abed] < 0.001 || ActiveInverters < InvertersNo) // jeśli PN wyłącza ED + if (Hamulec->GetEDBCP() > 0.25 && inductionMotor.config[eimc_p_abed] < 0.001 || ActiveInverters < inductionMotor.inverterCount) // jeśli PN wyłącza ED { PosRatio = 0; - eimv[eimv_Fzad] = 0; + inductionMotor.state[eimv_Fzad] = 0; } else { // strefa wylaczenia ED (Vh0..Vh1) - mnoznik 0..1 zaleznie od predkosci - double const vhRamp = std::max(0.0, std::min(1.0, (Vel - eimc[eimc_p_Vh0]) / (eimc[eimc_p_Vh1] - eimc[eimc_p_Vh0]))); + double const vhRamp = std::max(0.0, std::min(1.0, (Vel - inductionMotor.config[eimc_p_Vh0]) / (inductionMotor.config[eimc_p_Vh1] - inductionMotor.config[eimc_p_Vh0]))); if (SplitEDPneumaticBrake) { // w trybie split LocalBrake nie zaleca ED; uzywany jest DynamicBrakeCtrl // oraz zwykle zapotrzebowanie z hamulca zespolonego (edBCP) double const edLeverDemand = DynamicBrakeRatio(); PosRatio = -std::max(std::max(edLeverDemand, std::min(edBCP / MaxBrakePress[0], 1.0)), AnPos) * vhRamp; - eimv[eimv_Fzad] = -std::min(1.0, std::max(edLeverDemand, edBCP / MaxBrakePress[0])); + inductionMotor.state[eimv_Fzad] = -std::min(1.0, std::max(edLeverDemand, edBCP / MaxBrakePress[0])); } else { PosRatio = -std::max(std::min(edBCP * 1.0 / MaxBrakePress[0], 1.0), AnPos) * vhRamp; - eimv[eimv_Fzad] = -std::min(1.0, std::max(LocalBrakeRatio(), edBCP / MaxBrakePress[0])); + inductionMotor.state[eimv_Fzad] = -std::min(1.0, std::max(LocalBrakeRatio(), edBCP / MaxBrakePress[0])); } } return PosRatio; @@ -1293,57 +1293,57 @@ void TMoverParameters::InductionMotorDrive(double dt) { double tmp; if (DynamicBrakeFlag) - tmp = eimc[eimc_f_Uzh]; + tmp = inductionMotor.config[eimc_f_Uzh]; else - tmp = eimc[eimc_f_Uzmax]; + tmp = inductionMotor.config[eimc_f_Uzmax]; - auto f_cfu{DynamicBrakeFlag ? eimc[eimc_f_cfuH] : eimc[eimc_f_cfu]}; + auto f_cfu{DynamicBrakeFlag ? inductionMotor.config[eimc_f_cfuH] : inductionMotor.config[eimc_f_cfu]}; - eimv[eimv_Uzsmax] = std::min(EngineVoltage - eimc[eimc_f_DU], tmp); - eimv[eimv_fkr] = eimv[eimv_Uzsmax] / f_cfu; - if (eimv_pr < 0) + inductionMotor.state[eimv_Uzsmax] = std::min(EngineVoltage - inductionMotor.config[eimc_f_DU], tmp); + inductionMotor.state[eimv_fkr] = inductionMotor.state[eimv_Uzsmax] / f_cfu; + if (inductionMotor.forceShare < 0) { - eimv[eimv_Pmax] = eimc[eimc_p_Ph]; + inductionMotor.state[eimv_Pmax] = inductionMotor.config[eimc_p_Ph]; } else { - eimv[eimv_Pmax] = std::min(eimc[eimc_p_Pmax], 0.001 * EngineVoltage * (eimc[eimc_p_Imax] - eimc[eimc_f_I0]) * Pirazy2 * eimc[eimc_s_cim] / eimc[eimc_s_p] / eimc[eimc_s_cfu]); + inductionMotor.state[eimv_Pmax] = std::min(inductionMotor.config[eimc_p_Pmax], 0.001 * EngineVoltage * (inductionMotor.config[eimc_p_Imax] - inductionMotor.config[eimc_f_I0]) * Pirazy2 * inductionMotor.config[eimc_s_cim] / inductionMotor.config[eimc_s_p] / inductionMotor.config[eimc_s_cfu]); if (GensetSelected()) { // on the genset of a dual-mode vehicle the traction takes no more than the genset gives - eimv[eimv_Pmax] = std::min(eimv[eimv_Pmax], GensetTractionPowerLimit()); + inductionMotor.state[eimv_Pmax] = std::min(inductionMotor.state[eimv_Pmax], GensetTractionPowerLimit()); } } - eimv[eimv_FMAXMAX] = 0.001 * - square(std::min(1.0, eimv[eimv_fkr] / std::max(abs(enrot) * eimc[eimc_s_p] + eimc[eimc_s_dfmax] * eimv[eimv_ks], eimc[eimc_s_dfmax])) * f_cfu / eimc[eimc_s_cfu]) * - (eimc[eimc_s_dfmax] * eimc[eimc_s_dfic] * eimc[eimc_s_cim]) * Transmision.Ratio * NPoweredAxles * 2.0 / WheelDiameter; + inductionMotor.state[eimv_FMAXMAX] = 0.001 * + square(std::min(1.0, inductionMotor.state[eimv_fkr] / std::max(abs(enrot) * inductionMotor.config[eimc_s_p] + inductionMotor.config[eimc_s_dfmax] * inductionMotor.state[eimv_ks], inductionMotor.config[eimc_s_dfmax])) * f_cfu / inductionMotor.config[eimc_s_cfu]) * + (inductionMotor.config[eimc_s_dfmax] * inductionMotor.config[eimc_s_dfic] * inductionMotor.config[eimc_s_cim]) * Transmision.Ratio * NPoweredAxles * 2.0 / WheelDiameter; InductionMotorForceLimits(); - for (auto &inv : Inverters) + for (auto &inv : inductionMotor.inverters) { - inv.Request = inv.IsActive ? eimv_pr : 0.0; + inv.Request = inv.IsActive ? inductionMotor.forceShare : 0.0; inv.Error = inv.Failure_Const || (inv.Failure_Drive && inv.Request != 0); inv.IsActive = inv.Activate && !inv.Error; } - eimv[eimv_ks] = eimv[eimv_Fr] / eimv[eimv_FMAXMAX]; - eimv[eimv_df] = eimv[eimv_ks] * eimc[eimc_s_dfmax]; - eimv[eimv_fp] = DirAbsolute * enrot * eimc[eimc_s_p] + eimv[eimv_df]; // do przemyslenia dzialanie pp z tmpV - // eimv[eimv_U]:=std::max(eimv[eimv_Uzsmax],std::min(eimc[eimc_f_cfu]*eimv[eimv_fp],eimv[eimv_Uzsmax])); - // eimv[eimv_pole]:=eimv[eimv_U]/(eimv[eimv_fp]*eimc[eimc_s_cfu]); - if (abs(eimv[eimv_fp]) <= eimv[eimv_fkr]) - eimv[eimv_pole] = f_cfu / eimc[eimc_s_cfu]; + inductionMotor.state[eimv_ks] = inductionMotor.state[eimv_Fr] / inductionMotor.state[eimv_FMAXMAX]; + inductionMotor.state[eimv_df] = inductionMotor.state[eimv_ks] * inductionMotor.config[eimc_s_dfmax]; + inductionMotor.state[eimv_fp] = DirAbsolute * enrot * inductionMotor.config[eimc_s_p] + inductionMotor.state[eimv_df]; // do przemyslenia dzialanie pp z tmpV + // inductionMotor.state[eimv_U]:=std::max(inductionMotor.state[eimv_Uzsmax],std::min(inductionMotor.config[eimc_f_cfu]*inductionMotor.state[eimv_fp],inductionMotor.state[eimv_Uzsmax])); + // inductionMotor.state[eimv_pole]:=inductionMotor.state[eimv_U]/(inductionMotor.state[eimv_fp]*inductionMotor.config[eimc_s_cfu]); + if (abs(inductionMotor.state[eimv_fp]) <= inductionMotor.state[eimv_fkr]) + inductionMotor.state[eimv_pole] = f_cfu / inductionMotor.config[eimc_s_cfu]; else - eimv[eimv_pole] = eimv[eimv_Uzsmax] / eimc[eimc_s_cfu] / abs(eimv[eimv_fp]); - eimv[eimv_U] = eimv[eimv_pole] * eimv[eimv_fp] * eimc[eimc_s_cfu]; - eimv[eimv_Ic] = (eimv[eimv_fp] - DirAbsolute * enrot * eimc[eimc_s_p]) * eimc[eimc_s_dfic] * eimv[eimv_pole]; - eimv[eimv_If] = eimv[eimv_Ic] * eimc[eimc_s_icif]; - eimv[eimv_M] = eimv[eimv_pole] * eimv[eimv_Ic] * eimc[eimc_s_cim]; - eimv[eimv_Ipoj] = eimv[eimv_Ic] * NPoweredAxles * InvertersRatio * eimv[eimv_U] / (EngineVoltage - eimc[eimc_f_DU]) + eimc[eimc_f_I0]; - eimv[eimv_Pm] = DirActive * eimv[eimv_M] * NPoweredAxles * InvertersRatio * enrot * Pirazy2 / 1000; - eimv[eimv_Pe] = eimv[eimv_Ipoj] * EngineVoltage / 1000; - eimv[eimv_eta] = eimv[eimv_Pm] / eimv[eimv_Pe]; + inductionMotor.state[eimv_pole] = inductionMotor.state[eimv_Uzsmax] / inductionMotor.config[eimc_s_cfu] / abs(inductionMotor.state[eimv_fp]); + inductionMotor.state[eimv_U] = inductionMotor.state[eimv_pole] * inductionMotor.state[eimv_fp] * inductionMotor.config[eimc_s_cfu]; + inductionMotor.state[eimv_Ic] = (inductionMotor.state[eimv_fp] - DirAbsolute * enrot * inductionMotor.config[eimc_s_p]) * inductionMotor.config[eimc_s_dfic] * inductionMotor.state[eimv_pole]; + inductionMotor.state[eimv_If] = inductionMotor.state[eimv_Ic] * inductionMotor.config[eimc_s_icif]; + inductionMotor.state[eimv_M] = inductionMotor.state[eimv_pole] * inductionMotor.state[eimv_Ic] * inductionMotor.config[eimc_s_cim]; + inductionMotor.state[eimv_Ipoj] = inductionMotor.state[eimv_Ic] * NPoweredAxles * inductionMotor.inverterRatio * inductionMotor.state[eimv_U] / (EngineVoltage - inductionMotor.config[eimc_f_DU]) + inductionMotor.config[eimc_f_I0]; + inductionMotor.state[eimv_Pm] = DirActive * inductionMotor.state[eimv_M] * NPoweredAxles * inductionMotor.inverterRatio * enrot * Pirazy2 / 1000; + inductionMotor.state[eimv_Pe] = inductionMotor.state[eimv_Ipoj] * EngineVoltage / 1000; + inductionMotor.state[eimv_eta] = inductionMotor.state[eimv_Pm] / inductionMotor.state[eimv_Pe]; - Im = eimv[eimv_If]; - if (eimv[eimv_Ipoj] >= 0) + Im = inductionMotor.state[eimv_If]; + if (inductionMotor.state[eimv_Ipoj] >= 0) Vadd *= 1.0 - 2.0 * dt; else if (GensetSelected()) Vadd = 1.0; // the genset of a dual-mode vehicle takes nothing back: all the braking energy to the resistors @@ -1351,57 +1351,57 @@ void TMoverParameters::InductionMotorDrive(double dt) Vadd *= 1.0 - dt; else Vadd = std::max(Vadd * (1.0 - 0.2 * dt), 0.007 * (std::abs(EngineVoltage) - (EnginePowerSource.CollectorParameters.MaxV - 100))); - Itot = eimv[eimv_Ipoj] * (0.01 + std::min(0.99, 0.99 - Vadd)); + Itot = inductionMotor.state[eimv_Ipoj] * (0.01 + std::min(0.99, 0.99 - Vadd)); - EnginePower = abs(eimv[eimv_Ic] * eimv[eimv_U] * NPoweredAxles) / 1000; + EnginePower = abs(inductionMotor.state[eimv_Ic] * inductionMotor.state[eimv_U] * NPoweredAxles) / 1000; // power inverters UpdateInverterFrequency(); - Mm = eimv[eimv_M] * DirAbsolute; + Mm = inductionMotor.state[eimv_M] * DirAbsolute; Mw = Mm * Transmision.Ratio * Transmision.Efficiency; Fw = Mw * 2.0 / WheelDiameter; - Ft = Fw * NPoweredAxles * InvertersRatio; - eimv[eimv_Fr] = DirAbsolute * Ft / 1000; + Ft = Fw * NPoweredAxles * inductionMotor.inverterRatio; + inductionMotor.state[eimv_Fr] = DirAbsolute * Ft / 1000; } -// the force the motors give at full and at the setting (eimv_pr), braking within the power and the force of the +// the force the motors give at full and at the setting (inductionMotor.forceShare), braking within the power and the force of the // electrodynamic brake, driving within the power and the starting force void TMoverParameters::InductionMotorForceLimits() { - if (eimv_pr < 0) + if (inductionMotor.forceShare < 0) { - eimv[eimv_Fful] = std::min(eimc[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(eimc[eimc_p_Fh], eimv[eimv_FMAXMAX])); - eimv[eimv_Fmax] = -Sign(V) * DirAbsolute*std::min(eimc[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(-eimc[eimc_p_Fh] * eimv_pr, eimv[eimv_FMAXMAX])); - double pr = eimv_pr; - if (EIMCLogForce) + inductionMotor.state[eimv_Fful] = std::min(inductionMotor.config[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(inductionMotor.config[eimc_p_Fh], inductionMotor.state[eimv_FMAXMAX])); + inductionMotor.state[eimv_Fmax] = -Sign(V) * DirAbsolute*std::min(inductionMotor.config[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(-inductionMotor.config[eimc_p_Fh] * inductionMotor.forceShare, inductionMotor.state[eimv_FMAXMAX])); + double pr = inductionMotor.forceShare; + if (inductionMotor.logForce) pr = -log(1 - 4 * pr) / log(5); - eimv[eimv_Fr] = -Sign(V) * DirAbsolute*std::min(eimc[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(-eimc[eimc_p_Fh] * pr, eimv[eimv_FMAXMAX])); - if (InvertersRatio < 1.0) - eimv[eimv_Fful] = 0; - //*std::min(1,(Vel-eimc[eimc_p_Vh0])/(eimc[eimc_p_Vh1]-eimc[eimc_p_Vh0])) + inductionMotor.state[eimv_Fr] = -Sign(V) * DirAbsolute*std::min(inductionMotor.config[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(-inductionMotor.config[eimc_p_Fh] * pr, inductionMotor.state[eimv_FMAXMAX])); + if (inductionMotor.inverterRatio < 1.0) + inductionMotor.state[eimv_Fful] = 0; + //*std::min(1,(Vel-inductionMotor.config[eimc_p_Vh0])/(inductionMotor.config[eimc_p_Vh1]-inductionMotor.config[eimc_p_Vh0])) } else { - eimv[eimv_Fful] = std::min(std::min(3.6 * eimv[eimv_Pmax] / std::max(Vel, 1.), eimc[eimc_p_F0] - Vel * eimc[eimc_p_a1]), eimv[eimv_FMAXMAX]); + inductionMotor.state[eimv_Fful] = std::min(std::min(3.6 * inductionMotor.state[eimv_Pmax] / std::max(Vel, 1.), inductionMotor.config[eimc_p_F0] - Vel * inductionMotor.config[eimc_p_a1]), inductionMotor.state[eimv_FMAXMAX]); // if(not Flat)then - eimv[eimv_Fmax] = eimv[eimv_Fful] * eimv_pr; + inductionMotor.state[eimv_Fmax] = inductionMotor.state[eimv_Fful] * inductionMotor.forceShare; // else - // eimv[eimv_Fmax]:=std::min(eimc[eimc_p_F0]*eimv_pr,eimv[eimv_Fful]); - double pr = eimv_pr; - if (EIMCLogForce) + // inductionMotor.state[eimv_Fmax]:=std::min(inductionMotor.config[eimc_p_F0]*inductionMotor.forceShare,inductionMotor.state[eimv_Fful]); + double pr = inductionMotor.forceShare; + if (inductionMotor.logForce) pr = log(1 + 4 * pr) / log(5); - eimv[eimv_Fr] = eimv[eimv_Fful] * pr; + inductionMotor.state[eimv_Fr] = inductionMotor.state[eimv_Fful] * pr; } } // the frequency of the inverters at the motors' slip frequency, from the list of the drive or of its brake void TMoverParameters::UpdateInverterFrequency() { - auto const tmpV{std::abs(eimv[eimv_fp])}; + auto const tmpV{std::abs(inductionMotor.state[eimv_fp])}; auto const useFFEDList = FFEDListSize > 0 && DynamicBrakeFlag; auto const list = useFFEDList ? FFEDlist : FFlist; - if (auto const listSize = useFFEDList ? FFEDListSize : FFListSize; listSize > 0 && std::abs(eimv[eimv_If]) > 1.0 && tmpV > 0.0001) + if (auto const listSize = useFFEDList ? FFEDListSize : FFListSize; listSize > 0 && std::abs(inductionMotor.state[eimv_If]) > 1.0 && tmpV > 0.0001) { int i = 0; @@ -1409,18 +1409,18 @@ void TMoverParameters::UpdateInverterFrequency() { ++i; } - InverterFrequency = (tmpV - list[i].v) / std::max(1.0, list[i + 1].v - list[i].v) * (list[i + 1].freq - list[i].freq) + list[i].freq; + inductionMotor.inverterFrequency = (tmpV - list[i].v) / std::max(1.0, list[i + 1].v - list[i].v) * (list[i + 1].freq - list[i].freq) + list[i].freq; } else { - InverterFrequency = 0.0; + inductionMotor.inverterFrequency = 0.0; } } // the induction motor drive without power, or blocked by the security system void TMoverParameters::InductionMotorOff() { - for (auto &inv : Inverters) + for (auto &inv : inductionMotor.inverters) { inv.Freal = 0.0; inv.IsActive = false; @@ -1431,14 +1431,14 @@ void TMoverParameters::InductionMotorOff() Fw = 0.0; Ft = 0.0; Itot = 0.0; - eimv_pr = 0.0; + inductionMotor.forceShare = 0.0; EnginePower = 0.0; { - for (auto &eimvvalue : eimv) + for (auto &eimvvalue : inductionMotor.state) eimvvalue = 0.0; } Hamulec->SetED(0.0); - InverterFrequency = 0.0; //(Hamulec as TLSt).SetLBP(LocBrakePress); + inductionMotor.inverterFrequency = 0.0; //(Hamulec as TLSt).SetLBP(LocBrakePress); } // ************************************************************************************************* diff --git a/physics/mover.h b/physics/mover.h index 6dd3eebe1..64a555d23 100644 --- a/physics/mover.h +++ b/physics/mover.h @@ -23,6 +23,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/odometerreading.h" #include "physics/vehicletypes.h" #include "physics/components/dieselengine.h" +#include "physics/components/inductionmotor.h" class TractionDrive; @@ -598,17 +599,6 @@ struct speed_control double PowerDownSpeed = 1000; }; -struct inverter -{ - double Freal = 0.0; - double Request = 0.0; - bool IsActive = true; - bool Activate = true; - bool Error = false; - bool Failure_Drive = false; - bool Failure_Const = false; -}; - class TMoverParameters { // Ra: wrapper na kod pascalowy, przejmujący jego funkcje Q: 20160824 - juz nie wrapper a klasa bazowa :) private: @@ -1156,18 +1146,12 @@ class TMoverParameters /*- dla uproszczonego modelu silnika (dumb) oraz dla drezyny*/ double Ftmax = 0.0; /*- dla lokomotyw z silnikami indukcyjnymi -*/ - double eimc[26]; - bool EIMCLogForce = false; // + // the drive of induction motors (physics/components/inductionmotor.h) + InductionMotor inductionMotor; static std::vector const eimc_labels; - double InverterFrequency{0.0}; // current frequency of power inverters - int InvertersNo = 0; // number of inverters - double InvertersRatio = 0.0; - std::vector Inverters; // all inverters - int InverterControlCouplerFlag = 4; // which coupling flag is necessary to controll inverters int Imaxrpc = 0; // Maksymalny prad rezystora hamowania chlodzonego pasywnie int BRVto = 0; // Czas jaki wentylatory jeszcze dodatkowo schladzaja rezystor double BRVtimer = 0; // Timer dla podtrzymania wentylatora - std::map EIM_Pmax_Table; /*tablica mocy maksymalnej od predkosci*/ /* -dla pojazdów z blendingiem EP/ED (MED) */ double MED_Vmax = 0; // predkosc maksymalna dla obliczen chwilowej sily hamowania EP w MED double MED_Vmin = 0; // predkosc minimalna dla obliczen chwilowej sily hamowania EP w MED @@ -1496,8 +1480,6 @@ class TMoverParameters bool EIMCtrlAdditionalZeros = false; /*czy ma dodatkowe zero jazdy i zero hamowania */ bool EIMCtrlEmergency = false; /*czy ma dodatkowe zero jazdy i zero hamowania */ bool EIMCtrlMainEmergency = false; /*czy zadajnik typu 2 (Elf) ma pozycje hamowania naglego ponizej swojej pozycji 0*/ - double eimv_pr = 0; /*realizowany procent dostepnej sily rozruchu/hamowania*/ - double eimv[21]; static std::vector const eimv_labels; double SpeedCtrlTimer = 0; /*zegar dzialania tempomatu z wybieralna predkoscia*/ double eimicSpeedCtrl = 1; /*pozycja sugerowana przez tempomat*/ @@ -1688,7 +1670,7 @@ class TMoverParameters bool EIMDirectionChangeAllow(void) const; inline double IsVehicleEIMBrakingFactor() const { - return DynamicBrakeFlag && ResistorsFlag ? 0.0 : eimv[eimv_Ipoj] < 0 ? -1.0 : 1.0; + return DynamicBrakeFlag && ResistorsFlag ? 0.0 : inductionMotor.state[eimv_Ipoj] < 0 ? -1.0 : 1.0; } void BrakeLevelSet(double b); bool BrakeLevelAdd(double b); diff --git a/tests/unit/golden.cpp b/tests/unit/golden.cpp index ce4225906..363d97718 100644 --- a/tests/unit/golden.cpp +++ b/tests/unit/golden.cpp @@ -67,7 +67,7 @@ std::vector traction() { {"EnginePower", [](auto const &M) { return M.EnginePower; }}, {"enrot", [](auto const &M) { return M.enrot; }}, {"dizel_fill", [](auto const &M) { return M.diesel.fill; }}, - {"eimv_pr", [](auto const &M) { return M.eimv_pr; }}, + {"eimv_pr", [](auto const &M) { return M.inductionMotor.forceShare; }}, {"DynamicBrakeFlag", [](auto const &M) { return M.DynamicBrakeFlag ? 1.0 : 0.0; }}, }; } diff --git a/tests/unit/test_definition.cpp b/tests/unit/test_definition.cpp index 6b0ce22b3..518f9b73f 100644 --- a/tests/unit/test_definition.cpp +++ b/tests/unit/test_definition.cpp @@ -131,7 +131,7 @@ TEST_CASE("definition: the highest power of an induction motor drive by the spee auto driven{test::driving(real)}; test::track const line{0.0, 0.0, test::catenary_3kv}; REQUIRE(test::start_up(driven, line)); - CHECK(real->eimc[eimc_p_Pmax] == doctest::Approx(table(real->Vel)).epsilon(0.01)); + CHECK(real->inductionMotor.config[eimc_p_Pmax] == doctest::Approx(table(real->Vel)).epsilon(0.01)); } } diff --git a/tests/unit/test_elf_controller.cpp b/tests/unit/test_elf_controller.cpp index f480951e1..138689f68 100644 --- a/tests/unit/test_elf_controller.cpp +++ b/tests/unit/test_elf_controller.cpp @@ -530,7 +530,7 @@ TEST_CASE("elf holding brake: the force of the motors at 1% against the holding unit.wait(5.0); auto const holding{cab.StopBrakeDecc * mass}; MESSAGE("mass " << mass << " kg, holding " << holding << " N, cars with motors " << powered << ", demand " << cab.eimic_real << ", cab car Ft " << cab.Ft - << " N, Fful " << cab.eimv[eimv_Fful] << " kN, speed " << cab.Vel << " km/h after 5 s"); + << " N, Fful " << cab.inductionMotor.state[eimv_Fful] << " kN, speed " << cab.Vel << " km/h after 5 s"); CHECK(cab.eimic_real == doctest::Approx(0.01).epsilon(0.02)); CHECK(cab.Ft * powered < 0.1 * holding); } diff --git a/tests/unit/test_fcfuh_default.cpp b/tests/unit/test_fcfuh_default.cpp index 437164060..e86f29e7b 100644 --- a/tests/unit/test_fcfuh_default.cpp +++ b/tests/unit/test_fcfuh_default.cpp @@ -142,12 +142,12 @@ TEST_CASE("fcfuH: the loader gives the dynamic brake the traction's figure when CAPTURE(fcfu); // the EU47's definition has fcfu only vehicle eu47{definition::fiz("e186_v2/eu47").set("Engine", "fcfu", fcfu)}; - CHECK(eu47->eimc[eimc_f_cfu] == read_fcfu(fcfu)); - CHECK(bits(eu47->eimc[eimc_f_cfuH]) == bits(eu47->eimc[eimc_f_cfu])); - CHECK(bits(eu47->eimc[eimc_f_cfuH]) == bits(fcfuh_before(read_fcfu(fcfu)))); + CHECK(eu47->inductionMotor.config[eimc_f_cfu] == read_fcfu(fcfu)); + CHECK(bits(eu47->inductionMotor.config[eimc_f_cfuH]) == bits(eu47->inductionMotor.config[eimc_f_cfu])); + CHECK(bits(eu47->inductionMotor.config[eimc_f_cfuH]) == bits(fcfuh_before(read_fcfu(fcfu)))); // its own figure is kept vehicle own{definition::fiz("e186_v2/eu47").set("Engine", "fcfu", fcfu).set("Engine", "fcfuH", "40.1")}; - CHECK(own->eimc[eimc_f_cfu] == read_fcfu(fcfu)); - CHECK(own->eimc[eimc_f_cfuH] == read_fcfu("40.1")); + CHECK(own->inductionMotor.config[eimc_f_cfu] == read_fcfu(fcfu)); + CHECK(own->inductionMotor.config[eimc_f_cfuH] == read_fcfu("40.1")); } } diff --git a/tests/unit/test_genset.cpp b/tests/unit/test_genset.cpp index 33af24480..cba96800f 100644 --- a/tests/unit/test_genset.cpp +++ b/tests/unit/test_genset.cpp @@ -309,11 +309,11 @@ TEST_CASE("genset: the revolutions follow the demand, so the power builds up") { notch_up(cab); // the demand of the traction builds up at the pace of the inverters, the revolutions follow it auto step_count{0L}; - for (; step_count < 3000 && cab.eimv_pr < 0.99; ++step_count) { + for (; step_count < 3000 && cab.inductionMotor.forceShare < 0.99; ++step_count) { step(dragon6, step_count); } CAPTURE(step_count); - REQUIRE(cab.eimv_pr >= 0.99); + REQUIRE(cab.inductionMotor.forceShare >= 0.99); run(dragon6, 3.0); auto const after3{cab.Genset.available_power()}; CAPTURE(after3); @@ -345,7 +345,7 @@ TEST_CASE("genset: running from the catenary is the same with the keys") { {"V", [&Values](TMoverParameters const &Vehicle) { Values.speed.push_back(Vehicle.V); return Vehicle.V; }}, {"EngineVoltage", [&Values](TMoverParameters const &Vehicle) { Values.voltage.push_back(Vehicle.EngineVoltage); return Vehicle.EngineVoltage; }}, {"Itot", [&Values](TMoverParameters const &Vehicle) { Values.current.push_back(Vehicle.Itot); return Vehicle.Itot; }}, - {"eimv_pr", [&Values](TMoverParameters const &Vehicle) { Values.demand.push_back(Vehicle.eimv_pr); return Vehicle.eimv_pr; }}, + {"eimv_pr", [&Values](TMoverParameters const &Vehicle) { Values.demand.push_back(Vehicle.inductionMotor.forceShare); return Vehicle.inductionMotor.forceShare; }}, }; }; auto const drive = [&record](definition const &Definition, values &Values) { @@ -492,7 +492,7 @@ braking brake_from_60(vehicle &Dragon, track const &Track) { for (auto step_count = 0L; step_count < 2000; ++step_count) { step(Dragon, step_count, Track); result.lowest_current = std::min(result.lowest_current, cab.Itot); - result.electrodynamic |= cab.eimv_pr < 0.0 && cab.eimv[eimv_Ipoj] < 0.0; + result.electrodynamic |= cab.inductionMotor.forceShare < 0.0 && cab.inductionMotor.state[eimv_Ipoj] < 0.0; } result.speed_lost = speed - cab.Vel; return result; diff --git a/vehicle/cab/equipmentcommands.cpp b/vehicle/cab/equipmentcommands.cpp index 256141d9a..a7c232c01 100644 --- a/vehicle/cab/equipmentcommands.cpp +++ b/vehicle/cab/equipmentcommands.cpp @@ -413,20 +413,20 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command { // only reacting to press, so the switch doesn't flip back and forth if key is held down bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; - auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->InverterControlCouplerFlag)}; + auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->inductionMotor.inverterControlCouplings)}; TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); while (p) { - if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) + if (p->MoverParameters->inductionMotor.config[eimc_p_Pmax] > 1) { - if (itemindex < p->MoverParameters->InvertersNo) + if (itemindex < p->MoverParameters->inductionMotor.inverterCount) { - p->MoverParameters->Inverters[itemindex].Activate = true; + p->MoverParameters->inductionMotor.inverters[itemindex].Activate = true; break; } else { - itemindex -= p->MoverParameters->InvertersNo; + itemindex -= p->MoverParameters->inductionMotor.inverterCount; } } p = kier ? p->Next(flag) : p->Prev(flag); @@ -452,20 +452,20 @@ void TTrain::OnCommand_inverterdisable(TTrain *Train, command_data const &Comman { // only reacting to press, so the switch doesn't flip back and forth if key is held down bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; - auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->InverterControlCouplerFlag)}; + auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->inductionMotor.inverterControlCouplings)}; TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); while (p) { - if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) + if (p->MoverParameters->inductionMotor.config[eimc_p_Pmax] > 1) { - if (itemindex < p->MoverParameters->InvertersNo) + if (itemindex < p->MoverParameters->inductionMotor.inverterCount) { - p->MoverParameters->Inverters[itemindex].Activate = false; + p->MoverParameters->inductionMotor.inverters[itemindex].Activate = false; break; } else { - itemindex -= p->MoverParameters->InvertersNo; + itemindex -= p->MoverParameters->inductionMotor.inverterCount; } } p = kier ? p->Next(flag) : p->Prev(flag); @@ -491,22 +491,22 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command { // only reacting to press, so the switch doesn't flip back and forth if key is held down bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; - auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->InverterControlCouplerFlag)}; + auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->inductionMotor.inverterControlCouplings)}; TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); while (p) { - if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) + if (p->MoverParameters->inductionMotor.config[eimc_p_Pmax] > 1) { - if (itemindex < p->MoverParameters->InvertersNo) + if (itemindex < p->MoverParameters->inductionMotor.inverterCount) { - p->MoverParameters->Inverters[itemindex].Activate = !p->MoverParameters->Inverters[itemindex].Activate; + p->MoverParameters->inductionMotor.inverters[itemindex].Activate = !p->MoverParameters->inductionMotor.inverters[itemindex].Activate; // visual feedback - item.UpdateValue(p->MoverParameters->Inverters[itemindex].Activate ? 1.0 : 0.0, Train->dsbSwitch); + item.UpdateValue(p->MoverParameters->inductionMotor.inverters[itemindex].Activate ? 1.0 : 0.0, Train->dsbSwitch); break; } else { - itemindex -= p->MoverParameters->InvertersNo; + itemindex -= p->MoverParameters->inductionMotor.inverterCount; } } p = kier ? p->Next(flag) : p->Prev(flag); diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index e72aefc54..80ffd7fe6 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -1175,7 +1175,7 @@ void TTrain::set_cab_controls(int const Cab) // finding each inverter - not so optimal, but action ins performed only during changing cabin bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; - auto const flag{CouplingSet::FromBits(DynamicObject->MoverParameters->InverterControlCouplerFlag)}; + auto const flag{CouplingSet::FromBits(DynamicObject->MoverParameters->inductionMotor.inverterControlCouplings)}; int itemstart = 0; for ([[maybe_unused]] auto const &item : ggInverterToggleButtons) // for each button { @@ -1184,17 +1184,17 @@ void TTrain::set_cab_controls(int const Cab) TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); while (p) { - if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) + if (p->MoverParameters->inductionMotor.config[eimc_p_Pmax] > 1) { - if (itemindex < p->MoverParameters->InvertersNo) + if (itemindex < p->MoverParameters->inductionMotor.inverterCount) { // visual feedback - ggInverterToggleButtons[itemstart - 1].PutValue(p->MoverParameters->Inverters[itemindex].Activate ? 1.0 : 0.0); + ggInverterToggleButtons[itemstart - 1].PutValue(p->MoverParameters->inductionMotor.inverters[itemindex].Activate ? 1.0 : 0.0); break; } else { - itemindex -= p->MoverParameters->InvertersNo; + itemindex -= p->MoverParameters->inductionMotor.inverterCount; } } p = kier ? p->Next(flag) : p->Prev(flag); diff --git a/vehicle/cab/train.cpp b/vehicle/cab/train.cpp index 3c1f86b62..2bdb38b0b 100644 --- a/vehicle/cab/train.cpp +++ b/vehicle/cab/train.cpp @@ -319,15 +319,15 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const int in = 0; while (p && in < 8) { - if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) + if (p->MoverParameters->inductionMotor.config[eimc_p_Pmax] > 1) { in++; - dict->insert("eimp_c" + std::to_string(in) + "_invno", p->MoverParameters->InvertersNo); - for (int j = 0; j < p->MoverParameters->InvertersNo; j++) + dict->insert("eimp_c" + std::to_string(in) + "_invno", p->MoverParameters->inductionMotor.inverterCount); + for (int j = 0; j < p->MoverParameters->inductionMotor.inverterCount; j++) { - dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_act", p->MoverParameters->Inverters[j].IsActive); - dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_error", p->MoverParameters->Inverters[j].Error); - dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_allow", p->MoverParameters->Inverters[j].Activate); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_act", p->MoverParameters->inductionMotor.inverters[j].IsActive); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_error", p->MoverParameters->inductionMotor.inverters[j].Error); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_allow", p->MoverParameters->inductionMotor.inverters[j].Activate); } } p = kier ? p->Next(Coupling::control) : p->Prev(Coupling::control); diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index 5d193a004..1f883ea4d 100644 --- a/vehicle/cab/update.cpp +++ b/vehicle/cab/update.cpp @@ -349,17 +349,17 @@ bool TTrain::Update(double const Deltatime) bCompressors.emplace_back(p->MoverParameters->CompressorAllow || p->MoverParameters->CompressorStart == start_t::automatic, p->MoverParameters->CompressorFlag, i); } bSlip[i] = p->MoverParameters->SlippingWheels; - if (in < 8 && p->MoverParameters->eimc[eimc_p_Pmax] > 1) + if (in < 8 && p->MoverParameters->inductionMotor.config[eimc_p_Pmax] > 1) { - fEIMParams[1 + in][0] = static_cast(p->MoverParameters->eimv[eimv_Fmax]); + fEIMParams[1 + in][0] = static_cast(p->MoverParameters->inductionMotor.state[eimv_Fmax]); fEIMParams[1 + in][1] = std::max(fEIMParams[1 + in][0], 0.f); fEIMParams[1 + in][2] = -std::min(fEIMParams[1 + in][0], 0.f); - fEIMParams[1 + in][3] = static_cast(p->MoverParameters->eimv[eimv_Fmax] / std::max(p->MoverParameters->eimv[eimv_Fful], 1.)); + fEIMParams[1 + in][3] = static_cast(p->MoverParameters->inductionMotor.state[eimv_Fmax] / std::max(p->MoverParameters->inductionMotor.state[eimv_Fful], 1.)); fEIMParams[1 + in][4] = std::max(fEIMParams[1 + in][3], 0.f); fEIMParams[1 + in][5] = -std::min(fEIMParams[1 + in][3], 0.f); - fEIMParams[1 + in][6] = static_cast(p->MoverParameters->eimv[eimv_If]); - fEIMParams[1 + in][7] = static_cast(p->MoverParameters->eimv[eimv_U]); - fEIMParams[1 + in][8] = static_cast(p->MoverParameters->Itot); // p->MoverParameters->eimv[eimv_Ipoj]; + fEIMParams[1 + in][6] = static_cast(p->MoverParameters->inductionMotor.state[eimv_If]); + fEIMParams[1 + in][7] = static_cast(p->MoverParameters->inductionMotor.state[eimv_U]); + fEIMParams[1 + in][8] = static_cast(p->MoverParameters->Itot); // p->MoverParameters->inductionMotor.state[eimv_Ipoj]; fEIMParams[1 + in][9] = static_cast(p->MoverParameters->EngineVoltage); fEIMParams[0][6] += fEIMParams[1 + in][8]; bMains[in] = p->MoverParameters->Mains; @@ -422,15 +422,15 @@ bool TTrain::Update(double const Deltatime) } // if (mvControlled == mvOccupied) - // fEIMParams[0][3] = mvControlled->eimv[eimv_Fzad]; // procent zadany + // fEIMParams[0][3] = mvControlled->inductionMotor.state[eimv_Fzad]; // procent zadany // else // fEIMParams[0][3] = - // mvControlled->eimv[eimv_Fzad] - mvOccupied->LocalBrakeRatio(); // procent zadany + // mvControlled->inductionMotor.state[eimv_Fzad] - mvOccupied->LocalBrakeRatio(); // procent zadany fEIMParams[0][3] = static_cast(mvOccupied->eimic_real); fEIMParams[0][4] = std::max(fEIMParams[0][3], 0.f); fEIMParams[0][5] = -std::min(fEIMParams[0][3], 0.f); - fEIMParams[0][1] = static_cast(fEIMParams[0][4] * mvControlled->eimv[eimv_Fful]); - fEIMParams[0][2] = static_cast(fEIMParams[0][5] * mvControlled->eimv[eimv_Fful]); + fEIMParams[0][1] = static_cast(fEIMParams[0][4] * mvControlled->inductionMotor.state[eimv_Fful]); + fEIMParams[0][2] = static_cast(fEIMParams[0][5] * mvControlled->inductionMotor.state[eimv_Fful]); fEIMParams[0][0] = fEIMParams[0][1] - fEIMParams[0][2]; fEIMParams[0][7] = 0; fEIMParams[0][8] = 0; diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index 3cde7887c..ee5828877 100644 --- a/vehicle/dynamic/sounds.cpp +++ b/vehicle/dynamic/sounds.cpp @@ -1089,7 +1089,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub } if (Vehicle.Mains) { - float power = std::clamp(Vehicle.eimv_pr, 0.0, 1.0); + float power = std::clamp(Vehicle.inductionMotor.forceShare, 0.0, 1.0); fake_engine .pitch(fake_engine.m_frequencyoffset + power * fake_engine.m_frequencyfactor) @@ -1263,12 +1263,12 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub if( false == acmotors.empty() ) { if( Vehicle.EngineType == TEngineType::ElectricInductionMotor ) { - if( Vehicle.InverterFrequency > 0.001 ) { + if( Vehicle.inductionMotor.inverterFrequency > 0.001 ) { for( auto &motor : acmotors ) { motor - .pitch( motor.m_frequencyoffset + motor.m_frequencyfactor * Vehicle.InverterFrequency ) - .gain( motor.m_amplitudeoffset + motor.m_amplitudefactor * std::sqrt( std::abs( Vehicle.eimv_pr ) ) ) + .pitch( motor.m_frequencyoffset + motor.m_frequencyfactor * Vehicle.inductionMotor.inverterFrequency ) + .gain( motor.m_amplitudeoffset + motor.m_amplitudefactor * std::sqrt( std::abs( Vehicle.inductionMotor.forceShare ) ) ) .play( sound_flags::exclusive | sound_flags::looping ); } } @@ -1303,12 +1303,12 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub } // inverter sounds if( Vehicle.EngineType == TEngineType::ElectricInductionMotor ) { - if( Vehicle.InverterFrequency > 0.001 ) { + if( Vehicle.inductionMotor.inverterFrequency > 0.001 ) { - volume = inverter.m_amplitudeoffset + inverter.m_amplitudefactor * std::sqrt( std::abs( Vehicle.eimv_pr) ); + volume = inverter.m_amplitudeoffset + inverter.m_amplitudefactor * std::sqrt( std::abs( Vehicle.inductionMotor.forceShare) ); inverter - .pitch( inverter.m_frequencyoffset + inverter.m_frequencyfactor * Vehicle.InverterFrequency ) + .pitch( inverter.m_frequencyoffset + inverter.m_frequencyfactor * Vehicle.inductionMotor.inverterFrequency ) .gain( volume ) .play( sound_flags::exclusive | sound_flags::looping ); } diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index ece70ca4d..9fd5df13d 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -293,17 +293,17 @@ bool TDynamicObject::Update(double dt, double dt1) Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), p->MoverParameters->MED_Vref) * 1000; // sila hamowania pn - FmaxED += p->MoverParameters->Mains && p->MoverParameters->DirActive != 0 && p->MoverParameters->InvertersRatio == 1.0 && - p->MoverParameters->eimc[eimc_p_Fh] * p->MoverParameters->NPoweredAxles > 0 ? - p->MoverParameters->eimc[eimc_p_Fh] * 1000 : + FmaxED += p->MoverParameters->Mains && p->MoverParameters->DirActive != 0 && p->MoverParameters->inductionMotor.inverterRatio == 1.0 && + p->MoverParameters->inductionMotor.config[eimc_p_Fh] * p->MoverParameters->NPoweredAxles > 0 ? + p->MoverParameters->inductionMotor.config[eimc_p_Fh] * 1000 : 0; // chwilowy max ED -> do rozdzialu sil - FED -= std::min(p->MoverParameters->eimv[eimv_Fmax], 0.0) * + FED -= std::min(p->MoverParameters->inductionMotor.state[eimv_Fmax], 0.0) * 1000; // chwilowy max ED -> do rozdzialu sil - FfulED = std::min(p->MoverParameters->eimv[eimv_Fful], 0.0) * + FfulED = std::min(p->MoverParameters->inductionMotor.state[eimv_Fful], 0.0) * 1000; // chwilowy max ED -> do rozdzialu sil - FrED -= std::min(p->MoverParameters->eimv[eimv_Fmax], 0.0) * + FrED -= std::min(p->MoverParameters->inductionMotor.state[eimv_Fmax], 0.0) * 1000; // chwilowo realizowane ED -> do pneumatyki - Frj += std::max(p->MoverParameters->eimv[eimv_Fmax], 0.0) * + Frj += std::max(p->MoverParameters->inductionMotor.state[eimv_Fmax], 0.0) * 1000;// chwilowo realizowany napęd -> do utrzymującego masa += p->MoverParameters->TotalMass; osie += p->MoverParameters->NAxles; @@ -341,11 +341,11 @@ bool TDynamicObject::Update(double dt, double dt1) } auto Fzad = amax * LBR * masa; if ((MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB) - && MoverParameters->eimc[eimc_p_abed] < 0.001) || + && MoverParameters->inductionMotor.config[eimc_p_abed] < 0.001) || MoverParameters->EmergencyValveFlow > 0) Fzad = amax * masa; //pętla bezpieczeństwa - pełne służbowe if (MoverParameters->ScndS && - MoverParameters->Vel > MoverParameters->eimc[eimc_p_Vh1] && FmaxED > 0) + MoverParameters->Vel > MoverParameters->inductionMotor.config[eimc_p_Vh1] && FmaxED > 0) { Fzad = std::min(LBR * FmaxED, FfulED); } @@ -403,7 +403,7 @@ bool TDynamicObject::Update(double dt, double dt1) } } if (MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB) - && MoverParameters->eimc[eimc_p_abed] < 0.001) + && MoverParameters->inductionMotor.config[eimc_p_abed] < 0.001) FzadED = 0; //pętla bezpieczeństwa - bez ED auto const FzadPN = Fzad - FrED * MoverParameters->MED_FrED_factor; std::vector PrzekrF( np ); @@ -458,13 +458,13 @@ bool TDynamicObject::Update(double dt, double dt1) p = kier == true ? p->Next(Coupling::control) : p->Prev(Coupling::control) ) { if (FzEP[i] > 0.01 && - FzEP[i] > p->MoverParameters->TotalMass * p->MoverParameters->eimc[eimc_p_eped] + std::min(p->MoverParameters->eimv[eimv_Fmax], 0.) * 1000 && + FzEP[i] > p->MoverParameters->TotalMass * p->MoverParameters->inductionMotor.config[eimc_p_eped] + std::min(p->MoverParameters->inductionMotor.state[eimv_Fmax], 0.) * 1000 && !PrzekrF[i]) { - float przek1 = -std::min(p->MoverParameters->eimv[eimv_Fmax], 0.) * 1000 + + float przek1 = -std::min(p->MoverParameters->inductionMotor.state[eimv_Fmax], 0.) * 1000 + FzEP[i] - p->MoverParameters->TotalMass * - p->MoverParameters->eimc[eimc_p_eped] * 0.999; + p->MoverParameters->inductionMotor.config[eimc_p_eped] * 0.999; PrzekrF[i] = true; test = true; nPrzekrF++;