From f8143e4ef4b32fef943461e7625e161b9edc4e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20Elgs=C3=A6ter?= Date: Wed, 4 Dec 2024 15:41:27 +0100 Subject: [PATCH] fix accidentally added code during refactor --- Dynamic/Identification/DisturbanceIdentifier.cs | 13 +++++++------ Dynamic/PlantSimulator/PlantSimulator.cs | 5 ++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dynamic/Identification/DisturbanceIdentifier.cs b/Dynamic/Identification/DisturbanceIdentifier.cs index a490a69..6eb4a78 100644 --- a/Dynamic/Identification/DisturbanceIdentifier.cs +++ b/Dynamic/Identification/DisturbanceIdentifier.cs @@ -149,12 +149,13 @@ private static UnitDataSet RemoveSetpointAndOtherInputChangeEffectsFromDataSet(U var unitDataSet_adjusted = new UnitDataSet(unitDataSet); if (unitModel != null && pidParams != null) { + var pidModel1 = new PidModel(pidParams, "PID"); // BEGIN "no_dist" process simulation = // a simulation of the process that does not include any real Y_meas or u_pid, thus no effects of // disturbances are visible in this simulation - var pidModel1 = new PidModel(pidParams, "PID"); - var processSim_noDist = new PlantSimulator( + + var processSim_noDist = new PlantSimulator( new List { pidModel1, unitModel }); processSim_noDist.ConnectModels(unitModel, pidModel1); processSim_noDist.ConnectModels(pidModel1, unitModel,pidInputIdx); @@ -174,12 +175,12 @@ private static UnitDataSet RemoveSetpointAndOtherInputChangeEffectsFromDataSet(U inputData_noDist.Add(processSim_noDist.AddExternalSignal(pidModel1, SignalType.Setpoint_Yset), unitDataSet.Y_setpoint); inputData_noDist.CreateTimestamps(unitDataSet.GetTimeBase()); inputData_noDist.SetIndicesToIgnore(unitDataSet.IndicesToIgnore); - - + + // rewrite: - // (var processSim_noDist, var inputData_noDist) = PlantSimulator.CreateFeedbackLoop(unitDataSet, pidModel1, unitModel, pidInputIdx); + // (var processSim_noDist, var inputData_noDist) = PlantSimulator.CreateFeedbackLoop(unitDataSet, pidModel1, unitModel, pidInputIdx); var noDist_isOk = processSim_noDist.Simulate(inputData_noDist, out TimeSeriesDataSet simData_noDist); - noDist_isOk = false;//TODO: remove temporary + // noDist_isOk = false;//TODO: remove temporary if (noDist_isOk) { int idxFirstGoodValue = 0; diff --git a/Dynamic/PlantSimulator/PlantSimulator.cs b/Dynamic/PlantSimulator/PlantSimulator.cs index 8a34ab6..0cf9937 100644 --- a/Dynamic/PlantSimulator/PlantSimulator.cs +++ b/Dynamic/PlantSimulator/PlantSimulator.cs @@ -399,6 +399,8 @@ public string ConnectModels(ISimulatableModel upstreamModel, ISimulatableModel d /// /// Create a PlantSimulator and TimeSeriesDataSet from a UnitDataSet, PidModel and UnitModel to do closed-loop simulations /// + /// The feedback loop has no disturbance signal added, but this can be added to the returned PlantSimualtor as needed. + /// /// /// /// @@ -413,9 +415,6 @@ public static (PlantSimulator, TimeSeriesDataSet) CreateFeedbackLoop(UnitDataSet var signalId1 = plantSim.ConnectModels(unitModel, pidModel); var signalId2 = plantSim.ConnectModels(pidModel, unitModel, pidInputIdx); - // tell the simulator that there is a disturbance - // plantSim.AddExternalSignal(unitModel, SignalType.Disturbance_D); - var inputData = new TimeSeriesDataSet(); inputData.Add(signalId1, unitDataSet.Y_meas); inputData.Add(signalId2, unitDataSet.U.GetColumn(pidInputIdx));