Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster support of choicesAllMatching #10273

Closed
casella opened this issue Feb 27, 2023 · 19 comments · Fixed by #10275 or #10536
Closed

Faster support of choicesAllMatching #10273

casella opened this issue Feb 27, 2023 · 19 comments · Fixed by #10275 or #10536
Assignees
Labels
COMP/GUI/OMEdit Issue and pull request related to OMEdit COMP/OMC/Frontend Issue and pull request related to the frontend
Milestone

Comments

@casella
Copy link
Contributor

casella commented Feb 27, 2023

Install the ThermofluidStream library, open the ThermofluidStream.Processes.Tests.ConvectivePipe and double click on the thermalConvection component. Getting the parameter input window requires about one minute.

Checking the omeditcommunication.log file shows the culprit of such slow performance:

getAllSubtypeOf(ThermofluidStream.Media.myMedia.Interfaces.PartialMedium,ThermofluidStream.Interfaces.SISOFlow,false,false,false) 19:24:02:723
{ThermofluidStream.Media.XRGMedia.R245fa_ph,ThermofluidStream.Media.XRGMedia.R1234yf_ph,ThermofluidStream.Media.XRGMedia.CO2_ph,ThermofluidStream.Media.XRGMedia.NH3_ph,ThermofluidStream.Media.XRGMedia.R134a_ph,ThermofluidStream.Media.myMedia.Water.WaterIF97_R3ph,ThermofluidStream.Media.myMedia.Water.WaterIF97_R2ph,ThermofluidStream.Media.myMedia.Water.WaterIF97_R1ph,ThermofluidStream.Media.myMedia.Water.WaterIF97_R2pT,ThermofluidStream.Media.myMedia.Water.WaterIF97_R1pT,ThermofluidStream.Media.myMedia.Water.WaterIF97_R5ph,ThermofluidStream.Media.myMedia.Water.WaterIF97_R4ph,ThermofluidStream.Media.myMedia.Water.WaterIF97_ph,ThermofluidStream.Media.myMedia.Water.WaterIF97_pT,ThermofluidStream.Media.myMedia.Water.WaterIF97OnePhase_ph,ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase,ThermofluidStream.Media.myMedia.Water.StandardWater,ThermofluidStream.Media.myMedia.Water.ConstantPropertyLiquidWater,ThermofluidStream.Media.myMedia.Water.IdealSteam,ThermofluidStream.Media.myMedia.R134a.R134a_ph,ThermofluidStream.Media.myMedia.Incompressible.TableBased,ThermofluidStream.Media.myMedia.Incompressible.Examples.TestGlycol.Medium,ThermofluidStream.Media.myMedia.Incompressible.Examples.Essotherm650,ThermofluidStream.Media.myMedia.Incompressible.Examples.Glycol47,ThermofluidStream.Media.myMedia.IdealGases.MixtureGases.SimpleNaturalGasFixedComposition,ThermofluidStream.Media.myMedia.IdealGases.MixtureGases.SimpleNaturalGas,ThermofluidStream.Media.myMedia.IdealGases.MixtureGases.FlueGasSixComponents,ThermofluidStream.Media.myMedia.IdealGases.MixtureGases.FlueGasLambdaOnePlus,ThermofluidStream.Media.myMedia.IdealGases.MixtureGases.SimpleMoistAir,ThermofluidStream.Media.myMedia.IdealGases.MixtureGases.AirSteam,ThermofluidStream.Media.myMedia.IdealGases.MixtureGases.CombustionAir,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.SO3,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.SO2,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.O2,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.Ne,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.N2O,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.N2,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.NO2,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.NO,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.NH3,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.He,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.H2O,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.H2,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.F2,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.CL2,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C8H18_n_octane,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C8H10_ethylbenz,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C7H16_n_heptane,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C7H14_1_heptene,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C6H14_n_hexane,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C6H12_1_hexene,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C6H6,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C5H12_n_pentane,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C5H10_1_pentene,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C4H10_n_butane,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C4H8_1_butene,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C3H8O_1propanol,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C3H8,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C3H6_propylene,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C2H6,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C2H5OH,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C2H4,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.C2H2_vinylidene,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.CO2,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.CO,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.CH3OH,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.CH4,ThermofluidStream.Media.myMedia.IdealGases.SingleGases.Ar,ThermofluidStream.Media.myMedia.CompressibleLiquids.LinearWater_pT_Ambient,ThermofluidStream.Media.myMedia.CompressibleLiquids.LinearColdWater,ThermofluidStream.Media.myMedia.Air.ReferenceMoistAir,ThermofluidStream.Media.myMedia.Air.MoistAir,ThermofluidStream.Media.myMedia.Air.ReferenceAir.Air_dT,ThermofluidStream.Media.myMedia.Air.ReferenceAir.Air_pT,ThermofluidStream.Media.myMedia.Air.ReferenceAir.Air_ph,ThermofluidStream.Media.myMedia.Air.DryAirNasa,ThermofluidStream.Media.myMedia.Air.SimpleAir,ThermofluidStream.Media.myMedia.Examples.Utilities.ShortPipe.Medium,ThermofluidStream.Media.myMedia.Examples.Utilities.FixedAmbient.Medium,ThermofluidStream.Media.myMedia.Examples.Utilities.FixedMassFlowRate.Medium,ThermofluidStream.Media.myMedia.Examples.Utilities.PortVolume.Medium,ThermofluidStream.Media.myMedia.Examples.Utilities.FluidPort.Medium,ThermofluidStream.Media.myMedia.Examples.SolveOneNonlinearEquation.Inverse_sh_TX.Medium,ThermofluidStream.Media.myMedia.Examples.SolveOneNonlinearEquation.InverseIncompressible_sh_T.Medium,ThermofluidStream.Media.myMedia.Examples.SolveOneNonlinearEquation.Inverse_sh_T.Medium,ThermofluidStream.Media.myMedia.Examples.ReferenceAir.MoistAir.Medium,ThermofluidStream.Media.myMedia.Examples.TwoPhaseWater,ThermofluidStream.Media.myMedia.Examples.PsychrometricData.Medium,ThermofluidStream.Media.myMedia.Examples.MoistAir.Medium,ThermofluidStream.Media.myMedia.Examples.MixtureGases.Medium2,ThermofluidStream.Media.myMedia.Examples.MixtureGases.Medium1,ThermofluidStream.Media.myMedia.Examples.WaterIF97.Medium,ThermofluidStream.Media.myMedia.Examples.IdealGasH2O.Medium,ThermofluidStream.Media.myMedia.Examples.SimpleLiquidWater.Medium,ThermofluidStream.Utilities.Functions.massFractionK.Medium,ThermofluidStream.Undirected.Internal.regStepState.Medium,ThermofluidStream.Undirected.Sensors.Tests.TestSensors.Medium2,ThermofluidStream.Undirected.Sensors.Tests.TestSensors.Medium,ThermofluidStream.Undirected.Sensors.SingleSensorX.Medium,ThermofluidStream.Undirected.Sensors.SensorState.Medium,ThermofluidStream.Undirected.Sensors.TwoPhaseSensorSelect.Medium2Phase,ThermofluidStream.Undirected.FlowControl.Tests.MCV.Medium,ThermofluidStream.Undirected.FlowControl.Tests.SpecificValveType.Medium,ThermofluidStream.Undirected.FlowControl.Tests.BasicControlValve.Medium,ThermofluidStream.Undirected.FlowControl.Tests.TanValve.Medium,ThermofluidStream.Undirected.FlowControl.Tests.CheckValve.Medium,ThermofluidStream.Undirected.HeatExchangers.Tests.TestDiscretizedHEXvsDir.MediumRefrigerant,ThermofluidStream.Undirected.HeatExchangers.Tests.TestDiscretizedHEXvsDir.MediumAir,ThermofluidStream.Undirected.HeatExchangers.Tests.ConductionElementTwoPhase.MediumRefrigerant,ThermofluidStream.Undirected.HeatExchangers.Tests.TestDiscretizedHEX.MediumRefrigerant,ThermofluidStream.Undirected.HeatExchangers.Tests.TestDiscretizedHEX.MediumAir,ThermofluidStream.Undirected.HeatExchangers.DiscretizedCounterFlowHEX.MediumB,ThermofluidStream.Undirected.HeatExchangers.DiscretizedCounterFlowHEX.MediumA,ThermofluidStream.Undirected.HeatExchangers.DiscretizedCrossFlowHEX.MediumB,ThermofluidStream.Undirected.HeatExchangers.DiscretizedCrossFlowHEX.MediumA,ThermofluidStream.Undirected.Processes.Tests.TransportDelay.Medium,ThermofluidStream.Undirected.Processes.Tests.ConductionElement.Medium,ThermofluidStream.Undirected.Topology.Tests.TestConnectors.Medium,ThermofluidStream.Undirected.Topology.Tests.TestJunction.Medium,ThermofluidStream.Undirected.Topology.JunctionRRRF.Medium,ThermofluidStream.Undirected.Topology.JunctionRRFF2.Medium,ThermofluidStream.Undirected.Topology.JunctionRRFF.Medium,ThermofluidStream.Undirected.Topology.JunctionRFFF.Medium,ThermofluidStream.Undirected.Topology.JunctionRRF2.Medium,ThermofluidStream.Undirected.Topology.JunctionRRF.Medium,ThermofluidStream.Undirected.Topology.JunctionRFF2.Medium,ThermofluidStream.Undirected.Topology.JunctionRFF.Medium,ThermofluidStream.Undirected.Topology.ConnectorInletOutletFore.Medium,ThermofluidStream.Undirected.Topology.ConnectRearRear.Medium,ThermofluidStream.Undirected.Topology.ConnectForeFore.Medium,ThermofluidStream.Undirected.Topology.ConnectForeOutlet.Medium,ThermofluidStream.Undirected.Topology.ConnectRearOutlet.Medium,ThermofluidStream.Undirected.Topology.ConnectInletRear.Medium,ThermofluidStream.Undirected.Topology.ConnectInletFore.Medium,ThermofluidStream.Undirected.Topology.JunctionMN.Medium,ThermofluidStream.Undirected.Boundaries.Tests.PhaseSeperator.Medium,ThermofluidStream.Undirected.Boundaries.Tests.VolumesDirectCoupling.MediumMix,ThermofluidStream.Undirected.Boundaries.Tests.VolumesDirectCoupling.Medium,ThermofluidStream.Undirected.Boundaries.Tests.Reservoir.Medium,ThermofluidStream.Undirected.Boundaries.Tests.TestVolumes.MediumMix,ThermofluidStream.Undirected.Boundaries.Tests.TestVolumes.Medium,ThermofluidStream.Undirected.Boundaries.TerminalRear.Medium,ThermofluidStream.Undirected.Boundaries.TerminalFore.Medium,ThermofluidStream.Undirected.Boundaries.BoundaryFore.Medium,ThermofluidStream.Undirected.Boundaries.BoundaryRear.Medium,ThermofluidStream.Undirected.Interfaces.Tests.Test_p_out_clipping.Medium,ThermofluidStream.Undirected.Interfaces.Rear.Medium,ThermofluidStream.Undirected.Interfaces.Fore.Medium,ThermofluidStream.Sensors.Internal.getTwoPhaseQuantity.Medium,ThermofluidStream.Sensors.Internal.getFlowQuantity.Medium,ThermofluidStream.Sensors.Internal.getQuantity.Medium,ThermofluidStream.Sensors.Tests.TestSensors.Medium3,ThermofluidStream.Sensors.Tests.TestSensors.Medium2,ThermofluidStream.Sensors.Tests.TestSensors.Medium1,ThermofluidStream.Sensors.MultiSensor_Tpm.Medium,ThermofluidStream.Sensors.SingleFlowSensor.Medium,ThermofluidStream.Sensors.DifferenceSensor_Tp.MediumB,ThermofluidStream.Sensors.DifferenceSensor_Tp.MediumA,ThermofluidStream.Sensors.DifferenceTwoPhaseSensorSensorSelect.MediumB,ThermofluidStream.Sensors.DifferenceTwoPhaseSensorSensorSelect.MediumA,ThermofluidStream.Sensors.DifferenceSensorSelect.MediumB,ThermofluidStream.Sensors.DifferenceSensorSelect.MediumA,ThermofluidStream.Sensors.MultiSensor_Tp.Medium,ThermofluidStream.Sensors.SingleSensorX.Medium,ThermofluidStream.Sensors.SensorState.Medium,ThermofluidStream.Sensors.TwoPhaseSensorSelect.Medium,ThermofluidStream.Sensors.SingleSensorSelect.Medium,ThermofluidStream.FlowControl.Tests.Switch.Medium,ThermofluidStream.FlowControl.Tests.PCV.Medium,ThermofluidStream.FlowControl.Tests.MCV.Medium,ThermofluidStream.FlowControl.Tests.SpecificValveType.medium,ThermofluidStream.FlowControl.Tests.BasicControlValve.medium,ThermofluidStream.FlowControl.Tests.TanValve.Medium,ThermofluidStream.FlowControl.Tests.CheckValve.Medium,ThermofluidStream.FlowControl.FourWaySwitch.Medium,ThermofluidStream.FlowControl.Switch.Medium,ThermofluidStream.HeatExchangers.Internal.calculateEfficency.MediumB,ThermofluidStream.HeatExchangers.Internal.calculateEfficency.MediumA,ThermofluidStream.HeatExchangers.Tests.FlowRes.MediumRefrigerant,ThermofluidStream.HeatExchangers.Tests.FlowRes.MediumAir,ThermofluidStream.HeatExchangers.Tests.Recuperator.MediumRefrigerant,ThermofluidStream.HeatExchangers.Tests.ElementTwoPhase.MediumRefrigerant,ThermofluidStream.HeatExchangers.Tests.Evaporator.MediumRefrigerant,ThermofluidStream.HeatExchangers.Tests.Evaporator.MediumAir,ThermofluidStream.HeatExchangers.Tests.Condenser.MediumRefrigerant,ThermofluidStream.HeatExchangers.Tests.Condenser.MediumAir,ThermofluidStream.HeatExchangers.Tests.CrossFlowNTU_zeroMassFlow.MediumB,ThermofluidStream.HeatExchangers.Tests.CrossFlowNTU_zeroMassFlow.MediumA,ThermofluidStream.HeatExchangers.Tests.CrossFlowNTU.MediumB,ThermofluidStream.HeatExchangers.Tests.CrossFlowNTU.MediumA,ThermofluidStream.HeatExchangers.Tests.CounterFlowNTU_parallel.MediumB,ThermofluidStream.HeatExchangers.Tests.CounterFlowNTU_parallel.MediumA,ThermofluidStream.HeatExchangers.Tests.CounterFlowNTU_serial.MediumB,ThermofluidStream.HeatExchangers.Tests.CounterFlowNTU_serial.MediumA,ThermofluidStream.HeatExchangers.Tests.CounterFlowNTU_zeroMassFlow.MediumB,ThermofluidStream.HeatExchangers.Tests.CounterFlowNTU_zeroMassFlow.MediumA,ThermofluidStream.HeatExchangers.Tests.CounterFlowNTU.MediumB,ThermofluidStream.HeatExchangers.Tests.CounterFlowNTU.MediumA,ThermofluidStream.HeatExchangers.DiscretizedCounterFlowHEX_FR.MediumB,ThermofluidStream.HeatExchangers.DiscretizedCounterFlowHEX_FR.MediumA,ThermofluidStream.HeatExchangers.DiscretizedCrossFlowHEX_FR.MediumB,ThermofluidStream.HeatExchangers.DiscretizedCrossFlowHEX_FR.MediumA,ThermofluidStream.HeatExchangers.DiscretizedCounterFlowHEX.MediumB,ThermofluidStream.HeatExchangers.DiscretizedCounterFlowHEX.MediumA,ThermofluidStream.HeatExchangers.DiscretizedCrossFlowHEX.MediumB,ThermofluidStream.HeatExchangers.DiscretizedCrossFlowHEX.MediumA,ThermofluidStream.HeatExchangers.CrossFlowNTU.MediumB,ThermofluidStream.HeatExchangers.CrossFlowNTU.MediumA,ThermofluidStream.HeatExchangers.CounterFlowNTU.MediumB,ThermofluidStream.HeatExchangers.CounterFlowNTU.MediumA,ThermofluidStream.Processes.Tests.Nozzle.Medium,ThermofluidStream.Processes.Tests.TransportDelay.Medium,ThermofluidStream.Processes.Tests.ConductionElement.Medium,ThermofluidStream.Processes.Tests.ConvectivePipe_serial.Medium,ThermofluidStream.Processes.Tests.ConvectivePipe.Medium,ThermofluidStream.Processes.Tests.Turbine.Medium,ThermofluidStream.Processes.Tests.Compressor.Medium,ThermofluidStream.Processes.Tests.Pump.Medium,ThermofluidStream.Processes.Tests.Flow_Resistance.Medium,ThermofluidStream.Topology.Internal.SplitterRatio.Medium,ThermofluidStream.Topology.Tests.TestNonPhysical.Medium,ThermofluidStream.Topology.Tests.TestJunctionNM.Medium,ThermofluidStream.Topology.Tests.TestDynamicTopology.Medium,ThermofluidStream.Topology.Tests.TestSplitter.Medium,ThermofluidStream.Topology.Tests.TestJunction.Medium,ThermofluidStream.Topology.NonPhysical.JunctionRatio.Medium,ThermofluidStream.Topology.DynamicJunctionNM.Medium,ThermofluidStream.Topology.DynamicSplitterN.Medium,ThermofluidStream.Topology.DynamicJunctionN.Medium,ThermofluidStream.Topology.JunctionNM.Medium,ThermofluidStream.Topology.JunctionN.Medium,ThermofluidStream.Topology.SplitterN.Medium,ThermofluidStream.Topology.JunctionX3.Medium,ThermofluidStream.Topology.JunctionX2.Medium,ThermofluidStream.Topology.JunctionX1.Medium,ThermofluidStream.Topology.SplitterX.Medium,ThermofluidStream.Topology.JunctionT2.Medium,ThermofluidStream.Topology.JunctionT1.Medium,ThermofluidStream.Topology.SplitterT2.Medium,ThermofluidStream.Topology.SplitterT1.Medium,ThermofluidStream.Boundaries.Tests.PhaseSeperator.Medium,ThermofluidStream.Boundaries.Tests.DynamicBoundaries.Medium,ThermofluidStream.Boundaries.Tests.VolumesDirectCoupling.MediumMix,ThermofluidStream.Boundaries.Tests.VolumesDirectCoupling.Medium,ThermofluidStream.Boundaries.Tests.TerminalSourceSink.Medium,ThermofluidStream.Boundaries.Tests.Reservoir.Medium,ThermofluidStream.Boundaries.Tests.Volumes.MediumMix,ThermofluidStream.Boundaries.Tests.Volumes.Medium,ThermofluidStream.Boundaries.Tests.SourceSink.Medium,ThermofluidStream.Boundaries.CreateState.Medium,ThermofluidStream.Boundaries.TerminalSink.Medium,ThermofluidStream.Boundaries.TerminalSource.Medium,ThermofluidStream.Boundaries.Sink.Medium,ThermofluidStream.Boundaries.Source.Medium,ThermofluidStream.Interfaces.Tests.Test_p_out_clipping.Medium,ThermofluidStream.Interfaces.StateOutput.Medium,ThermofluidStream.Interfaces.StateInput.Medium,ThermofluidStream.Interfaces.Outlet.Medium,ThermofluidStream.Interfaces.Inlet.Medium,ThermofluidStream.Examples.Utilities.Tests.BoilerEspresso.Water,ThermofluidStream.Examples.Utilities.Tests.Piston.Medium,ThermofluidStream.Examples.Utilities.CupSink.Medium,ThermofluidStream.Examples.Utilities.Piston.Medium,ThermofluidStream.Examples.Utilities.CoffeeStrainer.Medium,ThermofluidStream.Examples.Utilities.BoilerEspresso.Medium,ThermofluidStream.Examples.ReverseHeatPump.RefrigerantMedium,ThermofluidStream.Examples.ReverseHeatPump.SecondaryMedium,ThermofluidStream.Examples.HeatPump.Air,ThermofluidStream.Examples.HeatPump.Medium,ThermofluidStream.Examples.VaporCycle.RefrigerantMedium,ThermofluidStream.Examples.VaporCycle.SecondaryMedium,ThermofluidStream.Examples.VenturiPump.Medium,ThermofluidStream.Examples.EspressoMachine.Water,ThermofluidStream.Examples.WaterHammer.Medium,ThermofluidStream.Examples.SimpleCoolingCycle.Medium_air,ThermofluidStream.Examples.SimpleCoolingCycle.Medium_liquid,ThermofluidStream.Examples.SimpleGasTurbine.Medium,ThermofluidStream.Examples.SimpleEngine.Water,ThermofluidStream.Examples.SimpleAirCycle.Medium_bleed,ThermofluidStream.Examples.SimpleAirCycle.Medium_ram,ThermofluidStream.Examples.SimpleStream.Medium} 19:24:43:699
#s#; 40.971000; 44.264000; 'getAllSubtypeOf(ThermofluidStream.Media.myMedia.Interfaces.PartialMedium,ThermofluidStream.Interfaces.SISOFlow,false,false,false)'

