Skip to content

Added test whether pure function calls impure function#608

Draft
mwetter wants to merge 2 commits intomasterfrom
issue607_pureFunctions
Draft

Added test whether pure function calls impure function#608
mwetter wants to merge 2 commits intomasterfrom
issue607_pureFunctions

Conversation

@mwetter
Copy link
Member

@mwetter mwetter commented Oct 3, 2025

This closes #607

@mwetter
Copy link
Member Author

mwetter commented Oct 3, 2025

Before merging, some models need to be corrected, and perhaps MSL need to be updated to 4.1. The output of the OpenModelica tests with this added check is

*** Warning: Buildings.Fluid.Geothermal.Borefields.Validation.Sandbox: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.DHC.ETS.Combined.Validation.ChillerBorefield: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.Validation.ClusterBoreholes_100boreholes: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.Validation.GFunction_SmallScaleValidation: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.DHC.Examples.Combined.SeriesConstantFlow: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.DHC.Examples.Combined.SeriesVariableFlow: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.Validation.GFunction_1borehole_5meters: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.DHC.Examples.Combined.SeriesVariableFlowAgentControl: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Boreholes.Examples.UTube: [/tmp/tmp-Buildings-10-ggmqnrlw/Buildings/Fluid/Geothermal/Boreholes/BaseClasses/temperatureDrop.mo:2:1-109:20:writable] Warning: Pure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.temperatureDrop' contains a call to impure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.exchangeValues'.
*** Warning: Buildings.Fluid.Geothermal.Boreholes.BaseClasses.Examples.SingleUTubeBoundaryCondition: [/tmp/tmp-Buildings-11-ziv2pr58/Buildings/Fluid/Geothermal/Boreholes/BaseClasses/temperatureDrop.mo:2:1-109:20:writable] Warning: Pure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.temperatureDrop' contains a call to impure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.exchangeValues'.
*** Warning: Buildings.Fluid.Geothermal.Boreholes.BaseClasses.Examples.BoreholeSegment: [/tmp/tmp-Buildings-12-vtlvreqc/Buildings/Fluid/Geothermal/Boreholes/BaseClasses/temperatureDrop.mo:2:1-109:20:writable] Warning: Pure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.temperatureDrop' contains a call to impure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.exchangeValues'.
*** Warning: Buildings.Utilities.IO.Files.Examples.Printer: [/tmp/tmp-Buildings-12-vtlvreqc/Buildings/Utilities/IO/Files/BaseClasses/printRealArray.mo:2:1-45:19:writable] Warning: Pure function 'Buildings.Utilities.IO.Files.BaseClasses.printRealArray' contains a call to impure function 'Modelica.Utilities.Streams.print'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.ThermalResponseFactors.Validation.GFunction_100boreholes: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.ThermalZones.EnergyPlus_24_2_0.Examples.SingleFamilyHouse.HeatPumpRadiantHeatingGroundHeatTransfer: [/tmp/tmp-Buildings-16-l0fc2ofh/Buildings/Fluid/Geothermal/Boreholes/BaseClasses/temperatureDrop.mo:2:1-109:20:writable] Warning: Pure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.temperatureDrop' contains a call to impure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.exchangeValues'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.Examples.RectangularBorefield: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Obsolete.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.HeatPumpRadiantHeatingGroundHeatTransfer: [/tmp/tmp-Buildings-17-7d2irxya/Buildings/Fluid/Geothermal/Boreholes/BaseClasses/temperatureDrop.mo:2:1-109:20:writable] Warning: Pure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.temperatureDrop' contains a call to impure function 'Buildings.Fluid.Geothermal.Boreholes.BaseClasses.exchangeValues'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.Examples.Borefields: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.DHC.ETS.Combined.Examples.ChillerBorefield: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Utilities.Clustering.Validation.KMeans_2d: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Utilities.Clustering.Validation.KMeans_1d: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.LoadAggregation.Validation.TemperatureResponseMatrix: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.Validation.Analytic_20Years: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.DHC.ETS.Combined.Subsystems.Validation.Borefield: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.Validation.Measured_SmallScale: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.Validation.FiniteDifference_1Week: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.
*** Warning: Buildings.Fluid.Geothermal.Borefields.Validation.ConstantHeatInjection_100Boreholes: [/home/mwetter/.openmodelica/libraries/Modelica 4.0.0+maint.om/Math/Random.mo:1057:5-1146:31:writable] Warning: Pure function 'Modelica.Math.Random.Utilities.initializeImpureRandom' contains a call to impure function 'Modelica.Math.Random.Utilities.initializeImpureRandom.setInternalState'.

@mwetter mwetter marked this pull request as draft October 3, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In regression tests, check for pure functions calling impure functions

1 participant

Comments