The bulk of the time is spent getting all the subtypes of ThermofluidStream.Media.myMedia.Interfaces.PartialMedium.

The way this is currently implemented is not efficient. According to @adrpo, it should be replaced by caching this information during parsing. Then, this should be added to the new instantiation-based interface, which currently doesn't support choicesAllMatching.

@adrpo, @perost, can you agree on a plan so that @perost can implement it at his earliest convenience?

@casella casella added COMP/OMC/Frontend Issue and pull request related to the frontend COMP/GUI/OMEdit Issue and pull request related to OMEdit labels Feb 27, 2023
@casella casella added this to the 1.21.0 milestone Feb 27, 2023
@casella
Copy link
Contributor Author

casella commented Feb 27, 2023

Adding @rfranke to the loop, he reported the specific test case.

perost added a commit to perost/OpenModelica that referenced this issue Feb 28, 2023
- Only expand packages when doing lookup for getAllSubtypeOf, since
  fully instantiating them is unnecessary and slow in that context.

Fixes OpenModelica#10273
@perost
Copy link
Member

perost commented Feb 28, 2023

#10275 improves the performance significantly by trying to avoid fully instantiating packages during lookup when it's not needed for getAllSubtypeOf. This brings the time down from about 23s to 0.6s on my computer.

I think it could be improved further since the implementation right now only uses the NF for doing lookup, so it's doing a lot of unnecessary things. But that would require completely rewriting the whole implementation, and it's probably good enough for now.

perost added a commit that referenced this issue Feb 28, 2023
- Only expand packages when doing lookup for getAllSubtypeOf, since
  fully instantiating them is unnecessary and slow in that context.

Fixes #10273
@casella
Copy link
Contributor Author

casella commented Feb 28, 2023

@rfranke please test and report.

@rfranke
Copy link
Member

rfranke commented Feb 28, 2023

Wow. It's like day and night on my Linux development machine. Looking forward to trying out the new nightly build on my Windows laptop tomorrow!

@rfranke
Copy link
Member

rfranke commented Mar 31, 2023

One thing changed to the worse: most Fluid models define a Medium locally to the model, e.g. Modelica.Fluid.Examples.PumpingSystem:

model PumpingSystem "Model of a pumping system for drinking water"
  extends Modelica.Icons.Example;
  replaceable package Medium = Modelica.Media.Water.StandardWaterOnePhase constrainedby Modelica.Media.Interfaces.PartialMedium;
  Modelica.Fluid.Sources.FixedBoundary source(redeclare package Medium = Medium);
  ...
end PumpingSystem;

OMEdit doesn't show this in the list of Medium options anymore. It only appears if it had already been selected before (e.g. in an existing example). It does not appear in newly added component models.

Previous versions were showing PumpingSystem.Medium as last option of the list in OMEdit. This was neither perfect. It should ideally be the first option and just be Medium to allow later modifications like:

model ModifiedPumpingSystem
  extends PumpingSystem(redeclare replaceable package Medium = SomethingOther);
end ModifiedPumpingSystem;

A component using PumpingSystem.Medium would not change it to ModifiedPumpingSystem.Medium.

@rfranke rfranke reopened this Mar 31, 2023
@perost
Copy link
Member

perost commented Mar 31, 2023

@rfranke: It looks like the issue is that OMEdit calls:

getAllSubtypeOf(Modelica.Media.Interfaces.PartialMedium,Modelica.Fluid.Sources.BaseClasses.PartialSource,false,false,false)

In #10277 I changed getAllSubtypeOf to only look inside packages like the specification says, but with the exception of local classes in the parent class.

However, OMEdit gives Modelica.Fluid.Sources.BaseClasses.PartialSource as the parent class here (where Medium in source is defined), but I think PumpingSystem should be used as the parent class instead. What do you think @adeas31?

If PumpingSystem is given as the parent instead then we get Modelica.Fluid.Examples.PumpingSystem.Medium as the last option in the list. However, as you point out we should probably put it first in the list instead and not fully qualify the names found in the parent model. I can take a look at that.

@perost
Copy link
Member

perost commented Mar 31, 2023

#10487 improves getAllSubtypeOf so that locally declared classes are not fully qualified and also put first in the list. But the issue with OMEdit also needs to fixed before those classes actually show up in the list.

I also removed a weirdly placed listReverse so the returned list is now reversed from before. I could have kept the same ordering by just reversing the list in a more appropriate place, but I didn't really see the point since the ordering is kind of arbitrary anyway.

@casella
Copy link
Contributor Author

casella commented Mar 31, 2023

@rfranke please try this with the next nightly. If that is OK for you, we can cherry pick this fix into 1.21.0

@rfranke
Copy link
Member

rfranke commented Apr 3, 2023

Thank you for the change of getAllSubtypeOf!

It works better now, but still a bit confusing. It works when adding e.g. a ThermofluidStream.Sensors.MultiSensor_Tpm that happens to define a package Medium. It does not work for e.g. Modelica.Fluid.Volumes.ClosedVolume, where Medium is defined in a base class it extends from. And it does not work with e.g. ThermofluidStream.Examples.SimpleAirCycle that uses different package names Medium_ram and Medium_bleed.

@adeas31 would need to also change the call to getAllSubtypeOf as @perost explains above.

@adeas31
Copy link
Member

adeas31 commented Apr 5, 2023

#10506 will fix this for old api which is still default in OMEdit. Need more work to fix this for instance api.

@casella
Copy link
Contributor Author

casella commented Apr 5, 2023

@adeas31 can you please also cherry-pick this on maintenance/v1.21?

@rfranke
Copy link
Member

rfranke commented Apr 6, 2023

Looks good!
I can cherry pick it along with a C++ fix for Record inputs to external functions.

@rfranke
Copy link
Member

rfranke commented Apr 6, 2023

Unfortunately testsuite-clang-metamodelica failed that should be unrelated though :(

@casella
Copy link
Contributor Author

casella commented Apr 6, 2023

Hope it works with @sjoelund's fix.

@rfranke
Copy link
Member

rfranke commented Apr 6, 2023

Cherry picking another useful commit, all tests passed. But now the license/cla hangs.
@adeas31 or @sjoelund can you please check PR #10508?

@adeas31
Copy link
Member

adeas31 commented Apr 6, 2023

Try to force push to the branch so that license cla will be resend.

@rfranke
Copy link
Member

rfranke commented Apr 6, 2023

Huuh. Removed the additional commit again and now both passed: tests and cla.

@rfranke rfranke closed this as completed Apr 6, 2023
@casella
Copy link
Contributor Author

casella commented Apr 6, 2023

Great, thanks @rfranke!

@adeas31
Copy link
Member

adeas31 commented Apr 12, 2023

#10536 makes sure that this works as expected when instance API is used.
I will port this to maintenance branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP/GUI/OMEdit Issue and pull request related to OMEdit COMP/OMC/Frontend Issue and pull request related to the frontend
Projects
None yet
5 participants