text
stringlengths
1
4.74k
code
stringlengths
69
637k
Control to avoid Legionella in the DHW. This model represents the anti legionella control of a real heat pump. Based on a daily or weekly approach, the given supply temperature is raised above the minimal temperature required for the thermal desinfection (at least 60 °C) for a given duration minTimeAntLeg.
within AixLib.Controls.HeatPump; model AntiLegionella "Control to avoid Legionella in the DHW" parameter Modelica.Units.SI.ThermodynamicTemperature TLegMin=333.15 "Temperature at which the legionella in DWH dies"; parameter Modelica.Units.SI.Time minTimeAntLeg "Minimal duration of antilegionella control"; parameter Boolean weekly=true "Switch between a daily or weekly trigger approach" parameter Integer trigWeekDay "Day of the week at which control is triggered" parameter Integer trigHour "Hour of the day at which control is triggered"; parameter AixLib.Utilities.Time.Types.ZeroTime zerTim "Enumeration for choosing how reference time (time = 0) should be defined"; parameter Integer yearRef=2016 "Year when time = 0, used if zerTim=Custom"; Modelica.Blocks.Logical.GreaterEqual TConLessTLegMin "Compare if current TCon is smaller than the minimal TLeg" AixLib.Utilities.Logical.SmoothSwitch switchTLeg "Switch to Legionalla control if needed" Modelica.Blocks.Interfaces.RealOutput TSet_out "Set value for the condenser outlet temperature" Modelica.Blocks.Sources.Constant constTLegMin(final k=TLegMin) "Temperature at which the legionella in DWH dies" Modelica.Blocks.Logical.Timer timeAntiLeg "Time in which legionella will die" Modelica.Blocks.Logical.GreaterThreshold greaterThreshold(final threshold=minTimeAntLeg) Modelica.Blocks.Interfaces.RealInput TSet_in "Input of TSet" Modelica.Blocks.Logical.Pre pre1 AixLib.Utilities.Time.DaytimeSwitch daytimeSwitch( final hourDay=trigHour, final zerTim=zerTim, final yearRef=yearRef, final weekDay=trigWeekDay) "If given day and hour match the current daytime, output will be true" Modelica.Blocks.MathInteger.TriggeredAdd triggeredAdd(use_reset=true, use_set= false, y_start=0) "See info of model for description" Modelica.Blocks.Sources.IntegerConstant intConPluOne(final k=1) "Value for counting" Modelica.Blocks.Logical.LessThreshold lessThreshold(final threshold=1) "Checks if value is less than one" Modelica.Blocks.Math.IntegerToReal intToReal "Converts Integer to Real" Modelica.Blocks.Interfaces.RealInput TSupAct "Input of actual supply temperature" equation connect(constTLegMin.y, TConLessTLegMin.u2) connect(switchTLeg.y, TSet_out) connect(TSet_in, switchTLeg.u1) connect(switchTLeg.u3, constTLegMin.y) connect(timeAntiLeg.u, pre1.y) connect(TConLessTLegMin.y, pre1.u) connect(lessThreshold.y, switchTLeg.u2) connect(intToReal.y, lessThreshold.u) connect(intConPluOne.y, triggeredAdd.u) connect(intToReal.u, triggeredAdd.y) connect(greaterThreshold.y, triggeredAdd.reset) connect(TSupAct, TConLessTLegMin.u1) connect(daytimeSwitch.isDaytime, triggeredAdd.trigger) connect(timeAntiLeg.y, greaterThreshold.u) end AntiLegionella;
Control block to ensure no frost limits heat flow at the evaporator. Basic model for a defrost control. The icing factor is calculated in the heat pump based on functions or other models.
within AixLib.Controls.HeatPump; model DefrostControl "Control block to ensure no frost limits heat flow at the evaporator" parameter Real minIceFac "Minimal value above which no defrost is necessary"; parameter Real deltaIceFac = 0.1 "Bandwitdth for hystereses. If the icing factor is based on the duration of defrost, this value is necessary to avoid state-events."; Modelica.Blocks.Interfaces.BooleanInput hea Modelica.Blocks.Interfaces.RealInput ySet "Set value relative speed of compressor. Analog from 0 to 1" Utilities.Logical.SmoothSwitch swiErr "If an error occurs, the value of the conZero block will be used(0)" Modelica.Blocks.Sources.Constant conOne(final k=1) "If Defrost is enabled, HP runs at full power" Modelica.Blocks.Interfaces.RealOutput yOut "Relative speed of compressor. From 0 to 1" Modelica.Blocks.Interfaces.BooleanOutput heaOut Fluid.HeatPumps.ModularReversible.BaseClasses.RefrigerantMachineControlBus sigBus Modelica.Blocks.Logical.Hysteresis iceFacGreMinChi( final uLow=minIceFac, final uHigh=minIceFac + deltaIceFac, final pre_y_start=true) "Check if icing factor is greater than a boundary" Modelica.Blocks.Logical.LogicalSwitch logicalSwitch "If a chiller is used to defrost, mode will be false" Modelica.Blocks.Sources.BooleanConstant conTrueUseChi(final k=false) "Set mode to false to simulate the defrost cycle" equation connect(conOne.y, swiErr.u3) connect(swiErr.y,yOut) connect(ySet, swiErr.u1) connect(sigBus.iceFacMea, iceFacGreMinChi.u) connect(iceFacGreMinChi.y, swiErr.u2) connect(logicalSwitch.y, heaOut) connect(hea, logicalSwitch.u1) connect(iceFacGreMinChi.y, logicalSwitch.u2) connect(conTrueUseChi.y, logicalSwitch.u3) end DefrostControl;
Control block which makes sure the desired temperature is supplied by the HP. Model of a heat pump controller, setting a compressor signal and heat pump mode based on a given input temperarute. A heating curve is used to determine the supply temperature. This TSet is later converted to a signal nSet based on the acutal temperature in the system. Futhermore, a legionella protection for DHW-Simulation is implemented.
within AixLib.Controls.HeatPump; model HPControl "Control block which makes sure the desired temperature is supplied by the HP" //General replaceable model TSetToNSet = AixLib.Controls.HeatPump.BaseClasses.PartialTSetToNSet constrainedby AixLib.Controls.HeatPump.BaseClasses.PartialTSetToNSet( final use_secHeaGen=use_secHeaGen) parameter Boolean use_secHeaGen=false "True to choose a bivalent system" //Heating Curve parameter Boolean use_tableData=true "Choose between tables or function to calculate TSet" replaceable function HeatingCurveFunction = SetPoints.Functions.HeatingCurveFunction constrainedby SetPoints.Functions.PartialBaseFct parameter AixLib.DataBase.Boiler.DayNightMode.HeatingCurvesDayNightBaseDataDefinition heatingCurveRecord= AixLib.DataBase.Boiler.DayNightMode.HeatingCurves_Vitotronic_Day25_Night10() "Record with information about heating curve data" parameter Real declination=2 "Declination of curve" parameter Real day_hour=6 "Hour of day at which day mode is enabled" parameter Real night_hour=22 "Hour of day at which night mode is enabled" parameter AixLib.Utilities.Time.Types.ZeroTime zerTim=AixLib.Utilities.Time.Types.ZeroTime.NY2017 "Enumeration for choosing how reference time (time = 0) should be defined. Used for heating curve and antilegionella" //Anti Legionella parameter Boolean use_antLeg "True if Legionella Control is of relevance" parameter Modelica.Units.SI.ThermodynamicTemperature TLegMin=333.15 "Temperature at which the legionella in DWH dies" parameter Modelica.Units.SI.Time minTimeAntLeg "Minimal duration of antilegionella control" parameter Boolean weekly=true "Switch between a daily or weekly trigger approach" parameter Integer trigWeekDay "Day of the week at which control is triggered" parameter Integer trigHour=3 "Hour of the day at which control is triggered" AixLib.Controls.HeatPump.AntiLegionella antiLegionella( final TLegMin=TLegMin, minTimeAntLeg=minTimeAntLeg, trigWeekDay=trigWeekDay, trigHour=trigHour, yearRef=2017, final zerTim=zerTim) if use_antLeg AixLib.Fluid.HeatPumps.ModularReversible.BaseClasses.RefrigerantMachineControlBus sigBusHP Modelica.Blocks.Interfaces.RealOutput yOut "Relative compressor speed" Modelica.Blocks.Interfaces.RealInput T_oda "Outdoor air temperature" Modelica.Blocks.Interfaces.RealOutput ySecHeaGen if use_secHeaGen "Relative power of second heat generator, from 0 to 1" Modelica.Blocks.Interfaces.RealOutput y_sou Modelica.Blocks.Interfaces.RealOutput y_sin Modelica.Blocks.Sources.Constant constHeating1(final k=1) "If you want to include chilling, please insert control blocks first" AixLib.Controls.SetPoints.HeatingCurve heatCurve( final TOffset=0, final use_dynTRoom=false, final zerTim=zerTim, final day_hour=day_hour, final night_hour=night_hour, final heatingCurveRecord=heatingCurveRecord, final declination=declination, redeclare function HeatingCurveFunction = HeatingCurveFunction, use_tableData=use_tableData, final TRoom_nominal=293.15) TSetToNSet ConvTSetToNSet Modelica.Blocks.Routing.RealPassThrough realPasThrAntLeg if not use_antLeg "No Anti Legionella" Modelica.Blocks.Sources.BooleanConstant constHeating(final k=true) "If you want to include chilling, please insert control blocks first" Modelica.Blocks.Interfaces.BooleanOutput hea "Heating mode" Modelica.Blocks.Interfaces.RealInput TSup "Supply temperature" equation connect(T_oda, sigBusHP.T_oda) connect(T_oda, heatCurve.T_oda) connect(heatCurve.TSet, antiLegionella.TSet_in) connect(antiLegionella.TSet_out,ConvTSetToNSet. TSet) connect(ConvTSetToNSet.nOut,yOut) connect(sigBusHP,ConvTSetToNSet. sigBusHP) connect(heatCurve.TSet, realPasThrAntLeg.u) connect(realPasThrAntLeg.y,ConvTSetToNSet. TSet) connect(hea, constHeating.y) connect(TSup, antiLegionella.TSupAct) connect(TSup,ConvTSetToNSet.TMea) connect(ConvTSetToNSet.ySecHeaGen, ySecHeaGen) connect(ySecHeaGen, ySecHeaGen) connect(constHeating1.y, y_sou) connect(constHeating1.y, y_sin) end HPControl;
Converter model for an inverter / speed controlled HP modulating between 0 and 1.
within AixLib.Controls.HeatPump; model InverterControlledHP "Converter model for an inverter / speed controlled HP modulating between 0 and 1" extends BaseClasses.PartialTSetToNSet; parameter Real bandwidth "Bandwith of hysteresis of controller"; parameter Real k "Gain of controller" parameter Modelica.Units.SI.Time Ti "Time constant of Integrator block" parameter Real yMin=0.2 "Minimal relative compressor speed" Modelica.Blocks.Logical.OnOffController onOffController(bandwidth=bandwidth, pre_y_start=false) "Hysteresis controller for set temperature" Modelica.Blocks.Continuous.LimPID InverterControl( final controllerType=Modelica.Blocks.Types.SimpleController.PI, final k=k, final Ti=Ti, final yMax=1, final yMin=yMin) "PI-Control for a inverter controlled HP" equation connect(TSet, onOffController.reference) connect(InverterControl.y, swiNullHP.u1) connect(TSet, InverterControl.u_s) connect(TMea, onOffController.u) connect(TMea, InverterControl.u_m) connect(onOffController.y, andHeaLim.u1) end InverterControlledHP;
Contains typical controllers for heat pumps
within AixLib.Controls; package HeatPump "Contains typical controllers for heat pumps" extends Modelica.Icons.VariantsPackage; end HeatPump;
Controller gives full speed or stop signal depending on temperature hysteresis.
within AixLib.Controls.HeatPump; model TwoPointControlledHP "Controller gives full speed or stop signal depending on temperature hysteresis" extends AixLib.Controls.HeatPump.BaseClasses.PartialTSetToNSet; parameter Real bandwidth "Bandwith of hysteresis of controller"; Modelica.Blocks.Logical.OnOffController onOffController(final bandwidth=bandwidth, final pre_y_start=false) "Hysteresis controller for set temperature" Modelica.Blocks.Sources.Constant conOne(final k=1) "Constant one for on off heat pump" equation connect(TSet, onOffController.reference) connect(conOne.y, swiNullHP.u1) connect(TMea, onOffController.u) connect(onOffController.y, andHeaLim.u1) end TwoPointControlledHP;
Package with base classes for the HeatPump controller
within AixLib.Controls.HeatPump; package BaseClasses "Package with base classes for the HeatPump controller" end BaseClasses;
Base class of a heat pump controller with bus interface. Base class for heat pump controllers that contains the <a href= \"modelica://AixLib.Controls.Interfaces.HeatPumpControlBus\">AixLib.Controls.Interfaces.HeatPumpControlBus</a>.
within AixLib.Controls.HeatPump.BaseClasses; partial model PartialHPController "Base class of a heat pump controller with bus interface" AixLib.Fluid.HeatPumps.ModularReversible.BaseClasses.RefrigerantMachineControlBus heatPumpControlBus end PartialHPController;
Partial model to convert set temperature to compressor speed of heat pump.
within AixLib.Controls.HeatPump.BaseClasses; partial model PartialTSetToNSet "Partial model to convert set temperature to compressor speed of heat pump" parameter Boolean use_secHeaGen=false "True to choose a bivalent system" // Heating limit temperature parameter Boolean use_heaLim=true "=false to disable moving average heating limit" parameter Modelica.Units.SI.Temperature T_heaLim=293.15 "Heating limit temperature. If the filtered outdoor air temperature surpasses this threshold, the device will be shut down" parameter Modelica.Units.SI.Time movAveTime=300 "Time span for building the average of the outdoor air temperature. Used for heating limit temperature" Modelica.Blocks.Logical.Switch swiNullHP "If HP is off, zero is passed" Modelica.Blocks.Sources.Constant conZer(final k=0) "If an error occurs, the compressor speed is set to zero" Modelica.Blocks.Interfaces.RealInput TSet( final quantity="ThermodynamicTemperature", final unit="K", final displayUnit="degC") "Set temperature" Modelica.Blocks.Interfaces.RealOutput nOut "Relative speed of compressor. From 0 to 1" AixLib.Fluid.HeatPumps.ModularReversible.BaseClasses.RefrigerantMachineControlBus sigBusHP Modelica.Blocks.Interfaces.RealOutput ySecHeaGen if use_secHeaGen "Relative power of second heat generator, from 0 to 1" Modelica.Blocks.Interfaces.RealInput TMea( final quantity="ThermodynamicTemperature", final unit="K", final displayUnit="degC") "Actual temperature, control variable" AixLib.Utilities.Logical.SmoothSwitch swiNullsecHeaGen if use_secHeaGen "If second heater is off, zero is passed" AixLib.Utilities.Math.MovingAverage movAve(final aveTime=movAveTime, final u_start=0) if use_heaLim "Moving average to account for fluctuations in the outdoor air temperature" Modelica.Blocks.Logical.And andHeaLim "Check if control and heating limit temperature yield true to turn the device on" Modelica.Blocks.Logical.LessThreshold lessThreshold(final threshold= T_heaLim) if use_heaLim Modelica.Blocks.Sources.BooleanConstant booleanConstant(final k=true) if not use_heaLim equation connect(conZer.y, swiNullHP.u3) connect(swiNullHP.y, nOut) connect(swiNullsecHeaGen.y, ySecHeaGen) connect(conZer.y, swiNullsecHeaGen.u3) connect(sigBusHP.T_oda, movAve.u) connect(movAve.y, lessThreshold.u) connect(lessThreshold.y, andHeaLim.u2) connect(andHeaLim.y, swiNullHP.u2) connect(booleanConstant.y, andHeaLim.u2) end PartialTSetToNSet;
<html><p> Example for an inverter controlled heat pump. Play around with the PI settings to see how they influence nSet depending on TSet and TMea. </p> </html>. Example for an inverter controlled heat pump. Play around with the PI settings to see how they influence nSet depending on TSet and TMea.
within AixLib.Controls.HeatPump.Examples; model InverterControlledHeatPump extends Modelica.Icons.Example; extends PartialHeatPumpController(redeclare InverterControlledHP hPController( bandwidth=2, k=0.05, Ti=100)); end InverterControlledHeatPump;
Examples for controller and interface usage
within AixLib.Controls.HeatPump; package Examples "Examples for controller and interface usage" extends Modelica.Icons.ExamplesPackage; end Examples;
Example for usage of heat pump controller. Partial example model for heat pump controls.
within AixLib.Controls.HeatPump.Examples; partial model PartialHeatPumpController "Example for usage of heat pump controller" AixLib.Fluid.HeatPumps.ModularReversible.BaseClasses.RefrigerantMachineControlBus heatPumpControlBus "Required to make the signals on the bus accessible" Modelica.Blocks.Sources.Sine T_meas( f=1/3600, amplitude=6, offset=310) "Generates the measured temperature" Modelica.Blocks.Sources.Constant T_set(k=310) "Provides the temperature set point" Modelica.Blocks.Interfaces.RealOutput TMea( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="degC", min=0) "Outputs the temperature measurement" replaceable BaseClasses.PartialTSetToNSet hPController constrainedby BaseClasses.PartialTSetToNSet( final use_secHeaGen=false, use_heaLim=false, T_heaLim=293.15, movAveTime=300) Modelica.Blocks.Interfaces.RealOutput TSet( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="degC", min=0) "Outputs the temperature measurement" Modelica.Blocks.Interfaces.RealOutput nSet "Outputs the temperature measurement" Modelica.Blocks.Sources.Constant T_oda(k=273.15) "Provides the temperature set point" equation connect(T_meas.y, TMea) connect(hPController.TSet, T_set.y) connect(hPController.TMea, T_meas.y) connect(nSet, hPController.nOut) connect(T_oda.y, heatPumpControlBus.TOdaMea) connect(heatPumpControlBus, hPController.sigBusHP) connect(T_set.y, TSet) end PartialHeatPumpController;
<html><p> Example for an two-point hysteresis controlled heat pump. Play around with the bandwith settings to see how it influence nSet depending on TSet and TMea. </p> </html>. Example for an two-point hysteresis controlled heat pump. Play around with the bandwith settings to see how it influence nSet depending on TSet and TMea.
within AixLib.Controls.HeatPump.Examples; model TwoPointControlledHeatPump extends Modelica.Icons.Example; extends PartialHeatPumpController(redeclare TwoPointControlledHP hPController( bandwidth=2)); end TwoPointControlledHeatPump;
Model of an internal controller for modular compressors. This a controller block used for modular compressor models as presented in <a href= \"modelica://AixLib.Fluid.Movers.Compressors.ModularCompressors\">AixLib.Fluid.Movers.Compressors.ModularCompressors</a>. The controller block consists of simple PID controllers for each compressor and no further control strategy is implemented yet. However, these PID controller are only initialised a nd activated if no external controller is provided (i.g. if <code>useExt = false</code>).
within AixLib.Controls.HeatPump.ModularHeatPumps; model ModularCompressorController "Model of an internal controller for modular compressors" extends BaseClasses.PartialModularController( dataBus(final nCom=nCom)); // Definition of dummy signals for controllers' rest inputs // Modelica.Blocks.Sources.BooleanConstant trigger[nCom](each k=false) "Boolean block to provide dummy signal to controllers' trigger signals" Modelica.Blocks.Sources.Constant triggerVal[nCom](each k=0) "Real block to provide dummy signal to controllers' rest signals" equation // Connect internal controller with inputs and outputs // connect(intCon.u_m, dataBus.comBus.meaConVarCom); connect(intCon.u_s, dataBus.comBus.intSetPoiCom); connect(intCon.y, manVarThr); if useExt then connect(manVarThr, dataBus.comBus.extManVarCom); end if; manVar = manVarThr; /*The output block 'manVarThr' is mandantory since the internal controller is conditional. Therefore, the connection 'connect(internalController.y, manVarThr)' is required to prevent errors that would occur otherwise if the internal controller is removed conditionally. */ // Connect dummy signals to controllers' rest inputs // connect(trigger.y, intCon.trigger) connect(triggerVal.y, intCon.y_reset_in) // Connect output signals // connect(useExtBlo, dataBus.comBus.extConCom) connect(curManVar, dataBus.comBus.curManVarVal) end ModularCompressorController;
Model of an internal controller for modular expansion valves. This a controller block used for modular expansion valve models as presented in <a href= \"modelica://AixLib.Fluid.Actuators.Valves.ExpansionValves.ModularExpansionValves\"> AixLib.Fluid.Actuators.Valves.ExpansionValves.ModularExpansionValves</a>. The controller block consists of simple PID controllers for each expansion valve and no further control strategy is implemented. However, these PID controller are only initialised and activated if no external controller is provided (i.g. if <code>useExt = false</code>).
within AixLib.Controls.HeatPump.ModularHeatPumps; model ModularExpansionValveController "Model of an internal controller for modular expansion valves" extends BaseClasses.PartialModularController( dataBus(final nVal=nCom)); // Definition of dummy signals for controllers' rest inputs // Modelica.Blocks.Sources.BooleanConstant tri[nCom](each k=false) "Boolean block to provide dummy signal to controllers' trigger signals" Modelica.Blocks.Sources.Constant triVal[nCom](each k=0) "Real block to provide dummy signal to controllers' rest signals" equation // Connect internal controller with inputs and outputs // connect(intCon.u_m, dataBus.expValBus.meaConVarVal); connect(intCon.u_s, dataBus.expValBus.intSetPoiVal); connect(intCon.y, manVarThr); if useExt then connect(manVar, dataBus.expValBus.extManVarVal); end if; manVar = manVarThr; /*The output block 'manVarThr' is mandantory since the internal controller is conditional. Therefore, the connection 'connect(internalController.y, manVarThr)' is required to prevent errors that would occur otherwise if the internal controller is removed conditionally. */ // Connect dummy signals to controllers' rest inputs // connect(tri.y, intCon.trigger) connect(triVal.y, intCon.y_reset_in) // Connect parameters describing if internal or external signal is used // connect(useExtBlo, dataBus.expValBus.extConVal) // Connect output signals // connect(curManVar, dataBus.expValBus.curManVarVal) end ModularExpansionValveController;
Package that contains controllers used for modular heat pumps
within AixLib.Controls.HeatPump; package ModularHeatPumps "Package that contains controllers used for modular heat pumps" extends Modelica.Icons.VariantsPackage; end ModularHeatPumps;
Package that contains base models used for controllers of modular heat pumps
within AixLib.Controls.HeatPump.ModularHeatPumps; package BaseClasses "Package that contains base models used for controllers of modular heat pumps" extends Modelica.Icons.BasesPackage; end BaseClasses;
Base model used for all modular controllers. This is a base model used by all modular controller models. It defines basic inputs, outputs, parameters and sub-models. The main inputs and outputs are the modular heat pump control bus <a href= \"modelica://AixLib.Controls.Interfaces.ModularHeatPumpControlBus\">AixLib.Controls.Interfaces.ModularHeatPumpControlBus</a>, the manipulated signals passed to the controlled components and the current manipulated signals. The main sub-model is a PID controller presented in <a href= \"modelica://AixLib.Controls.Continuous.LimPID\">AixLib.Controls.Continuous.LimPID</a> that is initialised if no external controller is used. Furthermore, all parameters with respect to the PID controller are propagated because the modular controller shall be used in an architectural modeling approach.
within AixLib.Controls.HeatPump.ModularHeatPumps.BaseClasses; partial model PartialModularController "Base model used for all modular controllers" // Definition of parameters describing modular approach // parameter Integer nCom = 1 "Number of components" parameter Boolean useExt = true "= true, if external signal is used instead of internal controllers" // Definition of parameters describing the controller // parameter Modelica.Blocks.Types.SimpleController controllerType[nCom]= fill(Modelica.Blocks.Types.SimpleController.PID,nCom) "Type of controller" parameter Boolean reverseAction[nCom] = fill(false,nCom) "= true, if medium flow rate is throttled through cooling coil controller" parameter AixLib.Types.Reset reset[nCom]= fill(AixLib.Types.Reset.Disabled,nCom) "Type of controller output reset" parameter Real k[nCom] = fill(1,nCom) "Gain of controller" parameter Modelica.Units.SI.Time Ti[nCom]=fill(0.5, nCom) "Time constant of integrator block" parameter Real Ni[nCom] = fill(0.9,nCom) "Ni*Ti is time constant of anti-windup compensation" parameter Modelica.Units.SI.Time Td[nCom]=fill(0.1, nCom) "Time constant of derivative block" parameter Real Nd[nCom] = fill(10,nCom) "The higher Nd, the more ideal the derivative block" parameter Real wp[nCom] = fill(1,nCom) "Set-point weight for Proportional block (0..1)" parameter Real wd[nCom] = fill(0,nCom) "Set-point weight for Derivative block (0..1)" parameter Real yMax[nCom] = fill(1,nCom) "Upper limit of output" parameter Real yMin[nCom] = fill(0,nCom) "Lower limit of output" parameter Modelica.Blocks.Types.Init initType[nCom]=fill(Modelica.Blocks.Types.Init.InitialState, nCom) "Init: (1: no init, 2: steady state, 3: initial state, 4: initial output)" parameter Real xi_start[nCom] = fill(0,nCom) "Initial or guess value value for integrator output (= integrator state)" parameter Real xd_start[nCom] = fill(0,nCom) "Initial or guess value for state of derivative block" parameter Real y_start[nCom] = fill(0,nCom) "Initial value of output" // Definition of models // Continuous.LimPID intCon[nCom]( final controllerType=controllerType, final k=k, final Ti=Ti, final Ni=Ni, final Td=Td, final Nd=Nd, final wp=wp, final wd=wd, final yMax=yMax, final yMin=yMin, final initType=initType, final xi_start=xi_start, final xd_start=xd_start, final y_start=y_start, final reverseActing=reverseAction, final reset=reset) if not useExt "Internal controller if internal controller is required" // Definition of connectors and inputs and outputs // Modelica.Blocks.Interfaces.BooleanOutput useExtBlo "Boolean block used to set data bus' useExt-signal" Modelica.Blocks.Interfaces.RealOutput manVarThr[nCom] "Input connector to pass controller's manipualted signals through if activated" Modelica.Blocks.Interfaces.RealInput curManVar[nCom] "Array of signals with current manipulated variables of controlled components" Modelica.Blocks.Interfaces.RealOutput manVar[nCom] "Array of manipulated variables for controlled components" Interfaces.ModularHeatPumpControlBus dataBus "Data bus with control signals" end PartialModularController;
This package contains a library for agent-based control of HVAC systems
within AixLib.Controls; package HVACAgentBasedControl "This package contains a library for agent-based control of HVAC systems" extends Modelica.Icons.VariantsPackage; end HVACAgentBasedControl;
Boolean variable to describe whether all proposals have been collected.
within AixLib.Controls.HVACAgentBasedControl.Agents; model Broker extends BaseClasses.PartialAgent; Boolean proposalsComplete(start=false) "Boolean variable to describe whether all proposals have been collected"; Boolean requestComplete(start= false) "Boolean variable to describe whether all requests are served by the current constellation"; Boolean rejectsComplete( start=false); Real[:,7] heatSupplierTable(start=startTable); parameter Real[:,7] startTable = [30001,0,0,0,0,0,0; 30002,0,0,0,0,0,0] "Initialization table for the negotiation process. Fill first column with ProducerAgents"; Integer proposalCounter(start=1) "Integer variable to describe proposalCounter"; Integer counterReject(start=1) "Integer variable to describe counterReject"; Real lowestPrice(start=0) "Real variable to define lowestPrice"; Integer counter(start=1) "Integer variable to describe counter"; Boolean requestsExceedSupply(start=false) "Boolean variable to describe whteher requests exceed supply"; // Tables and variables note the requests by the consumers Real requestTable[10,1](start=[0;0;0;0;0;0;0;0;0;0]) "Real variable to define requestTable"; Real requestAddresses[10,1](start=[0;0;0;0;0;0;0;0;0;0]) "Real variable to define requestAddresses"; Real heatingRequestSum(start=0) "Real variable to define the sum of heating requests"; Integer requestCounter(start=1) "Real variable to define requestCounter"; // Variables for average price (for storage) Real totalPrice "Real variable to define totalPrice"; Real totalHeat "Real variable to define totalHeat"; Real averagePrice "Real variable to define averagePrice"; // Variables for finding the lowest price combination Real heatingCalculationSum(start=0) "Real variable to define the sum of heatingCalculation"; Integer cheapest(start=1) "Integer variable to define the cheapest offer"; Real heatingPriceSum "Real variable to define the sum of heatingPrice"; Real totalaveragePrice "Real variable to define totalaveragePrice"; Real restHeat "Real variable to define restHeat"; Boolean calculationDone( start=false) "Boolean variable to annonce calculationDone"; // Variable for composing information Integer informationCounter(start=1) "Integer variable to define informationCounter"; Boolean informationDone(start=false) "Boolean variable to announce informationDone"; // Variables for requests from producers Boolean finalRequestDone(start=false) "Boolean variable to announce finalRequestDone"; // This section contains the blocks for the state-machine logic of the agent public Modelica.StateGraph.InitialStep waiting(nIn=7, nOut=1) Modelica.StateGraph.TransitionWithSignal newMessage Modelica.StateGraph.Step message(nOut=2, nIn=1) Modelica.Blocks.Math.IntegerChange integerChange Modelica.Blocks.Sources.BooleanExpression booleanExpression(y=noEvent( getperformative.y[1] == 19)) Modelica.StateGraph.TransitionWithSignal transitionWithSignal Modelica.StateGraph.Step requests(nIn=2, nOut=1) Modelica.StateGraph.Transition waitforRequests(enableTimer=true, waitTime=10) Modelica.StateGraph.TransitionWithSignal newRequests Modelica.StateGraph.Step callForProposal(nIn=2, nOut=1) Modelica.StateGraph.TransitionWithSignal newProposal(waitTime=0.1, enableTimer=false) Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y=noEvent(( getperformative.y[1] == 13) or (getperformative.y[1] == 17))) Modelica.StateGraph.Step collectProposal(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal allProposalsCollected(enableTimer=true, waitTime= 0.1) Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y=noEvent( proposalsComplete)) Modelica.StateGraph.Step sendOutRequest(nOut=1, nIn=3) Modelica.StateGraph.TransitionWithSignal notFinished(enableTimer=true, waitTime= 0.1) Modelica.Blocks.Logical.Not not2 Modelica.StateGraph.StepWithSignal sendCall(nOut=2, nIn=1) Modelica.StateGraph.Transition transition(enableTimer=true, waitTime=0.1) Modelica.StateGraph.StepWithSignal sendRequest( nOut=2, nIn=1) Modelica.StateGraph.Transition transition1(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Step check(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal correctPerformative(waitTime=0.5, enableTimer=false) Modelica.StateGraph.Step check1( nOut=1, nIn=1) Modelica.StateGraph.TransitionWithSignal correctPerformative1( waitTime=0.5, enableTimer=false) Modelica.StateGraph.Transition requestNoted(enableTimer=true, waitTime=1) Modelica.StateGraph.StepWithSignal sendConfirmation(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal actionConfirmed(waitTime=0.5, enableTimer=false) Modelica.Blocks.Sources.BooleanExpression booleanExpression5(y=noEvent(( getperformative.y[1] == 5) and (getsender.y[1] == receiver.u[1]))) Modelica.StateGraph.TransitionWithSignal transitionWithSignal3( enableTimer= true, waitTime=0.5) Modelica.StateGraph.Step composeNotUnderstood(nIn=1, nOut=1) Modelica.StateGraph.Transition transition2(enableTimer=true, waitTime=1) Modelica.StateGraph.StepWithSignal sendNotUnderstood(nOut=1, nIn=1) Modelica.StateGraph.Transition transition4(enableTimer=true, waitTime=1) Modelica.Blocks.Sources.BooleanExpression booleanExpression6(y=not ( getperformative.y[1] == 19)) // The algorithm section contains the logic of the broker, describing the // actions taken during each active state of the agent Modelica.StateGraph.Step composeInformation(nOut=1, nIn=2) Modelica.StateGraph.TransitionWithSignal newConfirm(waitTime=0.1, enableTimer= false) Modelica.StateGraph.Step check2(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal correctPerformative2( waitTime=0.5, enableTimer=false) Modelica.StateGraph.Step collectConfirm(nOut=3, nIn=1) Modelica.StateGraph.Step computePrice(nOut=1, nIn=1) Modelica.StateGraph.TransitionWithSignal transition5( enableTimer=true, waitTime=0.5) Modelica.StateGraph.Transition transition6( enableTimer=true, waitTime=0.1) Modelica.StateGraph.StepWithSignal sendInformation(nIn=1, nOut=1) Modelica.StateGraph.TransitionWithSignal confirmComplete(waitTime=0.5, enableTimer=false) Modelica.StateGraph.Step computeFinalConstellation(nOut=1, nIn=1) Modelica.StateGraph.Transition transition7( enableTimer=true, waitTime=0.1) Modelica.StateGraph.Step checkRequestComplete(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal requestsComplete(waitTime=0.5, enableTimer=false) Modelica.StateGraph.TransitionWithSignal requestsNotComplete(waitTime=0.5, enableTimer=false) Modelica.StateGraph.TransitionWithSignal confirmNotComplete(waitTime=0.5, enableTimer=false) Modelica.Blocks.Logical.Or or1 Modelica.Blocks.Logical.Or or2 Modelica.Blocks.Logical.Or or3 Modelica.Blocks.Logical.Or or4 Modelica.Blocks.Sources.BooleanExpression booleanExpression3(y=noEvent(( getperformative.y[1] == 5 or getperformative.y[1] == 3) and ( getsender.y[1] == receiver.u[1]))) Modelica.Blocks.Sources.BooleanExpression booleanExpression4(y=noEvent( informationDone and (abs(heatingRequestSum) >= 1))) Modelica.Blocks.Sources.BooleanExpression booleanExpression7(y=noEvent(not ( informationDone))) Modelica.Blocks.Sources.BooleanExpression booleanExpression8(y=noEvent( finalRequestDone)) Modelica.Blocks.Sources.BooleanExpression booleanExpression9(y=noEvent(not ( finalRequestDone))) Modelica.StateGraph.Transition abort(enableTimer=true, waitTime=10) Modelica.Blocks.Sources.BooleanExpression booleanExpression11(y=noEvent( calculationDone)) Modelica.StateGraph.Step prepareTableforRejections(nOut=1, nIn=1) Modelica.StateGraph.Transition transition3( enableTimer=true, waitTime=0.1) Modelica.StateGraph.Transition reset(enableTimer=true, waitTime=60) Modelica.StateGraph.Transition reset1(enableTimer=true, waitTime=60) Modelica.StateGraph.Transition reset2(enableTimer=true, waitTime=60) Modelica.StateGraph.Transition reset3(enableTimer=true, waitTime=60) Modelica.StateGraph.Step checkAvailability(nIn=1, nOut=2) Modelica.StateGraph.TransitionWithSignal enoughSupply(enableTimer=true, waitTime= 0.1) Modelica.Blocks.Sources.BooleanExpression booleanExpression10(y=noEvent(not ( requestsExceedSupply))) Modelica.StateGraph.Step limitedSupplyAbort( nIn=1, nOut=1) Modelica.StateGraph.TransitionWithSignal enoughSupply1(enableTimer=true, waitTime=1) Modelica.Blocks.Sources.BooleanExpression booleanExpression12(y=noEvent( requestsExceedSupply)) Modelica.StateGraph.Transition reset4(enableTimer=true, waitTime=1) algorithm when noEvent(waiting.active) then counter :=1; counterReject := 1; lowestPrice :=0; heatSupplierTable := startTable; proposalCounter := 1; finalRequestDone :=false; informationCounter :=1; informationDone :=false; heatingCalculationSum :=0; cheapest :=1; heatingPriceSum :=0; totalaveragePrice :=0; restHeat := 0; requestTable :=[0;0;0;0;0;0;0;0;0;0]; requestAddresses := [0;0;0;0;0;0;0;0;0;0]; heatingRequestSum := 0; requestCounter :=1; proposalsComplete := false; requestComplete := false; heatingRequestSum :=0; rejectsComplete := false; content.u[1] := 0; content.u[2] := 0; calculationDone := false; requestsExceedSupply := false; end when; // Collecting requests to bundle goals when noEvent(requests.active) then // Collect the requests heatingRequestSum := heatingRequestSum + get_content.y[1]; requestTable[requestCounter,1] := get_content.y[1]; requestAddresses[requestCounter,1] := getsender.y[1]; // Create the confirmation for the consumer agent performative.u[1] := 5; //"confirm" ontology.u[1] :=1; sender.u[1] := name; receiver.u[1] := getsender.y[1]; reply_to.u[1] := name; content.u[1] := get_content.y[1]; uDPSend_adapted.receiver := getsender.y[1]; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("Broker "+ String(name)+ " collected the request of " + String(requestTable[requestCounter,1]) + " W of heat from Consumer " + String(requestAddresses[requestCounter,1])+"."); requestCounter := requestCounter +1; end when; // Broker calls all heatSuppliers in the list for a proposal for the requested heat when noEvent(callForProposal.active) then performative.u[1]:= 4; sender.u[1]:=name; receiver.u[1]:= integer(heatSupplierTable[proposalCounter,1]); reply_to.u[1] := name; content.u[1] := heatingRequestSum; ontology.u[1] := 1; uDPSend_adapted.receiver := heatSupplierTable[proposalCounter,1]; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("Broker "+ String(name)+ " calls for proposal of " + String(heatingRequestSum) + " W of heat from Producer " + String(receiver.u[1])+"."); end when; // Receiving the proposals and add the information that proposal was received // price for the proposal and maximum capacity when noEvent(collectProposal.active) then if noEvent(getperformative.y[1] == 13) then heatSupplierTable[proposalCounter,3] := get_content.y[1]; heatSupplierTable[proposalCounter,4] := get_content.y[2]; heatSupplierTable[proposalCounter,5] := if heatingRequestSum >=0 then (get_content.y[1]/max(0.0001,get_content.y[2])) else -(get_content.y[1]/min(0.0001,get_content.y[2])); heatSupplierTable[proposalCounter,7] := heatSupplierTable[proposalCounter,5]; /*if getsender.y[1] == 30001 then heatSupplierTable[proposalCounter,3] := averagePrice; heatSupplierTable[proposalCounter,7] := averagePrice; end if;*/ Modelica.Utilities.Streams.print("Broker "+ String(name)+ " collects proposal of " + String(get_content.y[2]) + " W of heat for the price of " + String(heatSupplierTable[proposalCounter,3]) + " from Producer " + String(receiver.u[1])+"."); else heatSupplierTable[proposalCounter,3] := 999999999; heatSupplierTable[proposalCounter,4] := 0.0001; heatSupplierTable[proposalCounter,5] := 999999999; heatSupplierTable[proposalCounter,7] := 999999999; heatSupplierTable[proposalCounter,2] := 3; Modelica.Utilities.Streams.print("Broker "+ String(name)+ " collects refusal from from Producer " + String(receiver.u[1])+"."); end if; if noEvent(proposalCounter== size(heatSupplierTable,1)) then proposalsComplete := true; //if all proposals are there go to next block end if; proposalCounter := proposalCounter +1; end when; // Check whether the possible supply exceeds the demand when noEvent(checkAvailability.active) then if abs(sum(heatSupplierTable[:,4])) < (abs(heatingRequestSum)-1) then Modelica.Utilities.Streams.print("Broker received less proposals than necessary to fulfill demand. Ordering all available capacity."); heatingRequestSum := sum(heatSupplierTable[:,4]); end if; if abs(sum(heatSupplierTable[:,4])) < 10 then requestsExceedSupply := true; end if; end when; // Abort procedure if demand exceeds supply when noEvent(limitedSupplyAbort.active) then Modelica.Utilities.Streams.print("Broker received no proposal. Abort process."); end when; // Block to compute the price when noEvent(computePrice.active) then restHeat := heatingRequestSum; while (abs(heatingCalculationSum)<abs(heatingRequestSum)) loop lowestPrice := min(heatSupplierTable[:,7]); for i in 1:size(heatSupplierTable,1) loop if noEvent(Modelica.Math.isEqual(heatSupplierTable[i,7],lowestPrice)) then cheapest := i; break; end if; end for; heatSupplierTable[cheapest,6] := if (heatingRequestSum > 0) then min(restHeat,heatSupplierTable[cheapest,4]) else max(restHeat,heatSupplierTable[cheapest,4]); heatSupplierTable[cheapest,2] := 1; heatingCalculationSum := heatingCalculationSum + heatSupplierTable[cheapest,6]; heatingPriceSum := heatingPriceSum + heatSupplierTable[cheapest,6]*heatSupplierTable[cheapest,5]; heatSupplierTable[cheapest,7] := 9999999999.0; restHeat := heatingRequestSum - heatingCalculationSum; end while; totalaveragePrice := heatingPriceSum/heatingCalculationSum; Modelica.Utilities.Streams.print("Broker "+ String(name)+ " calculates an average price of " + String(totalaveragePrice) + " per W of heat."); heatingRequestSum :=0; heatingCalculationSum := 0; calculationDone := true; end when; // Composeinformation for consumer agents in order to get a confirmation afterwards when noEvent(composeInformation.active) then performative.u[1]:=8; sender.u[1]:=name; receiver.u[1]:= integer(requestAddresses[informationCounter,1]); reply_to.u[1] := name; content.u[1] := totalaveragePrice*requestTable[informationCounter,1]; content.u[2] := requestTable[informationCounter,1]; ontology.u[1] := 1; uDPSend_adapted.receiver := requestAddresses[informationCounter,1]; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("Broker "+ String(name)+ " asks for a confirmation of " + String(content.u[2]) + " W of heat for the total price of " + String(content.u[1]) + " from Consumer " + String(receiver.u[1])+"."); end when; // Collect confirms of the consumers and catch the final amount of heat requested when noEvent(collectConfirm.active) then if noEvent(getperformative.y[1] == 5) then heatingRequestSum := heatingRequestSum + get_content.y[2]; end if; informationCounter := informationCounter +1; if noEvent(requestAddresses[informationCounter,1]<1) then informationDone := true; if (abs(heatingRequestSum) >= 1) then Modelica.Utilities.Streams.print(String(heatingRequestSum)+ " W of heat were confirmed by consumers at broker " + String(name) +". Go on to final requests to producers."); else Modelica.Utilities.Streams.print("There was no request confirmed by consumers at broker " + String(name) +". It sends rejections to the producers."); end if; end if; end when; when noEvent(prepareTableforRejections.active) then for i in 1:size(heatSupplierTable,1) loop heatSupplierTable[i,3] := 0; heatSupplierTable[i,2] := 0; end for; end when; when noEvent(computeFinalConstellation.active) then if abs(sum(heatSupplierTable[:,4])) < (abs(heatingRequestSum)-1) then Modelica.Utilities.Streams.print("Broker received less proposals than necessary to fulfill demand. Ordering all available capacity."); heatingRequestSum := sum(heatSupplierTable[:,4]); end if; restHeat := heatingRequestSum; // Writing the right price back from column 5 to column 7 and resetting the requested capacity for i in 1:size(heatSupplierTable,1) loop heatSupplierTable[i,7] := heatSupplierTable[i,5]; heatSupplierTable[i,6] := 0; end for; // As long as the total request is not served, the next cheapest supplier is looked for while (abs(heatingCalculationSum)<abs(heatingRequestSum)) loop lowestPrice := min(heatSupplierTable[:,7]); // Looking for the index of the cheapest supplier for i in 1:size(heatSupplierTable,1) loop if noEvent(Modelica.Math.isEqual(heatSupplierTable[i,7],lowestPrice)) then cheapest := i; break; end if; end for; heatSupplierTable[cheapest,6] := if (heatingRequestSum > 0) then min(restHeat,heatSupplierTable[cheapest,4]) else max(restHeat,heatSupplierTable[cheapest,4]); //setting the requested capacity (minimum of the maximum device capacity and the rest of heat that needs to be supplied) heatSupplierTable[cheapest,2] := 1; //setting approve for supplier heatingCalculationSum := heatingCalculationSum + heatSupplierTable[cheapest,6]; //saving the amount of heat that is approved already heatingPriceSum := heatingPriceSum + heatSupplierTable[cheapest,6]*heatSupplierTable[cheapest,5]; //saving the the total price of the heat so far heatSupplierTable[cheapest,7] := 9999999999.0; //setting the price high, so the next cheapest producer can be found in the next loop restHeat := heatingRequestSum - heatingCalculationSum; //calculating the amount of heat that still needs to be approved in the next loop end while; // Update the average energy price totalPrice := totalPrice + heatingPriceSum; totalHeat := totalHeat + heatingRequestSum; averagePrice := totalPrice/totalHeat; counter:=1; //reset counter for next block end when; // Block to send out accept proposal to all providing producers when noEvent(sendOutRequest.active) then sender.u[1]:=name; receiver.u[1]:= integer(heatSupplierTable[counter,1]); reply_to.u[1] := name; content.u[1] := heatSupplierTable[counter,6]; ontology.u[1] := 1; uDPSend_adapted.receiver := heatSupplierTable[counter,1]; messageID.u[1] := name*name + integer(time); if noEvent(heatSupplierTable[counter,2] > 0 and heatSupplierTable[counter,2] <3) then performative.u[1]:=1;//accept proposal Modelica.Utilities.Streams.print("Broker "+ String(name)+ " accepts the proposal of " + String(receiver.u[1]) + " and orders " + String(content.u[1]) + " W of heat."); else if noEvent(heatSupplierTable[counter,2] <3) then performative.u[1]:=18;//reject proposal Modelica.Utilities.Streams.print("Broker "+ String(name)+ " rejects the proposal of " + String(receiver.u[1])+ "."); else performative.u[1]:=18; Modelica.Utilities.Streams.print("Broker "+ String(name)+ " accepts refusal of " + String(receiver.u[1])+ "."); end if; end if; counter := counter+1; if noEvent(counter > size(heatSupplierTable,1)) then finalRequestDone := true; end if; end when; // Send out "not understood" message, if message has unknown performative when noEvent(composeNotUnderstood.active) then performative.u[1] := 11; //"not understood" content.u[1] := 0; content.u[2] := 0; sender.u[1] := name; receiver.u[1] := getsender.y[1]; uDPSend_adapted.receiver := getsender.y[1]; ontology.u[1] := getontology.y[1]; messageID.u[1] := name*name + integer(time); end when; equation connect(newMessage.inPort,waiting. outPort[1]) connect(newMessage.outPort,message. inPort[1]) connect(integerChange.y, newMessage.condition) connect(integerChange.u, getMessageID.y[1]) connect(booleanExpression.y, transitionWithSignal.condition) connect(transitionWithSignal.outPort,requests. inPort[1]) connect(callForProposal.inPort[1], waitforRequests.outPort) connect(notFinished.inPort, collectProposal.outPort[1]) connect(not2.y, notFinished.condition) connect(message.outPort[1], transitionWithSignal.inPort) connect(notFinished.outPort, callForProposal.inPort[2]) connect(allProposalsCollected.inPort, collectProposal.outPort[2]) connect(transition.inPort, callForProposal.outPort[1]) connect(transition.outPort, sendCall.inPort[1]) connect(sendCall.outPort[1], newProposal.inPort) connect(sendOutRequest.outPort[1], transition1.inPort) connect(check.inPort[1], newProposal.outPort) connect(booleanExpression1.y, correctPerformative.condition) connect(correctPerformative.outPort, collectProposal.inPort[1]) connect(correctPerformative.inPort, check.outPort[1]) connect(newRequests.condition, newMessage.condition) connect(correctPerformative1.outPort, requests.inPort[2]) connect(check1.outPort[1], correctPerformative1.inPort) connect(check1.inPort[1], newRequests.outPort) connect(correctPerformative1.condition, transitionWithSignal.condition) connect(requests.outPort[1], requestNoted.inPort) connect(sendConfirmation.inPort[1], requestNoted.outPort) connect(sendConfirmation.outPort[1], waitforRequests.inPort) connect(newRequests.inPort, sendConfirmation.outPort[2]) connect(newProposal.condition, newMessage.condition) connect(booleanExpression2.y, not2.u) connect(booleanExpression2.y, allProposalsCollected.condition) connect(actionConfirmed.inPort, sendRequest.outPort[1]) connect(booleanExpression5.y, actionConfirmed.condition) connect(transition1.outPort, sendRequest.inPort[1]) connect(booleanExpression6.y, transitionWithSignal3.condition) connect(transitionWithSignal3.inPort, message.outPort[2]) connect(transitionWithSignal3.outPort, composeNotUnderstood.inPort[1]) connect(composeNotUnderstood.outPort[1], transition2.inPort) connect(transition2.outPort, sendNotUnderstood.inPort[1]) connect(sendNotUnderstood.outPort[1], transition4.inPort) connect(transition4.outPort, waiting.inPort[2]) connect(computePrice.outPort[1], transition5.inPort) connect(transition5.outPort, composeInformation.inPort[1]) connect(composeInformation.outPort[1], transition6.inPort) connect(transition6.outPort, sendInformation.inPort[1]) connect(sendInformation.outPort[1], newConfirm.inPort) connect(newConfirm.outPort, check2.inPort[1]) connect(check2.outPort[1], correctPerformative2.inPort) connect(correctPerformative2.outPort, collectConfirm.inPort[1]) connect(collectConfirm.outPort[1], confirmComplete.inPort) connect(confirmComplete.outPort, computeFinalConstellation.inPort[1]) connect(computeFinalConstellation.outPort[1], transition7.inPort) connect(transition7.outPort, sendOutRequest.inPort[1]) connect(actionConfirmed.outPort, checkRequestComplete.inPort[1]) connect(checkRequestComplete.outPort[1], requestsComplete.inPort) connect(requestsNotComplete.outPort, sendOutRequest.inPort[2]) connect(requestsNotComplete.inPort, checkRequestComplete.outPort[2]) connect(confirmNotComplete.inPort, collectConfirm.outPort[2]) connect(confirmNotComplete.outPort, composeInformation.inPort[2]) connect(requestsComplete.outPort, waiting.inPort[1]) connect(or1.u2, sendCall.active) connect(sendConfirmation.active, or1.u1) connect(sendNotUnderstood.active, or2.u1) connect(sendRequest.active, or2.u2) connect(sendInformation.active, or3.u2) connect(or1.y, or3.u1) connect(or4.u1, or3.y) connect(or4.y, uDPSend_adapted.trigger) connect(or2.y, or4.u2) connect(newConfirm.condition, newMessage.condition) connect(booleanExpression3.y, correctPerformative2.condition) connect(booleanExpression4.y, confirmComplete.condition) connect(booleanExpression7.y, confirmNotComplete.condition) connect(booleanExpression8.y, requestsComplete.condition) connect(booleanExpression9.y, requestsNotComplete.condition) connect(abort.inPort, collectConfirm.outPort[3]) connect(booleanExpression11.y, transition5.condition) connect(prepareTableforRejections.inPort[1], abort.outPort) connect(prepareTableforRejections.outPort[1], transition3.inPort) connect(transition3.outPort, sendOutRequest.inPort[3]) connect(reset.outPort, waiting.inPort[3]) connect(reset.inPort, sendRequest.outPort[2]) connect(reset1.inPort, check2.outPort[2]) connect(sendCall.outPort[2], reset2.inPort) connect(check.outPort[2], reset3.inPort) connect(reset1.outPort, waiting.inPort[4]) connect(reset2.outPort, waiting.inPort[5]) connect(reset3.outPort, waiting.inPort[6]) connect(checkAvailability.inPort[1], allProposalsCollected.outPort) connect(enoughSupply.inPort, checkAvailability.outPort[1]) connect(enoughSupply.outPort, computePrice.inPort[1]) connect(enoughSupply.condition, booleanExpression10.y) connect(enoughSupply1.outPort, limitedSupplyAbort.inPort[1]) connect(enoughSupply1.condition, booleanExpression12.y) connect(checkAvailability.outPort[2], enoughSupply1.inPort) connect(reset4.inPort, limitedSupplyAbort.outPort[1]) connect(reset4.outPort, waiting.inPort[7]) end Broker;
Maximum capacity for heat/cold generation (heat positive, cold negative).
within AixLib.Controls.HVACAgentBasedControl.Agents; model ColdProducerAgent extends BaseClasses.PartialAgent; parameter Real maxCapacity = 0 "Maximum capacity for heat/cold generation (heat positive, cold negative)"; parameter Real minCapacity = -10000 "Minimum capacity for heat/cold generation (heat positive, cold negative)"; Real minCapacityInternal "Real variable to define minCapacityInternal"; Real costCurrent(start=40) "Real variable to define costCurrent"; Real costNew(start=0) "Real variable to define costNew"; Real setCapacity(start=2000) "Real variable to define setCapacity"; Real costDifference(start=0) "Real variable to define costDifference"; Real totalRequest(start=0) "Real variable to define totalRequest"; Real currentCapacityDiscrete(start=2000) "Real variable to define currentCapacityDiscrete"; parameter Boolean maxCapacityExternal=false "Use external input for minimal capacity"; // CostFunction related components // This section contains the blocks for the state-machine logic of the agent Modelica.StateGraph.InitialStep waiting( nOut=2, nIn=4) Modelica.StateGraph.TransitionWithSignal newMessage Modelica.StateGraph.Step message(nOut=2, nIn=1) Modelica.StateGraph.Step adjustHeat(nIn=1, nOut=1) Modelica.StateGraph.Transition transition2( enableTimer=true, waitTime=2) Modelica.StateGraph.Step computeProposal(nIn=1, nOut=1) Modelica.Blocks.Sources.BooleanExpression booleanExpression(y=noEvent( getperformative.y[1] == 4)) Modelica.StateGraph.TransitionWithSignal transitionWithSignal( waitTime=0.5, enableTimer=false) Modelica.StateGraph.TransitionWithSignal transitionWithSignal1( waitTime=0.5, enableTimer=false) Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y=noEvent( getperformative.y[1] == 1)) Modelica.StateGraph.Transition transition1( waitTime=0.1, enableTimer=true) Modelica.StateGraph.StepWithSignal sendProposal(nOut=3, nIn=1) Modelica.Blocks.Math.IntegerChange integerChange Modelica.StateGraph.TransitionWithSignal transitionWithSignal2( waitTime=0.5, enableTimer=false) Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y=noEvent( getperformative.y[1] == 18)) Modelica.StateGraph.TransitionWithSignal transitionWithSignal3( enableTimer= true, waitTime=0.5) Modelica.Blocks.Sources.BooleanExpression booleanExpression3(y=noEvent( getperformative.y[1] == 4)) Modelica.Blocks.Logical.Not not1 Modelica.StateGraph.Step composeNotUnderstood(nIn=1, nOut=1) Modelica.StateGraph.Transition transition3(enableTimer=true, waitTime=1) Modelica.StateGraph.StepWithSignal sendNotUnderstood(nOut=1, nIn=1) Modelica.StateGraph.Transition transition4(enableTimer=true, waitTime=1) Modelica.Blocks.Logical.Or or1 Modelica.Blocks.Interfaces.RealInput currentCapacity "Input for current capacity of device" Modelica.Blocks.Interfaces.RealOutput setCapacityOut "Output for set capacity of device" Modelica.StateGraph.StepWithSignal sendConfirmation(nOut=1, nIn=2) Modelica.StateGraph.Transition transition5( waitTime=0.1, enableTimer=true) Modelica.Blocks.Logical.Or or2 protected Modelica.Blocks.Interfaces.BooleanInput send public Modelica.StateGraph.Step confirm(nIn=1, nOut=1) Modelica.StateGraph.Transition transition6( enableTimer=true, waitTime=2) Modelica.Blocks.Interfaces.RealOutput calcCapacity "Output to connect with cost function" Modelica.Blocks.Interfaces.RealInput calcCost "Input to connect with cost function" Modelica.StateGraph.TransitionWithSignal Off(enableTimer=true, waitTime=0) Modelica.StateGraph.Step shutDown( nOut=1, nIn=1) Modelica.StateGraph.Transition transition7( waitTime=0.1, enableTimer=true) Modelica.Blocks.Logical.Not not2 Modelica.Blocks.Interfaces.BooleanInput OnOff_external "External on/off switch" Modelica.Blocks.Sources.BooleanExpression booleanExpression4(y=noEvent(abs( setCapacity) > 30)) Modelica.Blocks.Logical.And and1 Modelica.StateGraph.Transition reset(enableTimer=true, waitTime=60) protected Modelica.Blocks.Interfaces.BooleanOutput calc_active "Indicator that cost calculation in cost function is active" public Modelica.Blocks.Discrete.ZeroOrderHold zeroOrderHold(samplePeriod=3600) Modelica.Blocks.Interfaces.RealInput minCapacityInput if maxCapacityExternal "Input for external minimum capacity" equation if maxCapacityExternal then //connect(maxCapacity,maxCapacityInternal); minCapacityInternal = zeroOrderHold.y; else minCapacityInternal = minCapacity; end if; connect(newMessage.inPort, waiting.outPort[1]) connect(newMessage.outPort, message.inPort[1]) connect(adjustHeat.outPort[1], transition2.inPort) connect(send, uDPSend_adapted.trigger) connect(booleanExpression.y, transitionWithSignal.condition) connect(computeProposal.inPort[1], transitionWithSignal.outPort) connect(booleanExpression1.y, transitionWithSignal1.condition) connect(adjustHeat.inPort[1], transitionWithSignal1.outPort) connect(transition1.inPort, computeProposal.outPort[1]) connect(sendProposal.inPort[1], transition1.outPort) connect(getMessageID.y[1], integerChange.u) connect(integerChange.y, newMessage.condition) connect(sendProposal.outPort[1], transitionWithSignal1.inPort) connect(transitionWithSignal2.condition, booleanExpression2.y) connect(transitionWithSignal2.inPort, sendProposal.outPort[2]) connect(message.outPort[1], transitionWithSignal.inPort) connect(booleanExpression3.y, not1.u) connect(transitionWithSignal3.condition, not1.y) connect(transitionWithSignal3.inPort, message.outPort[2]) connect(composeNotUnderstood.inPort[1], transitionWithSignal3.outPort) connect(composeNotUnderstood.outPort[1], transition3.inPort) connect(transition3.outPort, sendNotUnderstood.inPort[1]) connect(transition4.inPort, sendNotUnderstood.outPort[1]) // The algorithm section contains the logic of the broker, describing the // actions taken during each active state of the agent algorithm when noEvent(waiting.active) then currentCapacityDiscrete := currentCapacity; calcCapacity := setCapacity; costCurrent := calcCost; end when; // ExternalshutDown when noEvent(shutDown.active) then setCapacity :=0; setCapacityOut := setCapacity; end when; // Compute costs for the requested amount of heat when noEvent(computeProposal.active) then if get_content.y[1] >0 then if noEvent(((setCapacity+get_content.y[1]) >= maxCapacity)) then if noEvent(setCapacity > (maxCapacity-1)) then content.u[1] := 0; content.u[2] := 0; performative.u[1] := 17; Modelica.Utilities.Streams.print("ColdProducerAgent "+ String(name)+ " refuses proposal due to maximum capacity."); else totalRequest := maxCapacity; calcCapacity := totalRequest; calc_active := true; costNew := calcCost; content.u[2] := maxCapacity - setCapacity; performative.u[1] := 13; //propose costDifference := costNew - costCurrent; content.u[1] := costDifference; Modelica.Utilities.Streams.print("ColdProducerAgent "+ String(name)+ " proposes adjustment of " + String(content.u[2]) + " W " + "for a price of "+String(content.u[1])+"."); end if; else totalRequest := setCapacity+get_content.y[1]; calcCapacity := totalRequest; calc_active := true; costNew := calcCost; content.u[2] := get_content.y[1]; performative.u[1] := 13; //propose costDifference := costNew - costCurrent; content.u[1] := costDifference; Modelica.Utilities.Streams.print("ColdProducerAgent "+ String(name)+ " proposes adjustment of " + String(content.u[2]) + " W " + "for a price of "+String(content.u[1])+"."); end if; else if noEvent(((setCapacity+get_content.y[1]) <= minCapacityInternal)) then if noEvent(setCapacity < minCapacityInternal+10) then totalRequest := 0; calcCapacity := 0; calc_active := true; costNew := calcCost; content.u[2] := 0; performative.u[1] := 17; //refuse content.u[1] := 0; Modelica.Utilities.Streams.print("ColdProducerAgent "+ String(name)+ " refuses proposal due to minimum capacity."); else totalRequest := 0; calcCapacity := totalRequest; calc_active := true; costNew := calcCost; content.u[2] := minCapacityInternal - setCapacity; performative.u[1] := 13; //propose costDifference := costNew - costCurrent; content.u[1] := costDifference; Modelica.Utilities.Streams.print("ColdProducerAgent "+ String(name)+ " proposes adjustment of " + String(content.u[2]) + " W " + "for a price of "+String(content.u[1])+"."); end if; else totalRequest := setCapacity+get_content.y[1]; calcCapacity := totalRequest; calc_active := true; costNew := calcCost; content.u[2] := get_content.y[1]; performative.u[1] := 13; //propose costDifference := costNew - costCurrent; content.u[1] := costDifference; Modelica.Utilities.Streams.print("ColdProducerAgent "+ String(name)+ " proposes adjustment of " + String(content.u[2]) + " W " + "for a price of "+String(content.u[1])+"."); end if; end if; uDPSend_adapted.receiver := getsender.y[1]; receiver.u[1] := getsender.y[1]; ontology.u[1] := 1; reply_to.u[1] := name; sender.u[1] :=name; messageID.u[1] := name*name + integer(time); calc_active := false; end when; // Adjust heat according to the confirmation by the broker, send confirmation when noEvent(adjustHeat.active) then setCapacity := setCapacity + get_content.y[1]; setCapacityOut :=setCapacity; content.u[1] := 0; content.u[2] := 0; performative.u[1] := 5; //"confirm" uDPSend_adapted.receiver := getsender.y[1]; receiver.u[1] := getsender.y[1]; ontology.u[1] := 1; reply_to.u[1] := name; sender.u[1] :=name; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("ColdProducerAgent "+ String(name)+ " confirms the adjustment of " + String(get_content.y[1]) + " W of heat. The setpoint is now " + String(setCapacity) +"W."); end when; // Confirm the receiving of the reject when noEvent(confirm.active) then uDPSend_adapted.receiver := getsender.y[1]; receiver.u[1] := getsender.y[1]; performative.u[1] := 5; sender.u[1] :=name; content.u[1] := 0; content.u[2] := 0; end when; // Send out "not understood" message, if message has unknown performative when noEvent(composeNotUnderstood.active) then performative.u[1] := 11; //"not understood" content.u[1] := 0; content.u[2] := 0; messageID.u[1] := name*name + integer(time); end when; equation connect(transition2.outPort, sendConfirmation.inPort[1]) connect(sendConfirmation.outPort[1], transition5.inPort) connect(transition5.outPort, waiting.inPort[2]) connect(send, or2.y) connect(or2.u2, or1.y) connect(sendNotUnderstood.active, or2.u1) connect(sendConfirmation.active, or1.u1) connect(sendProposal.active, or1.u2) connect(confirm.inPort[1], transitionWithSignal2.outPort) connect(transition6.inPort, confirm.outPort[1]) connect(transition6.outPort, sendConfirmation.inPort[2]) connect(transition4.outPort, waiting.inPort[1]) connect(not2.u, OnOff_external) connect(Off.inPort, waiting.outPort[2]) connect(Off.outPort, shutDown.inPort[1]) connect(shutDown.outPort[1], transition7.inPort) connect(transition7.outPort, waiting.inPort[3]) connect(not2.y, and1.u1) connect(and1.y, Off.condition) connect(booleanExpression4.y, and1.u2) connect(reset.inPort, sendProposal.outPort[3]) connect(reset.outPort, waiting.inPort[4]) connect(minCapacityInput, zeroOrderHold.u) if maxCapacityExternal then connect(minCapacityInput, zeroOrderHold.u) else zeroOrderHold.u = 0; end if; end ColdProducerAgent;
Name of the corresponding broker-agent.
within AixLib.Controls.HVACAgentBasedControl.Agents; model ConsumerAgent extends BaseClasses.PartialAgent( name=10001, uDPSend_adapted(userBufferSize=100000, autoBufferSize=true), uDPReceive_adapted(userBufferSize=100000, autoBufferSize=true)); parameter Integer broker = 10003 "Name of the corresponding broker-agent"; parameter Real sampleStartTime = 0 "Time when the agent makes first request"; parameter Real sampleTriggerTime = 60 "Time difference between two calls for adjustment [s]"; Modelica.Blocks.Sources.SampleTrigger sampleTrigger( startTime= sampleStartTime, period=sampleTriggerTime) Modelica.StateGraph.InitialStep waiting( nOut=2, nIn=3) Modelica.StateGraph.TransitionWithSignal newMessage Modelica.Blocks.Math.IntegerChange integerChange Modelica.StateGraph.TransitionWithSignal transitionWithSignal Modelica.StateGraph.Step composeRequest(nOut=1, nIn=3) Modelica.StateGraph.Transition requestNoted(enableTimer=true, waitTime= 0.1) Modelica.StateGraph.StepWithSignal sendRequest(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal newMessage1 "confirmation" Modelica.StateGraph.Transition repeat(enableTimer=true, waitTime=10) Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y=noEvent( getperformative.y[1] == 5)) Modelica.StateGraph.Step state(nIn=1, nOut=2) Modelica.StateGraph.TransitionWithSignal rightMessage "confirmation" Modelica.StateGraph.Transition repeat1(enableTimer=true, waitTime=10) Modelica.StateGraph.Step composeNotUnderstood(nIn=1, nOut=1) Modelica.StateGraph.Transition transition2(enableTimer=true, waitTime=0.1) Modelica.StateGraph.StepWithSignal sendNotUnderstood(nOut=1, nIn=1) Modelica.StateGraph.Transition transition4(enableTimer=true, waitTime=0.1) Modelica.Blocks.Logical.Or or2 Modelica.StateGraph.Step composeConfirm(nOut=1, nIn=1) Modelica.StateGraph.StepWithSignal sendConfirm(nOut=1, nIn=1) Modelica.StateGraph.Transition confirmNoted(enableTimer=true, waitTime= 0.1) Modelica.StateGraph.Transition transition1(enableTimer=true, waitTime=0.1) Modelica.Blocks.Logical.Or or3 Modelica.StateGraph.Step waitForInform( nIn=1, nOut=2) Modelica.StateGraph.TransitionWithSignal rightMessage1 "confirmation" Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y= getperformative.y[1] == 8) Modelica.Blocks.Interfaces.RealInput demand "Input for the demand estimation of the consumer (e.g. output of a PID element)" Modelica.Blocks.Logical.And and1 Modelica.Blocks.Sources.BooleanExpression booleanExpression(y=(abs(demand) >= 20)) Modelica.StateGraph.Transition reset(enableTimer=true, waitTime=180) algorithm when noEvent(waiting.active) then content.u[1] := 0; content.u[2] := 0; end when; when noEvent(composeRequest.active) then content.u[1] := demand; //temporary function content.u[2] := 0; performative.u[1]:= 19; sender.u[1]:=name; receiver.u[1]:= broker; reply_to.u[1] := name; ontology.u[1] := 1; uDPSend_adapted.receiver := broker; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("ConsumerAgent "+ String(name)+ " requests " + String(content.u[1]) + " W of heat from Broker "+ String(broker)+"."); end when; // Send out "not understood" message, if message has unknown performative when noEvent(composeNotUnderstood.active) then content.u[1] := 0; content.u[2] := 0; performative.u[1] := 11; //"not understood" sender.u[1] := name; receiver.u[1] := getsender.y[1]; uDPSend_adapted.receiver := getsender.y[1]; ontology.u[1] := getontology.y[1]; messageID.u[1] := name*name + integer(time); end when; // Confirm the information by broker when noEvent(composeConfirm.active) then content.u[1] := get_content.y[1]; content.u[2] := get_content.y[2]; performative.u[1] := 5; //"confirm" receiver.u[1] := broker; reply_to.u[1] := name; ontology.u[1] := 1; uDPSend_adapted.receiver := broker; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("ConsumerAgent "+ String(name)+ " confirms the request of " + String(content.u[2]) + " W of heat " + "for a price of "+String(content.u[1])+"."); end when; equation connect(integerChange.u, getMessageID.y[1]) connect(transitionWithSignal.inPort, waiting.outPort[1]) connect(composeRequest.inPort[1], transitionWithSignal.outPort) connect(requestNoted.inPort, composeRequest.outPort[1]) connect(requestNoted.outPort, sendRequest.inPort[1]) connect(newMessage1.inPort, sendRequest.outPort[1]) connect(repeat.outPort, composeRequest.inPort[2]) connect(repeat.inPort, sendRequest.outPort[2]) connect(integerChange.y, newMessage1.condition) connect(state.inPort[1], newMessage1.outPort) connect(repeat1.outPort, composeRequest.inPort[3]) connect(repeat1.inPort, state.outPort[2]) connect(rightMessage.inPort, state.outPort[1]) connect(booleanExpression1.y, rightMessage.condition) connect(newMessage.inPort, waiting.outPort[2]) connect(newMessage.condition, newMessage1.condition) connect(composeNotUnderstood.inPort[1], newMessage.outPort) connect(composeNotUnderstood.outPort[1], transition2.inPort) connect(transition2.outPort, sendNotUnderstood.inPort[1]) connect(sendNotUnderstood.outPort[1], transition4.inPort) connect(transition4.outPort, waiting.inPort[2]) connect(sendRequest.active, or2.u1) connect(sendNotUnderstood.active, or2.u2) connect(confirmNoted.inPort, composeConfirm.outPort[1]) connect(confirmNoted.outPort, sendConfirm.inPort[1]) connect(sendConfirm.outPort[1], transition1.inPort) connect(transition1.outPort, waiting.inPort[1]) connect(or3.u1, sendConfirm.active) connect(or2.y, or3.u2) connect(or3.y, uDPSend_adapted.trigger) connect(waitForInform.outPort[1], rightMessage1.inPort) connect(booleanExpression2.y, rightMessage1.condition) connect(rightMessage.outPort, waitForInform.inPort[1]) connect(rightMessage1.outPort, composeConfirm.inPort[1]) connect(and1.u2, sampleTrigger.y) connect(booleanExpression.y, and1.u1) connect(and1.y, transitionWithSignal.condition) connect(waitForInform.outPort[2],reset. inPort) connect(reset.outPort, waiting.inPort[3]) end ConsumerAgent;
maximum capacity for heatgeneration.
within AixLib.Controls.HVACAgentBasedControl.Agents; model HeatProducerAgent extends BaseClasses.PartialAgent; parameter Real maxCapacity = 100000 "maximum capacity for heatgeneration"; parameter Real minCapacity = 0 "minimum capacity for heatgeneration"; Real costCurrent(start=40) "Real variable to define costCurrent"; Real costNew(start=0) "Real variable to define costNew"; Real setCapacity(start=2000) "Real variable to define setCapacity"; Real costDifference(start=0) "Real variable to define costDifference"; Real totalRequest(start=0) "Real variable to define totalRequest"; Real currentCapacityDiscrete(start=2000) "Real variable to define currentCapacityDiscrete"; Real maxCapacityInternal "Real variable to define maxCapacityInternal"; Real calcCapacityInternal(start=1) "Real variable to define calcCapacityInternal"; parameter Boolean maxCapacityExternal=false "Real variable to define maxCapacityExternal"; // CostFunction related components // This section contains the blocks for the state-machine logic of the agent Modelica.StateGraph.InitialStep waiting( nOut=2, nIn=4) Modelica.StateGraph.TransitionWithSignal newMessage Modelica.StateGraph.Step message(nOut=2, nIn=1) Modelica.StateGraph.Step adjustHeat(nIn=1, nOut=1) Modelica.StateGraph.TransitionWithSignal transition2( enableTimer=true) Modelica.StateGraph.Step computeProposal(nIn=1, nOut=1) Modelica.Blocks.Sources.BooleanExpression booleanExpression(y=noEvent( getperformative.y[1] == 4)) Modelica.StateGraph.TransitionWithSignal transitionWithSignal( waitTime=0.5, enableTimer=false) Modelica.StateGraph.TransitionWithSignal transitionWithSignal1( waitTime=0.5, enableTimer=false) Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y=noEvent( getperformative.y[1] == 1 and integerChange.y)) Modelica.StateGraph.Transition transition1( waitTime=0.1, enableTimer=true) Modelica.StateGraph.StepWithSignal sendProposal(nOut=3, nIn=1) Modelica.Blocks.Math.IntegerChange integerChange Modelica.StateGraph.TransitionWithSignal transitionWithSignal2( waitTime=0.5, enableTimer=false) Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y=noEvent( getperformative.y[1] == 18 and integerChange.y)) Modelica.StateGraph.TransitionWithSignal transitionWithSignal3( enableTimer= true, waitTime=0.5) Modelica.Blocks.Sources.BooleanExpression booleanExpression3(y=noEvent( getperformative.y[1] == 4)) Modelica.Blocks.Logical.Not not1 Modelica.StateGraph.Step composeNotUnderstood(nIn=1, nOut=1) Modelica.StateGraph.Transition transition3(enableTimer=true, waitTime=1) Modelica.StateGraph.StepWithSignal sendNotUnderstood(nOut=1, nIn=1) Modelica.StateGraph.Transition transition4(enableTimer=true, waitTime=1) Modelica.Blocks.Logical.Or or1 Modelica.Blocks.Interfaces.RealInput currentCapacity "Input for current capacity of device" Modelica.Blocks.Interfaces.RealOutput setCapacityOut "Output for set capacity of device" Modelica.StateGraph.StepWithSignal sendConfirmation( nIn=2, nOut=1) Modelica.StateGraph.Transition transition5( waitTime=0.1, enableTimer=true) Modelica.Blocks.Logical.Or or2 public Modelica.StateGraph.Step confirm(nIn=1, nOut=1) Modelica.StateGraph.Transition transition6( enableTimer=true, waitTime=2) Modelica.Blocks.Interfaces.RealOutput calcCapacity "Output to connect with cost function" Modelica.Blocks.Interfaces.RealInput calcCost "Input to connect with cost function" Modelica.Blocks.Interfaces.BooleanInput OnOff_external "External on/off switch" Modelica.StateGraph.Step shutDown( nOut=1, nIn=1) Modelica.StateGraph.TransitionWithSignal Off Modelica.Blocks.Logical.Not not2 Modelica.StateGraph.Transition transition7( waitTime=0.1, enableTimer=true) Modelica.Blocks.Sources.BooleanExpression booleanExpression4(y=noEvent(abs( setCapacity) > 30)) Modelica.Blocks.Logical.And and1 Modelica.StateGraph.Transition reset(enableTimer=true, waitTime=60) Modelica.Blocks.Sources.BooleanExpression booleanExpression5(y=setCapacityOut >= get_content.y[1]) Modelica.Blocks.Interfaces.RealInput maxCapacityInput if maxCapacityExternal "Input for external maximum capacity" Modelica.Blocks.Discrete.ZeroOrderHold zeroOrderHold(samplePeriod=3600) Modelica.Blocks.Sources.RealExpression realExpression(y=calcCapacityInternal) equation if maxCapacityExternal then // connect(maxCapacity,maxCapacityInternal); maxCapacityInternal = zeroOrderHold.y; else maxCapacityInternal = maxCapacity; end if; connect(newMessage.inPort, waiting.outPort[1]) connect(newMessage.outPort, message.inPort[1]) connect(adjustHeat.outPort[1], transition2.inPort) connect(booleanExpression.y, transitionWithSignal.condition) connect(computeProposal.inPort[1], transitionWithSignal.outPort) connect(booleanExpression1.y, transitionWithSignal1.condition) connect(adjustHeat.inPort[1], transitionWithSignal1.outPort) connect(transition1.inPort, computeProposal.outPort[1]) connect(sendProposal.inPort[1], transition1.outPort) connect(getMessageID.y[1], integerChange.u) connect(integerChange.y, newMessage.condition) connect(sendProposal.outPort[1], transitionWithSignal1.inPort) connect(transitionWithSignal2.condition, booleanExpression2.y) connect(transitionWithSignal2.inPort, sendProposal.outPort[2]) connect(message.outPort[1], transitionWithSignal.inPort) connect(booleanExpression3.y, not1.u) connect(transitionWithSignal3.condition, not1.y) connect(transitionWithSignal3.inPort, message.outPort[2]) connect(composeNotUnderstood.inPort[1], transitionWithSignal3.outPort) connect(composeNotUnderstood.outPort[1], transition3.inPort) connect(transition3.outPort, sendNotUnderstood.inPort[1]) connect(transition4.inPort, sendNotUnderstood.outPort[1]) // The algorithm section contains the logic of the broker, describing the // actions taken during each active state of the agent algorithm when noEvent(waiting.active) then currentCapacityDiscrete := currentCapacity; calcCapacityInternal := setCapacity; costCurrent := calcCost; end when; // ExternalshutDown when noEvent(shutDown.active) then setCapacity :=0; setCapacityOut := setCapacity; end when; // Compute costs for the requested amount of heat when noEvent(computeProposal.active) then if get_content.y[1] >0 then if noEvent(((setCapacity+get_content.y[1]) >= maxCapacityInternal)) then if noEvent(setCapacity > (maxCapacityInternal-1)) then content.u[1] := 0; content.u[2] := 0; performative.u[1] := 17; Modelica.Utilities.Streams.print("HeatProducerAgent "+ String(name)+ " refuses proposal due to maximum capacity."); else totalRequest := maxCapacityInternal; calcCapacityInternal := totalRequest; costNew := calcCost; content.u[2] := maxCapacityInternal - setCapacity; performative.u[1] := 13; //propose costDifference := costNew - costCurrent; content.u[1] := costDifference; Modelica.Utilities.Streams.print("HeatProducerAgent "+ String(name)+ " proposes adjustment of " + String(content.u[2]) + " W " + "for a price of "+String(content.u[1])+"."); end if; else totalRequest := setCapacity+get_content.y[1]; calcCapacityInternal := totalRequest; costNew := calcCost; content.u[2] := get_content.y[1]; performative.u[1] := 13; //propose costDifference := costNew - costCurrent; content.u[1] := costDifference; Modelica.Utilities.Streams.print("HeatProducerAgent "+ String(name)+ " proposes adjustment of " + String(content.u[2]) + " W " + "for a price of "+String(content.u[1])+"."); end if; else if noEvent(((setCapacity+get_content.y[1]) <= minCapacity)) then if noEvent(setCapacity < 0+1) then totalRequest := 0; calcCapacityInternal := 0; costNew := calcCost; content.u[2] := 0; performative.u[1] := 17; //refuse content.u[1] := 0; Modelica.Utilities.Streams.print("HeatProducerAgent "+ String(name)+ " refuses proposal due to minimum capacity."); else totalRequest := 0; calcCapacityInternal := totalRequest; costNew := calcCost; content.u[2] := minCapacity - setCapacity; performative.u[1] := 13; //propose costDifference := costNew - costCurrent; content.u[1] := costDifference; Modelica.Utilities.Streams.print("HeatProducerAgent "+ String(name)+ " proposes adjustment of " + String(content.u[2]) + " W " + "for a price of "+String(content.u[1])+"."); end if; else totalRequest := setCapacity+get_content.y[1]; calcCapacityInternal := totalRequest; costNew := calcCost; content.u[2] := get_content.y[1]; performative.u[1] := 13; //propose costDifference := costNew - costCurrent; content.u[1] := costDifference; Modelica.Utilities.Streams.print("HeatProducerAgent "+ String(name)+ " proposes adjustment of " + String(content.u[2]) + " W " + "for a price of "+String(content.u[1])+"."); end if; end if; uDPSend_adapted.receiver := getsender.y[1]; receiver.u[1] := getsender.y[1]; ontology.u[1] := 1; reply_to.u[1] := name; sender.u[1] :=name; messageID.u[1] := name*name + integer(time); end when; // Adjust heat according to the confirmation by the broker, send confirmation when (adjustHeat.active) then setCapacity := setCapacity + get_content.y[1]; setCapacityOut :=setCapacity; content.u[1] := 0; content.u[2] := 0; performative.u[1] := 5; //"confirm" uDPSend_adapted.receiver := getsender.y[1]; receiver.u[1] := getsender.y[1]; ontology.u[1] := 1; reply_to.u[1] := name; sender.u[1] :=name; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("HeatProducerAgent "+ String(name)+ " confirms the adjustment of " + String(get_content.y[1]) + " W of heat. The setpoint is now " + String(setCapacityOut) +"W."); end when; // Confirm the receiving of the reject when noEvent(confirm.active) then uDPSend_adapted.receiver := getsender.y[1]; receiver.u[1] := getsender.y[1]; performative.u[1] := 5; sender.u[1] :=name; content.u[1] := 0; content.u[2] := 0; end when; // Send out "not understood" message, if message has unknown performative when noEvent(composeNotUnderstood.active) then uDPSend_adapted.receiver := getsender.y[1]; receiver.u[1] := getsender.y[1]; performative.u[1] := 11; //"not understood" content.u[1] := 0; content.u[2] := 0; messageID.u[1] := name*name + integer(time); sender.u[1] :=name; end when; equation connect(transition2.outPort, sendConfirmation.inPort[1]) connect(sendConfirmation.outPort[1], transition5.inPort) connect(transition5.outPort, waiting.inPort[2]) connect(sendNotUnderstood.active, or2.u1) connect(sendConfirmation.active, or1.u1) connect(sendProposal.active, or1.u2) connect(confirm.inPort[1], transitionWithSignal2.outPort) connect(transition6.inPort, confirm.outPort[1]) connect(transition6.outPort, sendConfirmation.inPort[2]) connect(transition4.outPort, waiting.inPort[1]) /* connect(calcCapacity, calcCapacity) */ connect(OnOff_external, not2.u) connect(Off.inPort, waiting.outPort[2]) connect(shutDown.inPort[1], Off.outPort) connect(transition7.inPort, shutDown.outPort[1]) connect(transition7.outPort, waiting.inPort[3]) connect(and1.u2, booleanExpression4.y) connect(and1.u1, not2.y) connect(and1.y, Off.condition) connect(reset.inPort, sendProposal.outPort[3]) connect(reset.outPort, waiting.inPort[4]) connect(or1.y, or2.u2) connect(or2.y, uDPSend_adapted.trigger) connect(booleanExpression5.y, transition2.condition) if maxCapacityExternal then connect(maxCapacityInput, zeroOrderHold.u) else zeroOrderHold.u = 0; end if; connect(realExpression.y, calcCapacity) end HeatProducerAgent;
Name of the corresponding broker-agent.
within AixLib.Controls.HVACAgentBasedControl.Agents; model IntermediateAgent extends BaseClasses.PartialAgent; parameter Integer broker = 10003 "Name of the corresponding broker-agent"; parameter Real maxCapacity = 10000 "maximum capacity"; Integer currentClient(start=0) "Integer variable to define currentClient"; Real currentCost( start= 0) "Real variable to define currentCost"; Real setCapacity(start=0) "Real variable to define setCapacity"; Real newCost(start=0) "Real variable to define newCost"; Real ownCost(start=0) "Real variable to define ownCost"; // CostFunction related components // This section contains the blocks for the state-machine logic of the agent Modelica.StateGraph.InitialStep waiting(nOut=2, nIn=5) Modelica.StateGraph.TransitionWithSignal newMessage Modelica.StateGraph.Step message(nOut=2, nIn=1) Modelica.StateGraph.Step passOnCall(nIn=1, nOut=1) Modelica.Blocks.Sources.BooleanExpression booleanExpression(y=noEvent( getperformative.y[1] == 4)) Modelica.StateGraph.TransitionWithSignal transitionWithSignal( waitTime=0.5, enableTimer=false) Modelica.StateGraph.Transition transition1( waitTime=0.1, enableTimer=true) Modelica.StateGraph.StepWithSignal sendCall(nOut=2, nIn=1) Modelica.Blocks.Math.IntegerChange integerChange Modelica.StateGraph.TransitionWithSignal transitionWithSignal3( enableTimer= true, waitTime=0.5) Modelica.Blocks.Sources.BooleanExpression booleanExpression3(y=noEvent( getperformative.y[1] == 4)) Modelica.Blocks.Logical.Not not1 Modelica.StateGraph.Step composeNotUnderstood(nIn=1, nOut=1) Modelica.StateGraph.Transition transition3(enableTimer=true, waitTime=1) Modelica.StateGraph.StepWithSignal sendNotUnderstood(nOut=1, nIn=1) Modelica.StateGraph.Transition transition4(enableTimer=true, waitTime=1) Modelica.StateGraph.TransitionWithSignal fromTopBroker(waitTime=0.5, enableTimer=false) Modelica.StateGraph.TransitionWithSignal newMessage1 Modelica.StateGraph.Step check(nIn=1, nOut=1) Modelica.Blocks.Sources.BooleanExpression booleanExpression4(y=noEvent(( getperformative.y[1] == 8) and (getsender.y[1] == broker))) Modelica.StateGraph.Step passOnInformation(nIn=1, nOut=1) Modelica.StateGraph.Transition transition7( waitTime=0.1, enableTimer=true) Modelica.StateGraph.StepWithSignal sendInformation(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal newMessage2 Modelica.StateGraph.Step check1(nIn=1, nOut=1) Modelica.StateGraph.TransitionWithSignal fromBottomBroker(waitTime=0.5, enableTimer=false) Modelica.StateGraph.Step passOnConfirmation(nIn=1, nOut=1) Modelica.StateGraph.Transition transition8( waitTime=0.1, enableTimer=true) Modelica.StateGraph.StepWithSignal sendConfirmation( nOut=1, nIn=1) Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y=noEvent(( getsender.y[1] == currentClient))) Modelica.StateGraph.Transition transition2( waitTime=0.1, enableTimer=true) Modelica.StateGraph.Step confirmToBottom(nIn=1, nOut=1) Modelica.StateGraph.Transition transition5( waitTime=0.1, enableTimer=true) Modelica.StateGraph.StepWithSignal sendConfirmation1( nOut=1, nIn=1) Modelica.StateGraph.Transition transition6( waitTime=0.1, enableTimer=true) Modelica.Blocks.Logical.Or or1 Modelica.Blocks.Logical.Or or2 Modelica.Blocks.Logical.Or or3 Modelica.Blocks.Logical.Or or4 Modelica.Blocks.Interfaces.RealOutput calcCapacity "Output to connect with cost function" Modelica.Blocks.Interfaces.RealInput calcCost "Input to connect with cost function" Modelica.Blocks.Interfaces.RealInput currentCapacity "Input for current capacity of device" Modelica.Blocks.Interfaces.RealOutput setCapacityOut(start=0.001) "Output for set capacity of device" Modelica.StateGraph.Transition reset(enableTimer=true, waitTime=60) Modelica.StateGraph.Transition reset1( enableTimer=true, waitTime=60) Modelica.Blocks.Interfaces.BooleanInput OnOff_external "External on/off switch" Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y=noEvent(abs( setCapacity) > 30)) Modelica.Blocks.Logical.And and1 Modelica.StateGraph.Step shutDown( nOut=1, nIn=1) Modelica.StateGraph.Transition transition9( waitTime=0.1, enableTimer=true) Modelica.StateGraph.TransitionWithSignal Off Modelica.Blocks.Logical.Not not2 equation connect(newMessage.inPort, waiting.outPort[1]) connect(newMessage.outPort, message.inPort[1]) connect(booleanExpression.y, transitionWithSignal.condition) connect(passOnCall.inPort[1], transitionWithSignal.outPort) connect(transition1.inPort, passOnCall.outPort[1]) connect(sendCall.inPort[1], transition1.outPort) connect(getMessageID.y[1], integerChange.u) connect(integerChange.y, newMessage.condition) connect(message.outPort[1], transitionWithSignal.inPort) connect(booleanExpression3.y, not1.u) connect(transitionWithSignal3.condition, not1.y) connect(transitionWithSignal3.inPort, message.outPort[2]) connect(composeNotUnderstood.inPort[1], transitionWithSignal3.outPort) connect(composeNotUnderstood.outPort[1], transition3.inPort) connect(transition3.outPort, sendNotUnderstood.inPort[1]) connect(transition4.inPort, sendNotUnderstood.outPort[1]) // The algorithm section contains the logic of the broker, describing the // actions taken during each active state of the agent algorithm when waiting.active then currentClient := 0; calcCapacity := setCapacity; currentCost := calcCost; end when; // ExternalshutDown when noEvent(shutDown.active) then setCapacity :=0; setCapacityOut := setCapacity; end when; // Compute costs for the requested amount of heat when passOnCall.active then currentClient := getsender.y[1]; performative.u[1] := 19; sender.u[1] := name; receiver.u[1] := broker; reply_to.u[1] := name; content.u[1] := get_content.y[1]; content.u[2] := get_content.y[2]; ontology.u[1] := getontology.y[1]; uDPSend_adapted.receiver := broker; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("IntermediateAgent "+ String(name)+ " got a call from bottom broker " + String(currentClient) + " and passes it on to top broker " + String(broker) +"."); end when; when passOnInformation.active then performative.u[1] := 13; sender.u[1] := name; reply_to.u[1] := name; receiver.u[1] := currentClient; uDPSend_adapted.receiver := currentClient; calcCapacity := get_content.y[2]; newCost :=calcCost; ownCost := newCost -currentCost; content.u[1] := get_content.y[1]+ownCost; content.u[2] := get_content.y[2]; ontology.u[1] := getontology.y[1]; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("IntermediateAgent "+ String(name)+ " got an information from top broker " + String(broker) + " and passes it on as a proposal to bottom broker " + String(currentClient) +" after adding own costs of " + String(ownCost) +"."); end when; when passOnConfirmation.active then if getperformative.y[1] == 1 then performative.u[1] := 5; Modelica.Utilities.Streams.print("IntermediateAgent "+ String(name)+ " got an accept proposal from " + String(currentClient) + " and passes it on as a confirmation to top broker " + String(broker) +"."); else performative.u[1] := 3; Modelica.Utilities.Streams.print("IntermediateAgent "+ String(name)+ " got an reject proposal from " + String(currentClient) + " and passes it on as a cancel to top broker " + String(broker) +"."); end if; sender.u[1] := name; receiver.u[1] := broker; reply_to.u[1] := name; uDPSend_adapted.receiver := broker; content.u[1] := get_content.y[2]; content.u[2] := get_content.y[1]; ontology.u[1] := getontology.y[1]; messageID.u[1] := name*name + integer(time); end when; when confirmToBottom.active then performative.u[1] := 5; sender.u[1] := name; reply_to.u[1] := name; receiver.u[1] := currentClient; uDPSend_adapted.receiver := currentClient; content.u[1] := get_content.y[2]; content.u[2] := get_content.y[1]; ontology.u[1] := getontology.y[1]; messageID.u[1] := name*name + integer(time); if getperformative.y[1] == 1 then Modelica.Utilities.Streams.print("IntermediateAgent "+ String(name)+ " confirms the adjustment of " + String(get_content.y[1]) + " W of heat."); setCapacity := max(min(setCapacity+get_content.y[1],maxCapacity),0); setCapacityOut := setCapacity; end if; end when; // Send out "not understood" message, if message has unknown performative when composeNotUnderstood.active then performative.u[1] := 11; //"not understood" content.u[1] := 0; content.u[2] := 0; messageID.u[1] := name*name + integer(time); end when; equation connect(transition4.outPort, waiting.inPort[1]) connect(sendCall.outPort[1], newMessage1.inPort) connect(newMessage1.outPort, check.inPort[1]) connect(check.outPort[1], fromTopBroker.inPort) connect(fromTopBroker.outPort, passOnInformation.inPort[1]) connect(passOnInformation.outPort[1], transition7.inPort) connect(transition7.outPort, sendInformation.inPort[1]) connect(sendInformation.outPort[1], newMessage2.inPort) connect(newMessage2.outPort, check1.inPort[1]) connect(check1.outPort[1], fromBottomBroker.inPort) connect(fromBottomBroker.outPort, passOnConfirmation.inPort[1]) connect(passOnConfirmation.outPort[1], transition8.inPort) connect(transition8.outPort, sendConfirmation.inPort[1]) connect(booleanExpression4.y, fromTopBroker.condition) connect(booleanExpression1.y, fromBottomBroker.condition) connect(sendConfirmation.outPort[1], transition2.inPort) connect(transition2.outPort, confirmToBottom.inPort[1]) connect(confirmToBottom.outPort[1], transition5.inPort) connect(transition5.outPort, sendConfirmation1.inPort[1]) connect(transition6.inPort, sendConfirmation1.outPort[1]) connect(transition6.outPort, waiting.inPort[2]) connect(newMessage1.condition, integerChange.y) connect(newMessage2.condition, newMessage.condition) connect(sendCall.active, or1.u1) connect(sendInformation.active, or1.u2) connect(sendNotUnderstood.active, or2.u2) connect(sendConfirmation1.active, or2.u1) connect(or3.u1, sendConfirmation.active) connect(or2.y, or3.u2) connect(or4.u2, or3.y) connect(or4.y, uDPSend_adapted.trigger) connect(or4.u1, or1.y) connect(reset.inPort, sendCall.outPort[2]) connect(sendInformation.outPort[2], reset1.inPort) connect(reset.outPort, waiting.inPort[3]) connect(reset1.outPort, waiting.inPort[4]) connect(and1.u2, booleanExpression2.y) connect(Off.inPort, waiting.outPort[2]) connect(Off.outPort, shutDown.inPort[1]) connect(shutDown.outPort[1], transition9.inPort) connect(and1.y, Off.condition) connect(transition9.outPort, waiting.inPort[5]) connect(OnOff_external, not2.u) connect(not2.y, and1.u1) end IntermediateAgent;
Number of Boolean inputs (number of other agents in the system).
within AixLib.Controls.HVACAgentBasedControl.Agents; model MessageNotification parameter Integer n=1 "Number of Boolean inputs (number of other agents in the system)"; parameter Boolean usePoke=false "Mode for different type of communication (standard is false)"; Modelica.Blocks.MathBoolean.Or receiverCollector(nu=n) if usePoke Modelica.Blocks.Interfaces.BooleanInput receive[n] if usePoke "Input to connect with other agents" Modelica.Blocks.Interfaces.BooleanOutput y "Notification for other agents (not connected to anything)" equation connect(receive,receiverCollector. u) if usePoke then connect(receiverCollector.y, y) else y = false; end if; end MessageNotification;
Set temperature by the user.
within AixLib.Controls.HVACAgentBasedControl.Agents; model RoomAgent extends BaseClasses.PartialAgent( name=10001, uDPSend_adapted(userBufferSize=100000, autoBufferSize=true), uDPReceive_adapted(userBufferSize=100000, autoBufferSize=true)); parameter Real T_set = 273.15+20 "Set temperature by the user"; parameter Integer broker = 10003 "Name of the corresponding broker-agent"; parameter Real startTime = 0 "Time when the agent makes first request"; parameter Real threshold = 2 "Temperature threshold difference when agent gets active"; parameter Real sampleTriggerTime = 60 "Time difference between two calls for adjustment [s]"; parameter Real P=50 "Proportional factor for load estimation"; parameter Real Kd = 30000 "Derivative factor for load estimation"; parameter Real G=1 "Gain for the load estimation"; Modelica.Blocks.Interfaces.RealInput T "Room temperature" Modelica.Blocks.Math.Add add(k2=-1) Modelica.Blocks.Logical.GreaterThreshold T_too_high(threshold=threshold) Modelica.Blocks.Math.Add add1(k2=-1) Modelica.Blocks.Logical.GreaterThreshold T_too_low(threshold=threshold) Modelica.Blocks.Sources.SampleTrigger sampleTrigger( startTime= startTime, period=sampleTriggerTime) Modelica.Blocks.Logical.Or or1 Modelica.Blocks.Logical.And actionTrigger Modelica.StateGraph.InitialStep waiting( nOut=2, nIn=3) Modelica.StateGraph.TransitionWithSignal newMessage Modelica.Blocks.Math.IntegerChange integerChange Modelica.StateGraph.TransitionWithSignal transitionWithSignal Modelica.StateGraph.Step composeRequest(nOut=1, nIn=3) Modelica.StateGraph.Transition requestNoted(enableTimer=true, waitTime=1) Modelica.StateGraph.StepWithSignal sendRequest(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal newMessage1 "confirmation" Modelica.StateGraph.Transition repeat(enableTimer=true, waitTime= 100000000) Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y=noEvent( getperformative.y[1] == 5)) Modelica.StateGraph.Step state(nIn=1, nOut=2) Modelica.StateGraph.TransitionWithSignal rightMessage "confirmation" Modelica.StateGraph.Transition repeat1(enableTimer=true, waitTime= 100000000000.0) Modelica.StateGraph.Step composeNotUnderstood(nIn=1, nOut=1) Modelica.StateGraph.Transition transition2(enableTimer=true, waitTime=1) Modelica.StateGraph.StepWithSignal sendNotUnderstood(nOut=1, nIn=1) Modelica.StateGraph.Transition transition4(enableTimer=true, waitTime=1) Modelica.Blocks.Logical.Or or2 protected Modelica.Blocks.Interfaces.RealOutput T_ref public Modelica.StateGraph.Step composeConfirm(nOut=1, nIn=1) Modelica.StateGraph.StepWithSignal sendConfirm(nOut=1, nIn=1) Modelica.StateGraph.Transition confirmNoted(enableTimer=true, waitTime=1) Modelica.StateGraph.Transition transition1(enableTimer=true, waitTime=1) Modelica.Blocks.Logical.Or or3 Modelica.StateGraph.Step waitForInform( nIn=1, nOut=2) Modelica.StateGraph.TransitionWithSignal rightMessage1 "confirmation" Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y=noEvent( getperformative.y[1] == 8)) Modelica.Blocks.Continuous.Derivative derivative Modelica.StateGraph.Transition reset(enableTimer=true, waitTime=180) algorithm when noEvent(waiting.active) then content.u[1] := 0; content.u[2] := 0; end when; when noEvent(composeRequest.active) then content.u[1] := G*(P*add1.y+Kd*derivative.y); //temporary function content.u[2] := 0; performative.u[1]:= 19; sender.u[1]:=name; receiver.u[1]:= broker; reply_to.u[1] := name; ontology.u[1] := 1; uDPSend_adapted.receiver := broker; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("RoomAgent "+ String(name)+ " requests " + String(content.u[1]) + " W of heat from Broker "+ String(broker)+"."); end when; // Send out "not understood" message, if message has unknown performative when noEvent(composeNotUnderstood.active) then content.u[1] := 0; content.u[2] := 0; performative.u[1] := 11; //"not understood" sender.u[1] := name; receiver.u[1] := getsender.y[1]; uDPSend_adapted.receiver := getsender.y[1]; ontology.u[1] := getontology.y[1]; messageID.u[1] := name*name + integer(time); end when; // Confirm the information by broker when noEvent(composeConfirm.active) then content.u[1] := get_content.y[1]; content.u[2] := get_content.y[2]; performative.u[1] := 5; //"confirm" receiver.u[1] := broker; reply_to.u[1] := name; ontology.u[1] := 1; uDPSend_adapted.receiver := broker; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("RoomAgent "+ String(name)+ " confirms the request of " + String(content.u[2]) + " W of heat " + "for a price of "+String(content.u[1])+"."); end when; equation T_ref = T_set; connect(T, add.u1) connect(add.u2, T_ref) connect(add.y, T_too_high.u) connect(add1.u2, add.u1) connect(add1.u1, T_ref) connect(T_too_low.u, add1.y) connect(T_too_low.y, or1.u2) connect(T_too_high.y, or1.u1) connect(T_ref, T_ref) connect(actionTrigger.u2, sampleTrigger.y) connect(integerChange.u, getMessageID.y[1]) connect(transitionWithSignal.inPort, waiting.outPort[1]) connect(composeRequest.inPort[1], transitionWithSignal.outPort) connect(requestNoted.inPort, composeRequest.outPort[1]) connect(requestNoted.outPort, sendRequest.inPort[1]) connect(newMessage1.inPort, sendRequest.outPort[1]) connect(repeat.outPort, composeRequest.inPort[2]) connect(repeat.inPort, sendRequest.outPort[2]) connect(integerChange.y, newMessage1.condition) connect(state.inPort[1], newMessage1.outPort) connect(repeat1.outPort, composeRequest.inPort[3]) connect(repeat1.inPort, state.outPort[2]) connect(rightMessage.inPort, state.outPort[1]) connect(booleanExpression1.y, rightMessage.condition) connect(newMessage.inPort, waiting.outPort[2]) connect(newMessage.condition, newMessage1.condition) connect(composeNotUnderstood.inPort[1], newMessage.outPort) connect(composeNotUnderstood.outPort[1], transition2.inPort) connect(transition2.outPort, sendNotUnderstood.inPort[1]) connect(sendNotUnderstood.outPort[1], transition4.inPort) connect(transition4.outPort, waiting.inPort[2]) connect(actionTrigger.y, transitionWithSignal.condition) connect(sendRequest.active, or2.u1) connect(sendNotUnderstood.active, or2.u2) connect(confirmNoted.inPort, composeConfirm.outPort[1]) connect(confirmNoted.outPort, sendConfirm.inPort[1]) connect(sendConfirm.outPort[1], transition1.inPort) connect(transition1.outPort, waiting.inPort[1]) connect(or3.u1, sendConfirm.active) connect(or2.y, or3.u2) connect(or3.y, uDPSend_adapted.trigger) connect(waitForInform.outPort[1], rightMessage1.inPort) connect(booleanExpression2.y, rightMessage1.condition) connect(rightMessage.outPort, waitForInform.inPort[1]) connect(rightMessage1.outPort, composeConfirm.inPort[1]) connect(derivative.u, add1.y) connect(or1.y, actionTrigger.u1) connect(waitForInform.outPort[2], reset.inPort) connect(reset.outPort, waiting.inPort[3]) end RoomAgent;
Name of the agent (five-digit number, eg. 10001).
within AixLib.Controls.HVACAgentBasedControl.BaseClasses; partial model PartialAgent parameter Integer name "Name of the agent (five-digit number, eg. 10001)"; parameter Boolean usePoke=false "Use Modelica internal communication for inbox update"; parameter Real sampleRate=5 "Sample time for inbox update (used if usePoke=false)"; outer HVACAgentBasedControl.Agents.MessageNotification messageNotification if usePoke; Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Packager packager Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddReal content(nu=1, n=2) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetReal get_content(nu= 1, n=2) Modelica_DeviceDrivers.Blocks.Communication.UDPReceive uDPReceive_adapted(port_recv=name, enableExternalTrigger= if usePoke then true else false, sampleTime= if usePoke then 10e20 else sampleRate) UDPSend_adapted uDPSend_adapted Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddInteger sender(nu=1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddInteger receiver(nu= 1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddInteger reply_to(nu= 1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddReal ontology(nu=1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetInteger getperformative(nu=1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetInteger getsender( nu=1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetInteger getreceiver( nu=1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetInteger getreply_to( nu=1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetReal getontology(nu=1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddInteger performative(nu=1) Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.GetInteger getMessageID Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.AddInteger messageID(nu=1) inner Modelica.StateGraph.StateGraphRoot stateGraphRoot SendSample sendSample if usePoke Modelica.Blocks.Interfaces.BooleanOutput sendOut if usePoke "Turns true when the sending unit of the agent is active" equation if usePoke then connect(messageNotification.y, uDPReceive_adapted.trigger); end if; connect(sender.pkgOut[1], receiver.pkgIn) connect(receiver.pkgOut[1], reply_to.pkgIn) connect(reply_to.pkgOut[1], content.pkgIn) connect(content.pkgOut[1], ontology.pkgIn) connect(getperformative.pkgIn, uDPReceive_adapted.pkgOut) connect(getperformative.pkgOut[1], getsender.pkgIn) connect(getsender.pkgOut[1], getreceiver.pkgIn) connect(getreceiver.pkgOut[1], getreply_to.pkgIn) connect(getreply_to.pkgOut[1], get_content.pkgIn) connect(get_content.pkgOut[1], getontology.pkgIn) connect(performative.pkgIn, packager.pkgOut) connect(performative.pkgOut[1], sender.pkgIn) connect(getontology.pkgOut[1], getMessageID.pkgIn) connect(ontology.pkgOut[1], messageID.pkgIn) connect(messageID.pkgOut[1], uDPSend_adapted.pkgIn) connect(sendSample.u, uDPSend_adapted.send) connect(sendOut, sendSample.y) end PartialAgent;
Input to connect with ProducerAgent.
within AixLib.Controls.HVACAgentBasedControl.BaseClasses; partial model PartialCostFunction Modelica.Blocks.Interfaces.RealInput capacity "Input to connect with ProducerAgent" Modelica.Blocks.Interfaces.RealOutput cost "Output to connect with ProducerAgent" equation end PartialCostFunction;
Input connected to boolean output of UDPSend_adapted.
within AixLib.Controls.HVACAgentBasedControl.BaseClasses; model SendSample Modelica.Blocks.MathBoolean.Or or1(nu=4) Modelica.Blocks.MathBoolean.OnDelay onDelay4(delayTime=0.1) Modelica.Blocks.MathBoolean.OnDelay onDelay5(delayTime=0.2) Modelica.Blocks.MathBoolean.OnDelay onDelay6(delayTime=0.5) Modelica.Blocks.MathBoolean.OnDelay onDelay7(delayTime=1) Modelica.Blocks.Interfaces.BooleanInput u "Input connected to boolean output of UDPSend_adapted" Modelica.Blocks.Interfaces.BooleanOutput y "Output connected to sendOut of PartialAgent" Modelica.Blocks.Logical.Edge edge1 Modelica.Blocks.Logical.Edge edge2 Modelica.Blocks.Logical.Edge edge3 Modelica.Blocks.Logical.Edge edge4 equation connect(onDelay4.u, u) connect(or1.y, y) connect(edge1.u, onDelay4.y) connect(onDelay5.y, edge2.u) connect(onDelay6.y, edge3.u) connect(onDelay7.y, edge4.u) connect(onDelay5.u, u) connect(onDelay6.u, u) connect(onDelay7.u, u) connect(edge1.y, or1.u[1]) connect(edge2.y, or1.u[2]) connect(edge3.y, or1.u[3]) connect(edge4.y, or1.u[4]) end SendSample;
A block for sending UDP datagrams.
within AixLib.Controls.HVACAgentBasedControl.BaseClasses; model UDPSend_adapted "A block for sending UDP datagrams" import Modelica_DeviceDrivers; extends Modelica_DeviceDrivers.Utilities.Icons.BaseIcon; extends Modelica_DeviceDrivers.Utilities.Icons.UDPconnection; import Modelica_DeviceDrivers.Packaging.SerialPackager; import Modelica_DeviceDrivers.Communication.UDPSocket; // Parameter Modelica.SIunits.Period sampleTime=0.01 // "Sample time for update"; parameter Boolean autoBufferSize = true "true, buffer size is deduced automatically, otherwise set it manually." parameter Integer userBufferSize=16*1024 "Buffer size of message data in bytes (if not deduced automatically)." parameter String IPAddress="127.0.0.1" "IP address of remote UDP server" Real port_send "Target port of the receiving UDP server" Modelica_DeviceDrivers.Blocks.Interfaces.PackageIn pkgIn "Port for the data to send" protected UDPSocket socket = UDPSocket(0); Integer bufferSize; Real dummy; public Modelica.Blocks.Interfaces.BooleanInput trigger "Input to start the sending procedure" Modelica.Blocks.Interfaces.RealInput receiver "Input for receiving agent name" Modelica.Blocks.Interfaces.BooleanOutput send "Turns true when a message is send" equation port_send = receiver; when initial() then pkgIn.userPkgBitSize = if autoBufferSize then -1 else userBufferSize*8; pkgIn.autoPkgBitSize = 0; bufferSize = if autoBufferSize then Modelica_DeviceDrivers.Packaging.SerialPackager_.getBufferSize(pkgIn.pkg) else userBufferSize; end when; pkgIn.backwardTrigger = trigger; // pkgIn.backwardTrigger = noEvent(sample(0, sampleTime)); when noEvent(trigger) then dummy = AixLib.Controls.HVACAgentBasedControl.BaseClasses.Internal.sendToUDP( socket, IPAddress, port_send, pkgIn.pkg, bufferSize, pkgIn.dummy); end when; connect(trigger, send) end UDPSend_adapted;
<html><p> <span style=\
within AixLib.Controls.HVACAgentBasedControl; package CostFunctions extends Modelica.Icons.VariantsPackage; end CostFunctions;
Price per kWh of fuel. <b><span style= \"font-family: MS Shell Dlg 2; color: #008000;\">Overview</span></b>
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Economic; model Constant_Economic_Cost extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real p = 0.30 "Price per kWh of fuel"; parameter Real eta = 0.95 "thermal efficiency of the device"; equation cost = (p/eta) * capacity; end Constant_Economic_Cost;
Price per kWh of fuel. <b><span style= \"font-family: MS Shell Dlg 2; color: #008000;\">Overview</span></b>
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Economic; model PV_Variable_Economic_Cost extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real p = 0.30 "Price per kWh of fuel"; parameter Real eta = 0.95 "thermal efficiency of the device"; parameter Real rad_treshold = 310 "Treshold when electricity is free"; Modelica.Blocks.Interfaces.RealInput rad "Input for solar radiation" Modelica.Blocks.Logical.GreaterEqualThreshold lessEqualThreshold(threshold= rad_treshold) Modelica.Clocked.RealSignals.Sampler.SampleClocked sample1 Modelica.Clocked.ClockSignals.Clocks.PeriodicRealClock periodicClock1(period= 300) Modelica.Clocked.RealSignals.Sampler.Hold hold1(y_start=100) Modelica.Blocks.Math.Product product Modelica.Blocks.Logical.Switch switch1 Modelica.Blocks.Sources.RealExpression realExpression(y=(p/eta)) Modelica.Blocks.Sources.RealExpression realExpression1(y=0.0001) Modelica.Blocks.Interfaces.BooleanOutput electricity_free "Indicator if electricity is considered free" equation connect(sample1.u, rad) connect(periodicClock1.y, sample1.clock) connect(sample1.y, hold1.u) connect(hold1.y, lessEqualThreshold.u) connect(capacity, product.u2) connect(switch1.u2, lessEqualThreshold.y) connect(switch1.y, product.u1) connect(product.y, cost) connect(lessEqualThreshold.y, electricity_free) connect(switch1.u1, realExpression1.y) connect(switch1.u3, realExpression.y) end PV_Variable_Economic_Cost;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Exergy; model Boiler_ExergyDestruction extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real eta = 0.84 "Overall efficiency of the boiler"; Real m_flow "mass flow"; Modelica.Blocks.Interfaces.RealInput T_in Modelica.Blocks.Interfaces.RealInput T_out equation m_flow = capacity/(4182*(T_out-T_in)); cost= -capacity - (m_flow*T_0*4182*log(T_in/T_out)) + 0.9257 * capacity/eta; end Boiler_ExergyDestruction;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Exergy; model Boiler_ExergyDestruction_Simplified extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real eta = 0.84 "Overall efficiency of the boiler"; Modelica.Blocks.Math.Division division Modelica.Blocks.Sources.RealExpression realExpression(y=eta) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression1(y=T_0) Modelica.Blocks.Math.Add add(k2=-1) Modelica.Blocks.Sources.RealExpression realExpression3(y=1) Modelica.Blocks.Math.Product product Modelica.Blocks.Math.Add add1(k2=-1) Modelica.Blocks.Math.Gain gain(k=0.9257) Modelica.Blocks.Interfaces.RealInput T_circuit Modelica.Blocks.Math.Max min Modelica.Blocks.Sources.RealExpression realExpression2(y=274.15) equation connect(division.u2, realExpression.y) connect(division1.u1, realExpression1.y) connect(division1.y, add.u2) connect(add.u1, realExpression3.y) connect(add.y, product.u1) connect(capacity, product.u2) connect(division.u1, product.u2) connect(product.y, add1.u2) connect(add1.y, cost) connect(division.y, gain.u) connect(gain.y, add1.u1) connect(min.y, division1.u2) connect(min.u1, realExpression2.y) connect(min.u2, T_circuit) end Boiler_ExergyDestruction_Simplified;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Exergy; model HeatingRod_ExergyDestruction extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real eta = 0.97 "Overall efficiency of the boiler"; Real T_in "Inlet temperature"; Modelica.Blocks.Interfaces.RealInput T_below "Temperature of the storage water layer below the heating rod" Modelica.Blocks.Interfaces.RealInput m_flow(start=0.5, fixed=true) equation T_in = T_below; cost= -(m_flow*T_0*4182*log(T_in/(T_in+capacity/(4182*m_flow)))); end HeatingRod_ExergyDestruction;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Exergy; model HeatingRod_ExergyDestruction_Simplified extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real eta = 1 "Overall efficiency of the boiler"; Modelica.Blocks.Math.Division division Modelica.Blocks.Sources.RealExpression realExpression(y=eta) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression1(y=T_0) Modelica.Blocks.Math.Add add(k2=-1) Modelica.Blocks.Sources.RealExpression realExpression3(y=1) Modelica.Blocks.Math.Product product Modelica.Blocks.Math.Add add1(k2=-1) Modelica.Blocks.Math.Gain gain(k=1) Modelica.Blocks.Interfaces.RealInput T_circuit Modelica.Blocks.Math.Max min Modelica.Blocks.Sources.RealExpression realExpression2(y=274.15) equation connect(division.u2, realExpression.y) connect(division1.u1, realExpression1.y) connect(division1.y, add.u2) connect(add.u1, realExpression3.y) connect(add.y, product.u1) connect(capacity, product.u2) connect(division.u1, product.u2) connect(product.y, add1.u2) connect(add1.y, cost) connect(division.y, gain.u) connect(gain.y, add1.u1) connect(min.y, division1.u2) connect(min.u1, realExpression2.y) connect(min.u2, T_circuit) end HeatingRod_ExergyDestruction_Simplified;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Exergy; model HeatPump_ExergyDestruction_Cooling extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real tablePower[:, :] = fill(0.0, 0, 2) "table matrix (grid u1 = first column, grid u2 = first row; e.g., table=[0,0;0,1])"; parameter Real tableHeatFlowCondenser[:, :] = fill(0.0, 0, 2) "table matrix (grid u1 = first column, grid u2 = first row; e.g., table=[0,0;0,1])"; Real COP "Cooefficient of performance"; Modelica.Blocks.Sources.RealExpression realExpression(y=1 - (1/COP)) Modelica.Blocks.Math.Add add1(k2=+1) Modelica.Blocks.Math.Add add2(k2=-1) Modelica.Blocks.Math.Add add4(k2=-1) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression1(y=T_0) Modelica.Blocks.Interfaces.RealInput T_cold Modelica.Blocks.Sources.RealExpression realExpression2(y=1) Modelica.Blocks.Math.Product product Modelica.Blocks.Interfaces.RealInput T_hot Modelica.Blocks.Math.Division division2 Modelica.Blocks.Sources.RealExpression realExpression3(y=T_0) Modelica.Blocks.Sources.RealExpression realExpression4(y=1) Modelica.Blocks.Math.Add add5(k2=-1) Modelica.Blocks.Math.Product product1 Modelica.Blocks.Math.Division division3 Modelica.Blocks.Sources.RealExpression realExpression5(y=COP) Modelica.Blocks.Math.Division division4 Modelica.Blocks.Math.Add add3(k2=-1) Modelica.Blocks.Tables.CombiTable2Ds PowerTable(table=tablePower) Modelica.Blocks.Tables.CombiTable2Ds HeatFlowCondenserTable(table= tableHeatFlowCondenser) equation COP = HeatFlowCondenserTable.y/PowerTable.y; connect(add1.y, add2.u1) connect(division1.u1, realExpression1.y) connect(division1.u2, T_cold) connect(add4.u1, realExpression2.y) connect(division1.y, add4.u2) connect(add4.y, product.u2) connect(realExpression3.y, division2.u1) connect(division2.u2, T_hot) connect(add5.u2, division2.y) connect(add5.y, product1.u2) connect(realExpression4.y, add5.u1) connect(cost, add2.y) connect(product1.y, add1.u1) connect(division3.u2, realExpression.y) connect(product1.u1, division3.y) connect(capacity, division3.u1) connect(realExpression5.y, division4.u2) connect(division4.u1, division3.y) connect(add2.u2, product.y) connect(add1.u2, division4.y) connect(add3.u2, division4.y) connect(add3.u1, division3.u1) connect(add3.y, product.u1) connect(T_hot, HeatFlowCondenserTable.u1) connect(T_hot, PowerTable.u1) connect(T_cold, PowerTable.u2) connect(HeatFlowCondenserTable.u2, T_cold) end HeatPump_ExergyDestruction_Cooling;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Exergy; model HeatPump_ExergyDestruction_Heating extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real tablePower[:, :] = fill(0.0, 0, 2) "table matrix (grid u1 = first column, grid u2 = first row; e.g., table=[0,0;0,1])"; parameter Real tableHeatFlowCondenser[:, :] = fill(0.0, 0, 2) "table matrix (grid u1 = first column, grid u2 = first row; e.g., table=[0,0;0,1])"; Real COP "Cooefficient of performance"; Modelica.Blocks.Sources.RealExpression realExpression(y=COP) Modelica.Blocks.Math.Add add1(k2=+1) Modelica.Blocks.Math.Add add2(k2=-1) Modelica.Blocks.Math.Division division Modelica.Blocks.Math.Add add3(k1=-1, k2=+1) Modelica.Blocks.Math.Add add4(k2=-1) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression1(y=T_0) Modelica.Blocks.Interfaces.RealInput T_cold Modelica.Blocks.Sources.RealExpression realExpression2(y=1) Modelica.Blocks.Math.Product product Modelica.Blocks.Interfaces.RealInput T_hot Modelica.Blocks.Math.Division division2 Modelica.Blocks.Sources.RealExpression realExpression3(y=T_0) Modelica.Blocks.Sources.RealExpression realExpression4(y=1) Modelica.Blocks.Math.Add add5(k2=-1) Modelica.Blocks.Math.Product product1 Modelica.Blocks.Tables.CombiTable2Ds HeatFlowCondenserTable(table= tableHeatFlowCondenser) Modelica.Blocks.Tables.CombiTable2Ds PowerTable(table=tablePower) equation COP = HeatFlowCondenserTable.y/PowerTable.y; connect(add1.y, add2.u1) connect(division.u2, realExpression.y) connect(division.u1, capacity) connect(add3.u2, capacity) connect(division.y, add3.u1) connect(division1.u1, realExpression1.y) connect(division1.u2, T_cold) connect(add4.u1, realExpression2.y) connect(division1.y, add4.u2) connect(add3.y, product.u1) connect(add4.y, product.u2) connect(add1.u1, division.y) connect(add1.u2, product.y) connect(realExpression3.y, division2.u1) connect(division2.u2, T_hot) connect(add5.u2, division2.y) connect(add5.y, product1.u2) connect(product1.u1, capacity) connect(product1.y, add2.u2) connect(realExpression4.y, add5.u1) connect(add2.y, cost) connect(T_hot,HeatFlowCondenserTable. u1) connect(T_cold,PowerTable. u2) connect(T_hot,PowerTable. u1) connect(HeatFlowCondenserTable.u2, T_cold) end HeatPump_ExergyDestruction_Heating;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Exergy; model MixingValveAndHEX_ExergyDestruction extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real T_circuit_hot = 273.15+80 "Temperature of the hot water circuit"; parameter Real m_flow_hot = 0.2 "Mass flow in the hot temperature circuit"; Real T1(start=271.15+40) "Inlet cold temperature"; Real T2(start=273.15+40, fixed=true) "Outlet cold temperature"; Real T3(start=273.15+40) "Inlet hot temperature"; Real T4(start=273.15+40) "Outlet hot temperature"; Real m_flow_hot_actual(start=0.2); Modelica.Blocks.Interfaces.RealInput T_cold_in Modelica.Blocks.Interfaces.RealInput m_flow_cold equation m_flow_hot_actual = (capacity/4000)*m_flow_hot; T1 = T_cold_in; T2 = T1 + capacity/(m_flow_cold*4182); T3 = T_circuit_hot; T4 = T3 - capacity/(m_flow_hot*4182); cost = - (m_flow_cold * T_0 * 4182 * log( T1/T2)) - (m_flow_hot_actual * T_0 * 4182 * log(T3/T4)); end MixingValveAndHEX_ExergyDestruction;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.Exergy; model MixingValveAndHEX_ExergyDestruction_Simplified extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; Real T_hot(start=273.15+90) "Hot temperature"; Real T_cold(start=273.15+50) "Cold temperature"; Modelica.Blocks.Interfaces.RealInput T_cold_in Modelica.Blocks.Interfaces.RealInput T_hot_in Modelica.Blocks.Interfaces.RealInput T_cold_out Modelica.Blocks.Interfaces.RealInput T_hot_out equation T_hot= (T_hot_in+T_hot_out)/2; T_cold= (T_cold_in+T_cold_out)/2; cost = capacity*(1-T_0/T_hot)-capacity*(1-T_0/T_cold); end MixingValveAndHEX_ExergyDestruction_Simplified;
<html><p> <span style=\
within AixLib.Controls.HVACAgentBasedControl.CostFunctions; package Exergy extends Modelica.Icons.VariantsPackage; end Exergy;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.PrimaryExergy; model Boiler_PrimaryExergyDestruction_Simplified extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real eta = 0.84 "Overall efficiency of the boiler"; parameter Real PEF = 1.1 "Primary energy factor of the fuel"; Modelica.Blocks.Math.Division division Modelica.Blocks.Sources.RealExpression realExpression(y=eta) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression1(y=T_0) Modelica.Blocks.Math.Add add(k2=-1) Modelica.Blocks.Sources.RealExpression realExpression3(y=1) Modelica.Blocks.Math.Product product Modelica.Blocks.Math.Add add1(k2=-1) Modelica.Blocks.Math.Gain gain(k=PEF*0.9257) Modelica.Blocks.Interfaces.RealInput T_circuit Modelica.Blocks.Math.Max min Modelica.Blocks.Sources.RealExpression realExpression2(y=274.15) equation connect(division.u2, realExpression.y) connect(division1.u1, realExpression1.y) connect(division1.y, add.u2) connect(add.u1, realExpression3.y) connect(add.y, product.u1) connect(capacity, product.u2) connect(division.u1, product.u2) connect(product.y, add1.u2) connect(add1.y, cost) connect(division.y, gain.u) connect(gain.y, add1.u1) connect(min.y, division1.u2) connect(min.u1, realExpression2.y) connect(min.u2, T_circuit) end Boiler_PrimaryExergyDestruction_Simplified;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.PrimaryExergy; model HeatingRod_PrimaryExergyDestruction_Simplified extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real eta = 1 "Overall efficiency of the boiler"; parameter Real PEF = 1.8 "Primary energy factor of the fuel"; Modelica.Blocks.Math.Division division Modelica.Blocks.Sources.RealExpression realExpression(y=eta) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression1(y=T_0) Modelica.Blocks.Math.Add add(k2=-1) Modelica.Blocks.Sources.RealExpression realExpression3(y=1) Modelica.Blocks.Math.Product product Modelica.Blocks.Math.Add add1(k2=-1) Modelica.Blocks.Math.Gain gain(k=PEF) Modelica.Blocks.Interfaces.RealInput T_circuit Modelica.Blocks.Math.Max min Modelica.Blocks.Sources.RealExpression realExpression2(y=274.15) equation connect(division.u2, realExpression.y) connect(division1.u1, realExpression1.y) connect(division1.y, add.u2) connect(add.u1, realExpression3.y) connect(add.y, product.u1) connect(capacity, product.u2) connect(division.u1, product.u2) connect(product.y, add1.u2) connect(add1.y, cost) connect(division.y, gain.u) connect(gain.y, add1.u1) connect(min.y, division1.u2) connect(min.u1, realExpression2.y) connect(min.u2, T_circuit) end HeatingRod_PrimaryExergyDestruction_Simplified;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.PrimaryExergy; model HeatPump_PrimaryExergyDestruction_Cooling extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real tablePower[:, :] = fill(0.0, 0, 2) "table matrix (grid u1 = first column, grid u2 = first row; e.g., table=[0,0;0,1])"; parameter Real tableHeatFlowCondenser[:, :] = fill(0.0, 0, 2) "table matrix (grid u1 = first column, grid u2 = first row; e.g., table=[0,0;0,1])"; parameter Real PEF = 1.8 "Primary energy factor of the fuel"; Real COP "Cooefficient of performance"; Modelica.Blocks.Sources.RealExpression realExpression(y=1 - (1/COP)) Modelica.Blocks.Math.Add add1(k2=+1) Modelica.Blocks.Math.Add add2(k2=-1) Modelica.Blocks.Math.Add add4(k2=-1) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression1(y=T_0) Modelica.Blocks.Interfaces.RealInput T_cold Modelica.Blocks.Sources.RealExpression realExpression2(y=1) Modelica.Blocks.Math.Product product Modelica.Blocks.Interfaces.RealInput T_hot Modelica.Blocks.Math.Division division2 Modelica.Blocks.Sources.RealExpression realExpression3(y=T_0) Modelica.Blocks.Sources.RealExpression realExpression4(y=1) Modelica.Blocks.Math.Add add5(k2=-1) Modelica.Blocks.Math.Product product1 Modelica.Blocks.Math.Division division3 Modelica.Blocks.Sources.RealExpression realExpression5(y=COP) Modelica.Blocks.Math.Division division4 Modelica.Blocks.Math.Add add3(k2=-1) Modelica.Blocks.Tables.CombiTable2Ds PowerTable(table=tablePower) Modelica.Blocks.Tables.CombiTable2Ds HeatFlowCondenserTable(table= tableHeatFlowCondenser) Modelica.Blocks.Math.Gain gain(k=PEF) equation COP = HeatFlowCondenserTable.y/PowerTable.y; connect(add1.y, add2.u1) connect(division1.u1, realExpression1.y) connect(division1.u2, T_cold) connect(add4.u1, realExpression2.y) connect(division1.y, add4.u2) connect(add4.y, product.u2) connect(realExpression3.y, division2.u1) connect(division2.u2, T_hot) connect(add5.u2, division2.y) connect(add5.y, product1.u2) connect(realExpression4.y, add5.u1) connect(cost, add2.y) connect(product1.y, add1.u1) connect(division3.u2, realExpression.y) connect(product1.u1, division3.y) connect(capacity, division3.u1) connect(realExpression5.y, division4.u2) connect(division4.u1, division3.y) connect(add2.u2, product.y) connect(add3.u2, division4.y) connect(add3.u1, division3.u1) connect(add3.y, product.u1) connect(T_hot, HeatFlowCondenserTable.u1) connect(T_hot, PowerTable.u1) connect(T_cold, PowerTable.u2) connect(HeatFlowCondenserTable.u2, T_cold) connect(gain.y, add1.u2) connect(gain.u, division4.y) end HeatPump_PrimaryExergyDestruction_Cooling;
Exergy reference temperature.
within AixLib.Controls.HVACAgentBasedControl.CostFunctions.PrimaryExergy; model HeatPump_PrimaryExergyDestruction_Heating extends HVACAgentBasedControl.BaseClasses.PartialCostFunction; parameter Real T_0 = 298.15 "Exergy reference temperature"; parameter Real tablePower[:, :] = fill(0.0, 0, 2) "table matrix (grid u1 = first column, grid u2 = first row; e.g., table=[0,0;0,1])"; parameter Real tableHeatFlowCondenser[:, :] = fill(0.0, 0, 2) "table matrix (grid u1 = first column, grid u2 = first row; e.g., table=[0,0;0,1])"; parameter Real PEF = 1.8 "Primary energy factor of the fuel"; Real COP "Cooefficient of performance"; Modelica.Blocks.Sources.RealExpression realExpression(y=COP) Modelica.Blocks.Math.Add add1(k2=+1) Modelica.Blocks.Math.Add add2(k2=-1) Modelica.Blocks.Math.Division division Modelica.Blocks.Math.Add add3(k1=-1, k2=+1) Modelica.Blocks.Math.Add add4(k2=-1) Modelica.Blocks.Math.Division division1 Modelica.Blocks.Sources.RealExpression realExpression1(y=T_0) Modelica.Blocks.Interfaces.RealInput T_cold Modelica.Blocks.Sources.RealExpression realExpression2(y=1) Modelica.Blocks.Math.Product product Modelica.Blocks.Interfaces.RealInput T_hot Modelica.Blocks.Math.Division division2 Modelica.Blocks.Sources.RealExpression realExpression3(y=T_0) Modelica.Blocks.Sources.RealExpression realExpression4(y=1) Modelica.Blocks.Math.Add add5(k2=-1) Modelica.Blocks.Math.Product product1 Modelica.Blocks.Tables.CombiTable2Ds HeatFlowCondenserTable(table= tableHeatFlowCondenser) Modelica.Blocks.Tables.CombiTable2Ds PowerTable(table=tablePower) Modelica.Blocks.Math.Gain gain(k=PEF) equation COP = HeatFlowCondenserTable.y/PowerTable.y; connect(add1.y, add2.u1) connect(division.u2, realExpression.y) connect(division.u1, capacity) connect(add3.u2, capacity) connect(division.y, add3.u1) connect(division1.u1, realExpression1.y) connect(division1.u2, T_cold) connect(add4.u1, realExpression2.y) connect(division1.y, add4.u2) connect(add3.y, product.u1) connect(add4.y, product.u2) connect(add1.u2, product.y) connect(realExpression3.y, division2.u1) connect(division2.u2, T_hot) connect(add5.u2, division2.y) connect(add5.y, product1.u2) connect(product1.u1, capacity) connect(product1.y, add2.u2) connect(realExpression4.y, add5.u1) connect(add2.y, cost) connect(T_hot,HeatFlowCondenserTable. u1) connect(T_cold,PowerTable. u2) connect(T_hot,PowerTable. u1) connect(HeatFlowCondenserTable.u2, T_cold) connect(gain.u, division.y) connect(gain.y, add1.u1) end HeatPump_PrimaryExergyDestruction_Heating;
<html><p> <span style=\
within AixLib.Controls.HVACAgentBasedControl.CostFunctions; package PrimaryExergy extends Modelica.Icons.VariantsPackage; end PrimaryExergy;
This package contains Examples that show how the agent-based control library can be implemented.
within AixLib.Controls.HVACAgentBasedControl; package Examples "This package contains Examples that show how the agent-based control library can be implemented." extends Modelica.Icons.ExamplesPackage; end Examples;
List of known BookSellerAgents (their adresses).
within AixLib.Controls.HVACAgentBasedControl.Examples.BookTrading; model BookBuyerAgent extends BaseClasses.PartialAgent; parameter Real[:,1] knownSellers = [30001; 30002; 30003] "List of known BookSellerAgents (their adresses)"; Real[3,2] proposals(start=[9999,9999;9999,9999;9999,9999]); parameter Real ISBN = 3551551677.0 "ISBN number of the book that the agent tries to buy"; Integer counter( start=1); Integer counterProposals( start=1); Boolean requestsDone(start=false); Real lowestPrice(start=9999999); Boolean bookOffered(start=false); parameter Integer sampleTime = 20 "Period of time between two tries of the agent to buy the book"; Modelica.StateGraph.InitialStep waiting(nIn=4, nOut=1) Modelica.StateGraph.Step composeRequest(nIn=3, nOut=1) Modelica.StateGraph.Step collectProposal(nOut=2, nIn=1) Modelica.StateGraph.Step composeBuy(nIn=1, nOut=1) Modelica.Blocks.Math.IntegerChange integerChange Modelica.Blocks.Sources.SampleTrigger sampleTrigger(period=sampleTime, startTime=sampleTime) Modelica.StateGraph.TransitionWithSignal transitionWithSignal Modelica.StateGraph.Transition transition(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Step check(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal newMessage Modelica.StateGraph.TransitionWithSignal offer(enableTimer=true, waitTime=0.1) Modelica.StateGraph.TransitionWithSignal refuse(enableTimer=true, waitTime=0.1) Modelica.StateGraph.TransitionWithSignal done(enableTimer=true, waitTime=0.1) Modelica.StateGraph.TransitionWithSignal notDone(enableTimer=true, waitTime=0.1) Modelica.StateGraph.StepWithSignal sendRequest(nOut=2, nIn=1) Modelica.StateGraph.StepWithSignal sendBuy(nOut=2, nIn=1) Modelica.StateGraph.Step check1(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal confirmation(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Step setDone(nOut=1, nIn=1) Modelica.StateGraph.Transition transition1(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Transition transition3(enableTimer=true, waitTime=0.1) Modelica.Blocks.Interfaces.BooleanOutput bookBought "Indicator that turns true if a book was succesfully bought" Modelica.StateGraph.TransitionWithSignal newMessage1 Modelica.Blocks.Logical.Or or1 Modelica.Blocks.Sources.BooleanExpression booleanExpression(y=( getperformative.y[1] == 13) or (requestsDone)) Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y= getperformative.y[1] == 17) Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y=requestsDone) Modelica.Blocks.Sources.BooleanExpression booleanExpression3(y=not ( requestsDone)) Modelica.Blocks.Sources.BooleanExpression booleanExpression4(y= getperformative.y[1] == 5) Modelica.StateGraph.Transition abort(enableTimer=true, waitTime=30) inner Modelica.StateGraph.StateGraphRoot stateGraphRoot Modelica.StateGraph.Step stateOfOffers(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal transitionWithSignal1 Modelica.Blocks.Sources.BooleanExpression booleanExpression5(y=bookOffered) Modelica.StateGraph.Transition noOffers(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Transition abortAction( enableTimer=true, waitTime=15) Modelica.StateGraph.Transition abortAction1( enableTimer=true, waitTime=15) Modelica.StateGraph.Step notServed(nIn=2, nOut=1) Modelica.StateGraph.Transition transition2( waitTime=0.1, enableTimer=false) Modelica.Blocks.Logical.And and1 Modelica.Blocks.Sources.BooleanExpression booleanExpression6(y=not ( bookBought)) algorithm when waiting.active then counter :=1; counterProposals :=1; lowestPrice := 9999999; bookOffered :=false; end when; when composeRequest.active then content.u[1] := ISBN; //temporary function content.u[2] := 0; performative.u[1]:= 4; sender.u[1]:=name; reply_to.u[1] := name; ontology.u[1] := 1; uDPSend_adapted.receiver := knownSellers[counter,1]; receiver.u[1]:= integer(knownSellers[counter,1]); messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("BookBuyerAgent "+ String(name)+ " calls for proposals for book " + String(ISBN) + " from BookSellerAgent "+ String(knownSellers[counter,1])+"."); end when; when sendRequest.active then counter := counter +1; if counter > size(knownSellers,1) then requestsDone := true; end if; end when; when collectProposal.active then if Modelica.Math.isEqual(getperformative.y[1],13) then bookOffered :=true; Modelica.Utilities.Streams.print("BookBuyerAgent "+ String(name)+ " collects proposal for book " + String(ISBN)+"."); end if; proposals[counterProposals,1] := get_content.y[1]; proposals[counterProposals,2] := getsender.y[1]; counterProposals := counterProposals +1; end when; when composeBuy.active then counter := 1; lowestPrice := min(proposals[:,1]); // loop to find the cheapest producer for counter in 1:size(proposals,1) loop if Modelica.Math.isEqual(proposals[counter,1],lowestPrice) then break; end if; end for; //send out accept proposal to the cheapest producer performative.u[1]:=19; sender.u[1]:=name; receiver.u[1]:= integer(proposals[counter,2]); reply_to.u[1] := name; content.u[1] := ISBN; ontology.u[1] := 1; uDPSend_adapted.receiver := proposals[counter,2]; messageID.u[1] := name*name + integer(time); Modelica.Utilities.Streams.print("BookBuyerAgent "+ String(name)+ " buys book " + String(ISBN) + " from BookSellerAgent "+ String(proposals[counter,2])+"."); end when; when setDone.active then bookBought := true; Modelica.Utilities.Streams.print("BookBuyerAgent "+ String(name)+ " has succesfully bought the book " + String(ISBN) + " for "+ String(proposals[counter,1])+" €."); end when; when stateOfOffers.active then if not (bookOffered) then Modelica.Utilities.Streams.print("BookBuyerAgent "+ String(name)+ " was not offered the book " + String(ISBN) + ". It goes back to idle."); end if; end when; when notServed.active then Modelica.Utilities.Streams.print("BookBuyerAgent "+ String(name)+ " was not served and goes back to idle."); end when; equation connect(waiting.outPort[1], transitionWithSignal.inPort) connect(transitionWithSignal.outPort, composeRequest.inPort[1]) connect(transition.inPort, composeRequest.outPort[1]) connect(newMessage.outPort, check.inPort[1]) connect(check.outPort[1], offer.inPort) connect(offer.outPort, collectProposal.inPort[1]) connect(refuse.inPort, check.outPort[2]) connect(refuse.outPort, composeRequest.inPort[2]) connect(collectProposal.outPort[1], notDone.inPort) connect(done.inPort, collectProposal.outPort[2]) connect(notDone.outPort, composeRequest.inPort[3]) connect(sendRequest.outPort[1], newMessage.inPort) connect(sendRequest.inPort[1], transition.outPort) connect(composeBuy.outPort[1], transition1.inPort) connect(transition1.outPort, sendBuy.inPort[1]) connect(confirmation.inPort, check1.outPort[1]) connect(setDone.inPort[1], confirmation.outPort) connect(transition3.inPort, setDone.outPort[1]) connect(transition3.outPort, waiting.inPort[1]) connect(newMessage1.inPort, sendBuy.outPort[1]) connect(newMessage1.outPort, check1.inPort[1]) connect(or1.y, uDPSend_adapted.trigger) connect(or1.u1, sendRequest.active) connect(or1.u2, sendBuy.active) connect(booleanExpression.y, offer.condition) connect(booleanExpression1.y, refuse.condition) connect(booleanExpression2.y, done.condition) connect(booleanExpression3.y, notDone.condition) connect(integerChange.y, newMessage.condition) connect(newMessage1.condition, newMessage.condition) connect(abort.inPort, check1.outPort[2]) connect(abort.outPort, waiting.inPort[2]) connect(booleanExpression4.y, confirmation.condition) connect(transitionWithSignal1.outPort, composeBuy.inPort[1]) connect(transitionWithSignal1.inPort, stateOfOffers.outPort[1]) connect(stateOfOffers.inPort[1], done.outPort) connect(transitionWithSignal1.condition, booleanExpression5.y) connect(noOffers.inPort, stateOfOffers.outPort[2]) connect(noOffers.outPort, waiting.inPort[3]) connect(abortAction.inPort, sendRequest.outPort[2]) connect(abortAction1.inPort, sendBuy.outPort[2]) connect(abortAction.outPort, notServed.inPort[1]) connect(abortAction1.outPort, notServed.inPort[2]) connect(notServed.outPort[1], transition2.inPort) connect(transition2.outPort, waiting.inPort[4]) connect(and1.y, transitionWithSignal.condition) connect(sampleTrigger.y, and1.u2) connect(booleanExpression6.y, and1.u1) connect(getMessageID.y[1], integerChange.u) end BookBuyerAgent;
BookSellerAgent .
within AixLib.Controls.HVACAgentBasedControl.Examples.BookTrading; model BookSellerAgent extends BaseClasses.PartialAgent; Real[:,2] bookList( start= [3551551677.0,30; 3551551679.0,20; 3551551616.0, 20]); Real searchedBook(start=0); Integer counter(start=1); Boolean bookInStock(start=false); Boolean bookToSell(start=false); Real index(start=1); //current message Integer sender_current(start=0); Integer performative_current(start=0); Real content_1_current(start=0); Real content_2_current(start=0); Modelica.Blocks.Math.IntegerChange integerChange Modelica.StateGraph.InitialStep waiting(nIn=2, nOut=1) inner Modelica.StateGraph.StateGraphRoot stateGraphRoot Modelica.StateGraph.TransitionWithSignal newMessage Modelica.StateGraph.Step checkPurpose(nOut=2, nIn=1) Modelica.StateGraph.TransitionWithSignal OfferRequestsServer(enableTimer=true, waitTime=0.1) Modelica.StateGraph.TransitionWithSignal PurchaseOrdersServer(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Step checkLibrary(nIn=1, nOut=1) Modelica.StateGraph.Step composeResponse(nIn=1, nOut=1) Modelica.StateGraph.StepWithSignal sendResponse(nIn=1, nOut=1) Modelica.StateGraph.Step checkLibrary1(nIn=1, nOut=1) Modelica.StateGraph.Step composeResponse1(nIn=1, nOut=1) Modelica.StateGraph.StepWithSignal sendResponse1(nIn=1, nOut=1) Modelica.StateGraph.Transition transition(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Transition transition1(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Transition transition2(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Transition transition3(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Transition transition4(enableTimer=true, waitTime=0.1) Modelica.StateGraph.Transition transition5(enableTimer=true, waitTime=0.1) Modelica.Blocks.Logical.Or or1 Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y= performative_current == 4) Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y= performative_current == 19) algorithm when waiting.active then searchedBook := 0; counter := 1; bookInStock :=false; bookToSell :=false; index :=1; end when; when checkPurpose.active then sender_current := getsender.y[1]; performative_current := getperformative.y[1]; content_1_current := get_content.y[1]; content_2_current := get_content.y[2]; end when; when checkLibrary.active then searchedBook := content_1_current; for index in 1:size(bookList,1) loop if Modelica.Math.isEqual(bookList[index,1],searchedBook) then bookInStock := true; counter := index; break; end if; end for; end when; when composeResponse.active then sender.u[1]:=name; reply_to.u[1] := name; ontology.u[1] := 1; uDPSend_adapted.receiver := sender_current; receiver.u[1]:= sender_current; messageID.u[1] := name*name + integer(time); if bookInStock then content.u[1] := bookList[counter,2]; content.u[2] := bookList[counter,1]; performative.u[1]:= 13; Modelica.Utilities.Streams.print("BookSellerAgent "+ String(name)+ " has found the book " + String(get_content.y[1]) + " and offers it for "+ String(bookList[counter,2])+" €."); else content.u[1] := 0; content.u[2] := 0; performative.u[1]:= 17; Modelica.Utilities.Streams.print("BookSellerAgent "+ String(name)+ " has not found the book " + String(get_content.y[1]) + " and refuses the proposal."); end if; end when; when checkLibrary1.active then searchedBook := content_1_current; for index in 1:size(bookList,1) loop if Modelica.Math.isEqual(bookList[index,1],searchedBook) then bookToSell := true; counter := index; break; end if; end for; end when; when composeResponse1.active then sender.u[1]:=name; reply_to.u[1] := name; ontology.u[1] := 1; uDPSend_adapted.receiver := sender_current; receiver.u[1]:= sender_current; messageID.u[1] := name*name + integer(time); if bookToSell then Modelica.Utilities.Streams.print("BookSellerAgent "+ String(name)+ " has found the book " + String(get_content.y[1]) + " and and sells it for "+ String(bookList[counter,2])+" € to " + String(getsender.y[1])+"."); content.u[1] := bookList[counter,2]; content.u[2] := bookList[counter,1]; performative.u[1]:= 5; bookList[counter,2] := 0; bookList[counter,1] := 0; else content.u[1] := 0; content.u[2] := 0; performative.u[1]:= 17; Modelica.Utilities.Streams.print("BookSellerAgent "+ String(name)+ " has not found the book " + String(get_content.y[1]) + " and and can therefore not sell it."); end if; end when; equation connect(getMessageID.y[1], integerChange.u) connect(waiting.outPort[1], newMessage.inPort) connect(newMessage.outPort,checkPurpose. inPort[1]) connect(checkPurpose.outPort[1], OfferRequestsServer.inPort) connect(checkPurpose.outPort[2], PurchaseOrdersServer.inPort) connect(OfferRequestsServer.outPort, checkLibrary.inPort[1]) connect(transition.inPort, checkLibrary.outPort[1]) connect(transition.outPort, composeResponse.inPort[1]) connect(composeResponse.outPort[1], transition1.inPort) connect(transition1.outPort, sendResponse.inPort[1]) connect(transition4.outPort, waiting.inPort[1]) connect(transition5.outPort, waiting.inPort[2]) connect(sendResponse.outPort[1], transition4.inPort) connect(sendResponse1.outPort[1], transition5.inPort) connect(PurchaseOrdersServer.outPort, checkLibrary1.inPort[1]) connect(checkLibrary1.outPort[1], transition2.inPort) connect(transition2.outPort, composeResponse1.inPort[1]) connect(composeResponse1.outPort[1], transition3.inPort) connect(transition3.outPort, sendResponse1.inPort[1]) connect(uDPSend_adapted.trigger, or1.y) connect(or1.u1, sendResponse.active) connect(sendResponse1.active, or1.u2) connect(booleanExpression1.y, OfferRequestsServer.condition) connect(booleanExpression2.y, PurchaseOrdersServer.condition) connect(integerChange.y, newMessage.condition) end BookSellerAgent;
<html><h4> <span style=\.
within AixLib.Controls.HVACAgentBasedControl.Examples.BookTrading; model BookTrading extends Modelica.Icons.Example; BookBuyerAgent bookBuyerAgent(name=10001, ISBN=0618640150, sampleRate=1) BookSellerAgent bookSellerAgent(name=30001, bookList(start=[3551555559.0,30; 3551555577.0,20; 3551555588.0,20]), sampleRate=1) BookSellerAgent bookSellerAgent1(name=30002, bookList(start=[3551555589.0, 30; 3551555559.0,40; 3551555556.0,20]), sampleRate=1) BookSellerAgent bookSellerAgent2(name=30003, bookList(start=[3551555555.0, 30; 3551555554.0,20; 3551555553.0,20; 3551555580.0,15]), sampleRate=1) BookBuyerAgent bookBuyerAgent1( name=10002, ISBN=3551555559.0, sampleRate=1, sampleTime=40) BookBuyerAgent bookBuyerAgent2( ISBN=3551555559.0, name=10003, sampleRate=1, sampleTime=55) inner Agents.MessageNotification messageNotification end BookTrading;
134.130.49.128.
within AixLib.Controls.HVACAgentBasedControl.Examples.BookTrading; model NetworkCommunication1 extends Modelica.Icons.Example; BookSellerAgent bookSellerAgent1( bookList(start=[3551555589.0, 30; 3551555559.0,40; 3551555556.0,20]), uDPSend_adapted(IPAddress="134.130.49.128"), name=10003, sampleRate=1) Modelica_DeviceDrivers.Blocks.OperatingSystem.SynchronizeRealtime synchronizeRealtime(priority="Below normal") inner Agents.MessageNotification messageNotification end NetworkCommunication1;
134.130.49.160.
within AixLib.Controls.HVACAgentBasedControl.Examples.BookTrading; model NetworkCommunication2 extends Modelica.Icons.Example; BookBuyerAgent bookBuyerAgent1( name=10002, ISBN=3551555559.0, sampleTime=10, uDPSend_adapted(IPAddress="134.130.49.160"), knownSellers=[10002], sampleRate=1) Modelica_DeviceDrivers.Blocks.OperatingSystem.SynchronizeRealtime synchronizeRealtime(priority="Below normal") inner Agents.MessageNotification messageNotification end NetworkCommunication2;
bar
within AixLib.Controls.HVACAgentBasedControl.Examples.BuildingHeatingSystems; model BuildingHeating extends Modelica.Icons.Example; parameter AixLib.DataBase.Weather.TRYWeatherBaseDataDefinition weatherDataDay = AixLib.DataBase.Weather.TRYWinterDay(); ThermalZones.ReducedOrder.ThermalZone.ThermalZone thermalZone( redeclare AixLib.DataBase.ThermalZones.OfficePassiveHouse.OPH_1_OfficeNoHeaterCooler zoneParam, redeclare package Medium = Modelica.Media.Air.SimpleAir) ThermalZones.ReducedOrder.ThermalZone.ThermalZone thermalZone1(redeclare package Medium = Modelica.Media.Air.SimpleAir, redeclare AixLib.DataBase.ThermalZones.OfficePassiveHouse.OPH_1_OfficeNoHeaterCooler zoneParam) AixLib.Fluid.Movers.FlowControlled_m_flow fan(redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater, m_flow_nominal=2) AixLib.Fluid.HeatExchangers.HeaterCooler_u hea( redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater, m_flow_nominal=2, dp_nominal(displayUnit="bar") = 5000, Q_flow_nominal=1) AixLib.Fluid.HeatExchangers.HeaterCooler_u hea1( redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater, m_flow_nominal=2, dp_nominal(displayUnit="bar") = 5000, Q_flow_nominal=1) Fluid.Sources.Boundary_pT bou(nPorts=1, redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater) Agents.RoomAgent roomAgent( startTime=60, threshold=0.5, broker=10003, sampleRate=1, sampleTriggerTime=120, G=10) Agents.RoomAgent roomAgent1( name=10002, startTime=70, threshold=0.5, broker=10003, sampleRate=1, sampleTriggerTime=120, G=10) Modelica.Blocks.Sources.Constant roomSetPoint(k=273.15 + 22) inner Agents.MessageNotification messageNotification(n=5) Agents.HeatProducerAgent heatProducerAgent( name=30001, maxCapacity=3000, sampleRate=1, setCapacity(start=1), currentCapacityDiscrete(start=1)) Agents.HeatProducerAgent heatProducerAgent1(name=30002, maxCapacity=10000, sampleRate=1, setCapacity(start=1), currentCapacityDiscrete(start=1)) CostFunctions.Economic.Constant_Economic_Cost constantFactor(eta=1) CostFunctions.Economic.Constant_Economic_Cost constantFactor1(p=0.60, eta=1) Modelica.Blocks.Sources.BooleanExpression booleanExpression(y=true) Modelica.Blocks.Sources.Constant massFlowRate(k=5) Agents.Broker broker(name=10003, sampleRate=1) Modelica.Fluid.Vessels.ClosedVolume volume( nPorts=2, redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater, use_portsData=false, use_HeatTransfer=true, V=30*1E-3) Modelica.Fluid.Vessels.ClosedVolume volume1( nPorts=2, redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater, use_portsData=false, use_HeatTransfer=true, V=30*1E-3) Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor(G=2000) Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor1(G= 2000) AixLib.Fluid.Actuators.Valves.TwoWayLinear val1( m_flow_nominal=1, dpValve_nominal(displayUnit="bar") = 10000, redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater) Modelica.Blocks.Continuous.LimPID PID1( yMax=1, initType=Modelica.Blocks.Types.Init.InitialOutput, k=0.1, Ti=1, Td=0.01, y_start=0.3, yMin=0.1) AixLib.Fluid.Actuators.Valves.TwoWayLinear val( m_flow_nominal=1, dpValve_nominal(displayUnit="bar") = 10000, redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater) Modelica.Blocks.Continuous.LimPID PID2( yMax=1, initType=Modelica.Blocks.Types.Init.InitialOutput, k=0.1, Ti=1, Td=0.01, y_start=0.3, yMin=0.1) Modelica.Blocks.Sources.Constant internalGains[3](k={0,0,0}) Modelica.Blocks.Interfaces.RealOutput T_room(unit="K") "Temperature in room" Modelica.Blocks.Interfaces.RealOutput T_room1(unit="K") "Temperature in room" Modelica.Blocks.Interfaces.RealOutput Cap_device(unit="W") "Capacity of heating device" Modelica.Blocks.Interfaces.RealOutput Cap_device1(unit="W") "Capacity of heating device" BoundaryConditions.WeatherData.ReaderTMY3 weaDat( calTSky=AixLib.BoundaryConditions.Types.SkyTemperatureCalculation.HorizontalRadiation, computeWetBulbTemperature=false, filNam=Modelica.Utilities.Files.loadResource("modelica://AixLib/Resources/weatherdata/USA_CA_San.Francisco.Intl.AP.724940_TMY3.mos")) "Weather data reader" inner Modelica.Fluid.System system Modelica.Blocks.Sources.CombiTimeTable InternalHeatGain( table=[0,0,0.1,0,0; 3540,0,0.1,0,0; 3600,0,0.1,0,0; 7140,0,0.1,0,0; 7200,0, 0.1,0,0; 10740,0,0.1,0,0; 10800,0,0.1,0,0; 14340,0,0.1,0,0; 14400,0,0.1, 0,0; 17940,0,0.1,0,0; 18000,0,0.1,0,0; 21540,0,0.1,0,0; 21600,0,0.1,0,0; 25140,0,0.1,0,0; 25200,0,0.1,0,0; 28740,0,0.1,0,0; 28800,0,0.1,0,0; 32340,0,0.1,0,0; 32400,0.6,0.6,1,1; 35940,0.6,0.6,1,1; 36000,1,1,1,1; 39540,1,1,1,1; 39600,0.4,0.4,1,1; 43140,0.4,0.4,1,1; 43200,0,0.1,0,0; 46740,0,0.1,0,0; 46800,0,0.1,0,0; 50340,0,0.1,0,0; 50400,0.6,0.6,1,1; 53940,0.6,0.6,1,1; 54000,1,1,1,1; 57540,1,1,1,1; 57600,0.4,0.4,1,1; 61140,0.4,0.4,1,1; 61200,0,0.1,0,0; 64740,0,0.1,0,0; 64800,0,0.1,0,0; 68340,0,0.1,0,0; 68400,0,0.1,0,0; 71940,0,0.1,0,0; 72000,0,0.1,0,0; 75540,0,0.1,0,0; 75600,0,0.1,0,0; 79140,0,0.1,0,0; 79200,0,0.1,0,0; 82740,0,0.1,0,0; 82800,0,0.1,0,0; 86340,0,0.1,0,0; 86400,0,0.1,0,0; 89940,0,0.1,0,0; 90000,0,0.1,0,0; 93540,0,0.1,0,0; 93600,0,0.1,0,0; 97140,0,0.1,0,0; 97200,0,0.1,0,0; 100740,0,0.1,0,0; 100800,0,0.1,0,0; 104340,0,0.1,0,0; 104400,0,0.1,0,0; 107940,0,0.1,0,0; 108000,0,0.1,0,0; 111540,0,0.1,0,0; 111600,0,0.1,0,0; 115140,0,0.1,0,0; 115200,0,0.1,0,0; 118740,0,0.1,0,0; 118800,0.6,0.6,1,1; 122340,0.6,0.6,1,1; 122400,1,1,1, 1; 125940,1,1,1,1; 126000,0.4,0.4,1,1; 129540,0.4,0.4,1,1; 129600,0,0.1, 0,0; 133140,0,0.1,0,0; 133200,0,0.1,0,0; 136740,0,0.1,0,0; 136800,0.6, 0.6,1,1; 140340,0.6,0.6,1,1; 140400,1,1,1,1; 143940,1,1,1,1; 144000,0.4, 0.4,1,1; 147540,0.4,0.4,1,1; 147600,0,0.1,0,0; 151140,0,0.1,0,0; 151200, 0,0.1,0,0; 154740,0,0.1,0,0; 154800,0,0.1,0,0; 158340,0,0.1,0,0; 158400, 0,0.1,0,0; 161940,0,0.1,0,0; 162000,0,0.1,0,0; 165540,0,0.1,0,0; 165600, 0,0.1,0,0; 169140,0,0.1,0,0; 169200,0,0.1,0,0; 172740,0,0.1,0,0; 172800, 0,0.1,0,0; 176340,0,0.1,0,0; 176400,0,0.1,0,0; 179940,0,0.1,0,0; 180000, 0,0.1,0,0; 183540,0,0.1,0,0; 183600,0,0.1,0,0; 187140,0,0.1,0,0; 187200, 0,0.1,0,0; 190740,0,0.1,0,0; 190800,0,0.1,0,0; 194340,0,0.1,0,0; 194400, 0,0.1,0,0; 197940,0,0.1,0,0; 198000,0,0.1,0,0; 201540,0,0.1,0,0; 201600, 0,0.1,0,0; 205140,0,0.1,0,0; 205200,0.6,0.6,1,1; 208740,0.6,0.6,1,1; 208800,1,1,1,1; 212340,1,1,1,1; 212400,0.4,0.4,1,1; 215940,0.4,0.4,1,1; 216000,0,0.1,0,0; 219540,0,0.1,0,0; 219600,0,0.1,0,0; 223140,0,0.1,0,0; 223200,0.6,0.6,1,1; 226740,0.6,0.6,1,1; 226800,1,1,1,1; 230340,1,1,1,1; 230400,0.4,0.4,1,1; 233940,0.4,0.4,1,1; 234000,0,0.1,0,0; 237540,0,0.1, 0,0; 237600,0,0.1,0,0; 241140,0,0.1,0,0; 241200,0,0.1,0,0; 244740,0,0.1, 0,0; 244800,0,0.1,0,0; 248340,0,0.1,0,0; 248400,0,0.1,0,0; 251940,0,0.1, 0,0; 252000,0,0.1,0,0; 255540,0,0.1,0,0; 255600,0,0.1,0,0; 259140,0,0.1, 0,0; 259200,0,0.1,0,0; 262740,0,0.1,0,0; 262800,0,0.1,0,0; 266340,0,0.1, 0,0; 266400,0,0.1,0,0; 269940,0,0.1,0,0; 270000,0,0.1,0,0; 273540,0,0.1, 0,0; 273600,0,0.1,0,0; 277140,0,0.1,0,0; 277200,0,0.1,0,0; 280740,0,0.1, 0,0; 280800,0,0.1,0,0; 284340,0,0.1,0,0; 284400,0,0.1,0,0; 287940,0,0.1, 0,0; 288000,0,0.1,0,0; 291540,0,0.1,0,0; 291600,0.6,0.6,1,1; 295140,0.6, 0.6,1,1; 295200,1,1,1,1; 298740,1,1,1,1; 298800,0.4,0.4,1,1; 302340,0.4, 0.4,1,1; 302400,0,0.1,0,0; 305940,0,0.1,0,0; 306000,0,0.1,0,0; 309540,0, 0.1,0,0; 309600,0.6,0.6,1,1; 313140,0.6,0.6,1,1; 313200,1,1,1,1; 316740, 1,1,1,1; 316800,0.4,0.4,1,1; 320340,0.4,0.4,1,1; 320400,0,0.1,0,0; 323940,0,0.1,0,0; 324000,0,0.1,0,0; 327540,0,0.1,0,0; 327600,0,0.1,0,0; 331140,0,0.1,0,0; 331200,0,0.1,0,0; 334740,0,0.1,0,0; 334800,0,0.1,0,0; 338340,0,0.1,0,0; 338400,0,0.1,0,0; 341940,0,0.1,0,0; 342000,0,0.1,0,0; 345540,0,0.1,0,0; 345600,0,0.1,0,0; 349140,0,0.1,0,0; 349200,0,0.1,0,0; 352740,0,0.1,0,0; 352800,0,0.1,0,0; 356340,0,0.1,0,0; 356400,0,0.1,0,0; 359940,0,0.1,0,0; 360000,0,0.1,0,0; 363540,0,0.1,0,0; 363600,0,0.1,0,0; 367140,0,0.1,0,0; 367200,0,0.1,0,0; 370740,0,0.1,0,0; 370800,0,0.1,0,0; 374340,0,0.1,0,0; 374400,0,0.1,0,0; 377940,0,0.1,0,0; 378000,0.6,0.6,1, 1; 381540,0.6,0.6,1,1; 381600,1,1,1,1; 385140,1,1,1,1; 385200,0.4,0.4,1, 1; 388740,0.4,0.4,1,1; 388800,0,0.1,0,0; 392340,0,0.1,0,0; 392400,0,0.1, 0,0; 395940,0,0.1,0,0; 396000,0.6,0.6,1,1; 399540,0.6,0.6,1,1; 399600,1, 1,1,1; 403140,1,1,1,1; 403200,0.4,0.4,1,1; 406740,0.4,0.4,1,1; 406800,0, 0.1,0,0; 410340,0,0.1,0,0; 410400,0,0.1,0,0; 413940,0,0.1,0,0; 414000,0, 0.1,0,0; 417540,0,0.1,0,0; 417600,0,0.1,0,0; 421140,0,0.1,0,0; 421200,0, 0.1,0,0; 424740,0,0.1,0,0; 424800,0,0.1,0,0; 428340,0,0.1,0,0; 428400,0, 0.1,0,0; 431940,0,0.1,0,0; 432000,0,0,0,0; 435540,0,0,0,0; 435600,0,0,0, 0; 439140,0,0,0,0; 439200,0,0,0,0; 442740,0,0,0,0; 442800,0,0,0,0; 446340,0,0,0,0; 446400,0,0,0,0; 449940,0,0,0,0; 450000,0,0,0,0; 453540, 0,0,0,0; 453600,0,0,0,0; 457140,0,0,0,0; 457200,0,0,0,0; 460740,0,0,0,0; 460800,0,0,0,0; 464340,0,0,0,0; 464400,0,0,0,0; 467940,0,0,0,0; 468000, 0,0,0,0; 471540,0,0,0,0; 471600,0,0,0,0; 475140,0,0,0,0; 475200,0,0,0,0; 478740,0,0,0,0; 478800,0,0,0,0; 482340,0,0,0,0; 482400,0,0,0,0; 485940, 0,0,0,0; 486000,0,0,0,0; 489540,0,0,0,0; 489600,0,0,0,0; 493140,0,0,0,0; 493200,0,0,0,0; 496740,0,0,0,0; 496800,0,0,0,0; 500340,0,0,0,0; 500400, 0,0,0,0; 503940,0,0,0,0; 504000,0,0,0,0; 507540,0,0,0,0; 507600,0,0,0,0; 511140,0,0,0,0; 511200,0,0,0,0; 514740,0,0,0,0; 514800,0,0,0,0; 518340, 0,0,0,0; 518400,0,0,0,0; 521940,0,0,0,0; 522000,0,0,0,0; 525540,0,0,0,0; 525600,0,0,0,0; 529140,0,0,0,0; 529200,0,0,0,0; 532740,0,0,0,0; 532800, 0,0,0,0; 536340,0,0,0,0; 536400,0,0,0,0; 539940,0,0,0,0; 540000,0,0,0,0; 543540,0,0,0,0; 543600,0,0,0,0; 547140,0,0,0,0; 547200,0,0,0,0; 550740, 0,0,0,0; 550800,0,0,0,0; 554340,0,0,0,0; 554400,0,0,0,0; 557940,0,0,0,0; 558000,0,0,0,0; 561540,0,0,0,0; 561600,0,0,0,0; 565140,0,0,0,0; 565200, 0,0,0,0; 568740,0,0,0,0; 568800,0,0,0,0; 572340,0,0,0,0; 572400,0,0,0,0; 575940,0,0,0,0; 576000,0,0,0,0; 579540,0,0,0,0; 579600,0,0,0,0; 583140, 0,0,0,0; 583200,0,0,0,0; 586740,0,0,0,0; 586800,0,0,0,0; 590340,0,0,0,0; 590400,0,0,0,0; 593940,0,0,0,0; 594000,0,0,0,0; 597540,0,0,0,0; 597600, 0,0,0,0; 601140,0,0,0,0; 601200,0,0,0,0; 604740,0,0,0,0], columns={2,3,4}, extrapolation=Modelica.Blocks.Types.Extrapolation.Periodic) Modelica.Blocks.Math.Gain gain[3](k={0.8,0.8,0.8}) Fluid.FixedResistances.HydraulicResistance hydraulicResistance( redeclare package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater, m_flow_nominal=0.02, zeta=10, diameter=0.05) equation connect(hea.port_b, hea1.port_a) connect(hea1.port_b, fan.port_a) connect(bou.ports[1], fan.port_a) connect(heatProducerAgent.calcCapacity, constantFactor.capacity) connect(heatProducerAgent.calcCost, constantFactor.cost) connect(heatProducerAgent1.calcCapacity, constantFactor1.capacity) connect(heatProducerAgent1.calcCost, constantFactor1.cost) connect(heatProducerAgent.setCapacityOut, hea.u) connect(heatProducerAgent1.setCapacityOut, hea1.u) connect(hea1.Q_flow, heatProducerAgent1.currentCapacity) connect(hea.Q_flow, heatProducerAgent.currentCapacity) connect(booleanExpression.y, heatProducerAgent.OnOff_external) connect(booleanExpression.y, heatProducerAgent1.OnOff_external) connect(massFlowRate.y, fan.m_flow_in) connect(volume.ports[1], hea.port_a) connect(volume1.ports[1], hea.port_a) connect(volume.heatPort, thermalConductor.port_a) connect(thermalConductor1.port_a, volume1.heatPort) connect(PID1.y, val1.y) connect(val1.port_b, volume1.ports[2]) connect(val1.port_a, fan.port_b) connect(val.port_b, volume.ports[2]) connect(val.port_a, fan.port_b) connect(PID2.y, val.y) connect(roomSetPoint.y, PID1.u_s) connect(PID2.u_s, PID1.u_s) connect(hea.Q_flow, Cap_device) connect(hea1.Q_flow, Cap_device1) connect(thermalConductor.port_b, thermalZone.intGainsConv) connect(thermalZone.intGainsRad, thermalZone.intGainsConv) connect(thermalConductor1.port_b, thermalZone1.intGainsConv) connect(thermalZone1.intGainsRad, thermalZone1.intGainsConv) connect(thermalZone1.intGains, internalGains.y) connect(weaDat.weaBus, thermalZone.weaBus) connect(weaDat.weaBus, thermalZone1.weaBus) connect(thermalZone.TAir, roomAgent.T) connect(thermalZone1.TAir, roomAgent1.T) connect(thermalZone1.TAir, T_room1) connect(thermalZone1.TAir, PID1.u_m) connect(PID2.u_m, thermalZone.TAir) connect(thermalZone.TAir, T_room) connect(InternalHeatGain.y, gain.u) connect(gain.y, thermalZone.intGains) connect(hydraulicResistance.port_a, fan.port_b) connect(hydraulicResistance.port_b, hea.port_a) end BuildingHeating;
<html><h4> <span style=\.
within AixLib.Controls.HVACAgentBasedControl.Examples.BuildingHeatingSystems; model BuildingHeating_usePoke extends BuildingHeating( roomAgent(usePoke=true), roomAgent1(usePoke=true), broker(usePoke=true), messageNotification(usePoke=true, n=5), heatProducerAgent(usePoke=true), heatProducerAgent1(usePoke=true)); equation connect(roomAgent.sendOut, messageNotification.receive[1]) connect(roomAgent1.sendOut, messageNotification.receive[2]) connect(heatProducerAgent1.sendOut, messageNotification.receive[3]) connect(heatProducerAgent.sendOut, messageNotification.receive[4]) connect(broker.sendOut, messageNotification.receive[5]) end BuildingHeating_usePoke;
bar
within AixLib.Controls.HVACAgentBasedControl.Examples.BuildingHeatingSystems; model BuildingWithPV extends Modelica.Icons.Example; package Medium = AixLib.Media.Water; AixLib.Fluid.HeatExchangers.HeaterCooler_u hea( redeclare package Medium = Medium, m_flow_nominal=1, Q_flow_nominal=1, dp_nominal(displayUnit="bar") = 1000) AixLib.Fluid.HeatExchangers.HeaterCooler_u hea1( redeclare package Medium = Medium, m_flow_nominal=1, dp_nominal(displayUnit="bar") = 1000, Q_flow_nominal=1) AixLib.Fluid.Movers.FlowControlled_m_flow fan( redeclare package Medium = Medium, m_flow_nominal=1, m_flow(start=1), addPowerToMedium=false) AixLib.Fluid.MixingVolumes.MixingVolume vol(nPorts=2, redeclare package Medium = Medium, m_flow_nominal=1, V=1) AixLib.Fluid.MixingVolumes.MixingVolume vol1(nPorts=2, redeclare package Medium = Medium, m_flow_nominal=1, V=1) AixLib.Fluid.Actuators.Valves.TwoWayLinear val( redeclare package Medium = Medium, m_flow_nominal=1, dpValve_nominal(displayUnit="bar") = 10000) AixLib.Fluid.Actuators.Valves.TwoWayLinear val1( redeclare package Medium = Medium, m_flow_nominal=1, dpValve_nominal(displayUnit="bar") = 10000) HVACAgentBasedControl.Agents.Broker broker(name=20001) HVACAgentBasedControl.Agents.HeatProducerAgent heatProducerAgent( name=30001, costCurrent(start=0), setCapacity(start=0), currentCapacityDiscrete(start=0), maxCapacity=3000) AixLib.Controls.HVACAgentBasedControl.CostFunctions.Economic.Constant_Economic_Cost constantFactor(p=0.067) AixLib.Controls.HVACAgentBasedControl.CostFunctions.Economic.PV_Variable_Economic_Cost variableFactorPV( rad_treshold=310, p=0.29, eta=1) HVACAgentBasedControl.Agents.HeatProducerAgent heatProducerAgent1( name=30002, costCurrent(start=0), setCapacity(start=0), currentCapacityDiscrete(start=0), maxCapacity=10000) Modelica.Blocks.Sources.RealExpression zero(y=0) Modelica.Thermal.HeatTransfer.Sources.FixedHeatFlow fixedHeatFlow(Q_flow=0) HVACAgentBasedControl.Agents.RoomAgent roomAgent( broker=20001, threshold=0.5, sampleRate=1, sampleTriggerTime=120, G=2) HVACAgentBasedControl.Agents.RoomAgent roomAgent1( name=10002, broker=20001, startTime=5, threshold=0.5, sampleRate=1, sampleTriggerTime=120, G=2) Modelica.Blocks.Continuous.LimPID PID( yMax=1, initType=Modelica.Blocks.Types.Init.InitialOutput, k=0.1, Ti=1, Td=0.01, yMin=0.2, y_start=0.2) Modelica.Blocks.Continuous.LimPID PID1( yMax=1, initType=Modelica.Blocks.Types.Init.InitialOutput, k=0.1, Ti=1, Td=0.01, yMin=0.2, y_start=0.2) Modelica.Blocks.Sources.RealExpression zero1(y=273.15 + 20) Modelica.Blocks.Sources.RealExpression zero2(y=1) Fluid.Sources.Boundary_pT bou(nPorts=1, redeclare package Medium = Medium) inner Modelica.Fluid.System system Modelica.Blocks.Interfaces.RealOutput cap1 Modelica.Blocks.Interfaces.RealOutput cap2 Modelica.Blocks.Interfaces.RealOutput valve1 Modelica.Blocks.Interfaces.RealOutput valve2 Modelica.Blocks.Interfaces.RealOutput T1 Modelica.Blocks.Interfaces.RealOutput T2 AixLib.Fluid.Sensors.Temperature senTem(redeclare package Medium = Medium) Modelica.Blocks.Interfaces.RealOutput T_return Modelica.Blocks.Logical.LessThreshold lessThreshold(threshold=273.15 + 60) Modelica.Blocks.Math.UnitConversions.To_degC to_degC Modelica.Blocks.Math.UnitConversions.To_degC to_degC1 Modelica.Blocks.Math.UnitConversions.To_degC to_degC2 Modelica.Blocks.Interfaces.RealOutput T_air Modelica.Blocks.Math.UnitConversions.To_degC to_degC3 Modelica.Blocks.Interfaces.BooleanOutput electricity_free Modelica.Blocks.Logical.And and1 Modelica.Blocks.Logical.Or or1 Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold(threshold= 2999) inner HVACAgentBasedControl.Agents.MessageNotification messageNotification BoundaryConditions.WeatherData.ReaderTMY3 weaDat( calTSky=AixLib.BoundaryConditions.Types.SkyTemperatureCalculation.HorizontalRadiation, computeWetBulbTemperature=false, filNam=Modelica.Utilities.Files.loadResource("modelica://AixLib/Resources/weatherdata/USA_CA_San.Francisco.Intl.AP.724940_TMY3.mos")) "Weather data reader" ThermalZones.ReducedOrder.ThermalZone.ThermalZone thermalZone(redeclare package Medium = Modelica.Media.Air.SimpleAir, redeclare AixLib.DataBase.ThermalZones.OfficePassiveHouse.OPH_1_OfficeNoHeaterCooler zoneParam) ThermalZones.ReducedOrder.ThermalZone.ThermalZone thermalZone1(redeclare package Medium = Modelica.Media.Air.SimpleAir, redeclare AixLib.DataBase.ThermalZones.OfficePassiveHouse.OPH_1_OfficeNoHeaterCooler zoneParam) BoundaryConditions.WeatherData.Bus weaBus "Weather data bus" Modelica.Blocks.Sources.Constant internalGains[3](k={0,0,0}) Fluid.FixedResistances.HydraulicResistance hydraulicResistance1( redeclare package Medium = Medium, m_flow_nominal=0.02, zeta=10, diameter=0.05) Fluid.FixedResistances.HydraulicResistance hydraulicResistance( redeclare package Medium = Medium, m_flow_nominal=0.02, zeta=10, diameter=0.05) equation connect(fan.port_a, hea1.port_b) connect(fan.port_b, val.port_a) connect(val.port_b, vol1.ports[1]) connect(val1.port_b, vol.ports[1]) connect(fan.port_b, val1.port_a) connect(vol.ports[2], hea.port_a) connect(vol1.ports[2], hea.port_a) connect(heatProducerAgent.calcCapacity, constantFactor.capacity) connect(heatProducerAgent.calcCost, constantFactor.cost) connect(heatProducerAgent.setCapacityOut, hea.u) connect(hea.Q_flow, heatProducerAgent.currentCapacity) connect(hea1.u, heatProducerAgent1.setCapacityOut) connect(hea1.Q_flow, heatProducerAgent1.currentCapacity) connect(heatProducerAgent1.calcCapacity, variableFactorPV.capacity) connect(variableFactorPV.cost, heatProducerAgent1.calcCost) connect(PID1.u_m, roomAgent1.T) connect(PID.u_s, zero1.y) connect(PID1.u_s, zero1.y) connect(PID.y, val1.y) connect(PID1.y, val.y) connect(fan.m_flow_in, zero2.y) connect(fixedHeatFlow.port, fan.heatPort) connect(bou.ports[1], fan.port_a) connect(hea1.Q_flow, cap2) connect(hea.Q_flow, cap1) connect(val.y_actual, valve1) connect(valve2, val1.y_actual) connect(senTem.port, hea.port_a) connect(senTem.T, lessThreshold.u) connect(lessThreshold.y, heatProducerAgent.OnOff_external) connect(T_return, to_degC.y) connect(senTem.T, to_degC.u) connect(T2, to_degC1.y) connect(T1, to_degC2.y) connect(to_degC3.y, T_air) connect(variableFactorPV.electricity_free, electricity_free) connect(and1.u1, lessThreshold.y) connect(electricity_free, and1.u2) connect(greaterEqualThreshold.y, or1.u1) connect(heatProducerAgent.setCapacityOut, greaterEqualThreshold.u) connect(or1.u2, and1.y) connect(or1.y, heatProducerAgent1.OnOff_external) connect(weaDat.weaBus, thermalZone1.weaBus) connect(weaDat.weaBus,thermalZone. weaBus) connect(weaDat.weaBus, weaBus) connect(variableFactorPV.rad, weaBus.HGloHor) connect(vol.heatPort, thermalZone.intGainsConv) connect(vol.heatPort, thermalZone.intGainsRad) connect(vol1.heatPort, thermalZone1.intGainsConv) connect(vol1.heatPort, thermalZone1.intGainsRad) connect(thermalZone.intGains, internalGains.y) connect(thermalZone1.intGains, internalGains.y) connect(roomAgent.T, PID.u_m) connect(thermalZone1.TAir, roomAgent1.T) connect(thermalZone.TAir, roomAgent.T) connect(to_degC3.u, weaBus.TDryBul) connect(to_degC1.u, roomAgent.T) connect(to_degC2.u, roomAgent1.T) connect(fan.port_b, hydraulicResistance1.port_a) connect(hydraulicResistance1.port_b, hea.port_a) connect(hea.port_b, hydraulicResistance.port_a) connect(hydraulicResistance.port_b, hea1.port_a) end BuildingWithPV;
High Temperature Circuit . <b><span style= \"font-family: MS Shell Dlg 2; color: #008000;\">Overview</span></b>
within AixLib.Controls.HVACAgentBasedControl.Examples.HVACAgentsCommunications; model SimpleCommunication extends Modelica.Icons.Example; Agents.ConsumerAgent roomAgent_C(broker=20001, sampleTrigger(period=100)) Modelica.Blocks.Sources.TimeTable timeTable(table=[0.0,5000; 20,5000; 30, 5000; 50,5000; 70,5000; 90,5000]) Agents.Broker broker_LTC(name=20001, startTable=[30001,0,0,0,0,0,0; 30002,0, 0,0,0,0,0]) Agents.IntermediateAgent intermediateAgent_C(name=30001, broker=40001, setCapacity(start=3000)) Agents.Broker broker_HTC(name=40001, startTable=[40002,0,0,0,0,0,0; 40003,0, 0,0,0,0,0]) Agents.HeatProducerAgent heatProducerAgent(setCapacity(start=3000), name=40002) Agents.HeatProducerAgent heatProducerAgent1( name=30002, setCapacity(start=1000), maxCapacity=2000) Agents.HeatProducerAgent heatProducerAgent2(name=40003, setCapacity(start=4000)) Modelica.Blocks.Sources.BooleanExpression onOff(y=true) Modelica.Blocks.Sources.RealExpression cost(y=100) Modelica.Blocks.Sources.RealExpression capacity(y=1) inner Agents.MessageNotification messageNotification AixLib.Controls.HVACAgentBasedControl.CostFunctions.Economic.Constant_Economic_Cost constantFactor(p=1, eta=1) AixLib.Controls.HVACAgentBasedControl.CostFunctions.Economic.Constant_Economic_Cost constantFactor1(eta=1, p=2) AixLib.Controls.HVACAgentBasedControl.CostFunctions.Economic.Constant_Economic_Cost constantFactor2(eta=1, p=0.5) equation connect(onOff.y, heatProducerAgent.OnOff_external) connect(onOff.y, intermediateAgent_C.OnOff_external) connect(onOff.y, heatProducerAgent1.OnOff_external) connect(cost.y, intermediateAgent_C.calcCost) connect(capacity.y, intermediateAgent_C.currentCapacity) connect(capacity.y, heatProducerAgent1.currentCapacity) connect(capacity.y, heatProducerAgent2.currentCapacity) connect(heatProducerAgent.currentCapacity, heatProducerAgent2.currentCapacity) connect(timeTable.y, roomAgent_C.demand) connect(onOff.y, heatProducerAgent2.OnOff_external) connect(heatProducerAgent.calcCapacity, constantFactor.capacity) connect(heatProducerAgent.calcCost, constantFactor.cost) connect(heatProducerAgent2.calcCapacity, constantFactor1.capacity) connect(constantFactor1.cost, heatProducerAgent2.calcCost) connect(heatProducerAgent1.calcCapacity, constantFactor2.capacity) connect(heatProducerAgent1.calcCost, constantFactor2.cost) end SimpleCommunication;
Contains interfaces for connection to physical and automation system
within AixLib.Controls; package Interfaces "Contains interfaces for connection to physical and automation system" extends Modelica.Icons.InterfacesPackage; end Interfaces;
Model of a heating curve. Model of a heating curve. Either based on table input data or with a function, the set temperature for the heating system is calculated.
within AixLib.Controls.SetPoints; model HeatingCurve "Model of a heating curve" //General parameter Boolean use_tableData=true "Choose between tables or function to calculate TSet" parameter Modelica.Units.SI.ThermodynamicTemperature TOffset(displayUnit="K") = 0 "Offset to heating curve temperature" //Function replaceable function HeatingCurveFunction = AixLib.Controls.SetPoints.Functions.PartialBaseFct "Function to calculate set temperature" //Table Data parameter AixLib.DataBase.Boiler.DayNightMode.HeatingCurvesDayNightBaseDataDefinition heatingCurveRecord "Record with information about heating curve data" parameter Real declination=1 "Declination of curve" //Dynamic room temperature parameter Boolean use_dynTRoom=true "If different room temperatures are required, set to true" parameter Modelica.Units.SI.ThermodynamicTemperature TRoom_nominal=293.15 "Constant desired room temperature " //Day-Night Mode: parameter AixLib.Utilities.Time.Types.ZeroTime zerTim=AixLib.Utilities.Time.Types.ZeroTime.Custom "Enumeration for choosing how reference time (time = 0) should be defined" parameter Real day_hour=6 "Hour of day at which day mode is enabled" parameter Real night_hour=22 "Hour of day at which night mode is enabled" Modelica.Blocks.Interfaces.RealInput T_oda(unit="K") "Outdoor air temperature" Modelica.Blocks.Interfaces.RealInput TRoom_in(unit="K") if use_dynTRoom "Desired room temperature" Modelica.Blocks.Interfaces.RealOutput TSet(unit="K") "Set temperature calculated by heating curve" protected Modelica.Blocks.Tables.CombiTable2Ds tableDay( final tableOnFile=false, final table=heatingCurveRecord.varFlowTempDay, final smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments) if use_tableData "Combi Table for day data"; Modelica.Blocks.Tables.CombiTable2Ds tableNight( final tableOnFile=false, final table=heatingCurveRecord.varFlowTempNight, final smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments) if use_tableData "Combi Table for night data"; Modelica.Blocks.Interfaces.RealOutput TSet_internal "Internal set temperature"; Modelica.Blocks.Sources.RealExpression TRoomExp(y=TRoom_nominal) "Real expression for room temperature"; Modelica.Blocks.Sources.Constant dec(k=declination) "Declination constant for connectors"; AixLib.Utilities.Time.CalendarTime calTime(zerTim = zerTim) "Calendar-time to get current hour"; Modelica.Blocks.Interfaces.RealInput TRoom_internal "Actual room temperature to calculate with"; Modelica.Blocks.Math.UnitConversions.To_degC to_degC if use_tableData "Convert Kelvin to degC"; AixLib.Utilities.Logical.SmoothSwitch dayNightSwitch if use_tableData "Switch between day and night mode"; Modelica.Blocks.Interfaces.BooleanOutput isDay "Boolean to evaluate whether it is daytime or nighttime"; equation //Connect the room temperatures if use_dynTRoom then connect(TRoom_internal,TRoom_in); else connect(TRoom_internal,TRoomExp.y); end if; //Evaluate whether current time is daytime or nighttime if calTime.hour >= day_hour and calTime.hour < night_hour then isDay = true; else isDay = false; end if; //Convert Kelvin to degC for tables and function //Connect all models if tables are used, else use the function to calculate the internal set temperature if use_tableData then connect(T_oda, to_degC.u); connect(dec.y, tableDay.u2); connect(dec.y, tableNight.u2); connect(to_degC.y, tableDay.u1); connect(to_degC.y, tableNight.u1); connect(tableDay.y, dayNightSwitch.u1); connect(isDay, dayNightSwitch.u2); connect(tableNight.y, dayNightSwitch.u3); connect(dayNightSwitch.y, TSet_internal); else TSet_internal = HeatingCurveFunction( T_oda, TRoom_internal, isDay); end if; //Check if current outdoor air temperature is higher than the needed room temperature. If so, no heating is required //Else the needed offset is added and the temperature is adjusted according to the wished room temperature if T_oda >= TRoom_internal then TSet = TRoom_internal; else TSet =(TSet_internal + TOffset) + 273.15; end if; end HeatingCurve;
Occupancy schedule with look-ahead. This model outputs whether the building is currently occupied, and how long it will take until the next time when the building will be occupied or non-occupied. The latter may be used, for example, to start a ventilation system half an hour before occupancy starts in order to ventilate the room.
within AixLib.Controls.SetPoints; block OccupancySchedule "Occupancy schedule with look-ahead" extends Modelica.Blocks.Icons.Block; parameter Real occupancy[:]=3600*{7, 19} "Occupancy table, each entry switching occupancy on or off"; parameter Boolean firstEntryOccupied = true "Set to true if first entry in occupancy denotes a changed from unoccupied to occupied"; parameter Modelica.Units.SI.Time period=86400 "End time of periodicity"; Modelica.Blocks.Interfaces.RealOutput tNexNonOcc "Time until next non-occupancy" Modelica.Blocks.Interfaces.RealOutput tNexOcc "Time until next occupancy" Modelica.Blocks.Interfaces.BooleanOutput occupied "Outputs true if occupied at current time" protected final parameter Integer nRow = size(occupancy,1) "Number of rows in the schedule"; discrete Modelica.Units.SI.Time tOcc "Time when next occupancy starts"; discrete Modelica.Units.SI.Time tNonOcc "Time when next non-occupancy starts"; discrete Modelica.Units.SI.Time tNext "Time of next switch in schedule"; function getOutput "Get the next occupancy or non-occupancy outputs" extends Modelica.Icons.Function; input Modelica.Units.SI.Time t "Current model time"; input Modelica.Units.SI.Time period "Periodicity"; input Real occupancy[nRow] "Occupancy table, each entry switching occupancy on or off"; input Boolean firstEntryOccupied "Set to true if first entry in occupancy denotes a changed from unoccupied to occupied"; input Integer nRow "Number of rows in the schedule"; output Modelica.Units.SI.Time tOcc "Time when next occupancy starts"; output Modelica.Units.SI.Time tNonOcc "Time when next non-occupancy starts"; output Boolean occupied "Outputs true if occupied at current time"; output Modelica.Units.SI.Time tNext "Time of next switch in schedule"; protected Integer iPerSta "Counter for the period in which the next occupancy starts"; Integer iPerSto "Counter for the period in which the next occupancy stops"; Integer nexStaInd "Next index when occupancy starts"; Integer nexStoInd "Next index when occupancy stops"; algorithm // Initialize variables iPerSta := integer(t/period); iPerSto := iPerSta; // First, assume that the first entry is occupied nexStaInd := 1; nexStoInd := 2; // nRow is an even number for i in 1:2:nRow-1 loop if t >= occupancy[i] + iPerSta*period then nexStaInd := i+2; end if; end for; for i in 2:2:nRow loop if t >= occupancy[i] + iPerSto*period then nexStoInd := i+2; end if; end for; if nexStaInd > nRow then nexStaInd := 1; iPerSta :=iPerSta + 1; end if; if nexStoInd > nRow then nexStoInd := 2; iPerSto :=iPerSto + 1; end if; tOcc := occupancy[nexStaInd] + iPerSta*period; tNonOcc := occupancy[nexStoInd] + iPerSto*period; occupied := tNonOcc < tOcc; // Now, correct if the first entry is vaccant instead of occupied if not firstEntryOccupied then (nexStaInd, nexStoInd) := switchInteger(nexStaInd, nexStoInd); (iPerSta, iPerSto) := switchInteger(iPerSta, iPerSto); (tOcc, tNonOcc) := switchReal(tOcc, tNonOcc); occupied := not occupied; end if; tNext :=min(tOcc, tNonOcc); end getOutput; encapsulated function switchInteger "Switch two Integer arguments" import Modelica; extends Modelica.Icons.Function; input Integer x1 "First argument"; input Integer x2 "Second argument"; output Integer y1 "Output = x2"; output Integer y2 "Output = x1"; algorithm y1:=x2; y2:=x1; end switchInteger; encapsulated function switchReal "Switch two Real arguments" import Modelica; extends Modelica.Icons.Function; input Real x1 "First argument"; input Real x2 "Second argument"; output Real y1 "Output = x2"; output Real y2 "Output = x1"; algorithm y1:=x2; y2:=x1; end switchReal; initial equation // Check parameters for correctness assert(mod(nRow, 2) < 0.1, "The parameter \"occupancy\" must have an even number of elements.\n"); assert(0 <= occupancy[1], "The first element of \"occupancy\" must be bigger than or equal to zero." + "\n Received occupancy[1] = " + String(occupancy[1])); assert(period >= occupancy[nRow], "The parameter \"period\" must be greater than or equal to the last element of \"occupancy\"." + "\n Received period = " + String(period) + "\n occupancy[" + String(nRow) + "] = " + String(occupancy[nRow])); for i in 1:nRow-1 loop assert(occupancy[i] < occupancy[i+1], "The elements of the parameter \"occupancy\" must be strictly increasing."); end for; (tOcc, tNonOcc, occupied, tNext) = getOutput(t = time, period = period, occupancy= occupancy, firstEntryOccupied = firstEntryOccupied, nRow=nRow); equation when time >= pre(tNext) then (tOcc, tNonOcc, occupied, tNext) = getOutput(t = time, period = period, occupancy= occupancy, firstEntryOccupied = firstEntryOccupied, nRow=nRow); end when; tNexOcc = tOcc-time; tNexNonOcc = tNonOcc-time; end OccupancySchedule;
Package with models for control set points
within AixLib.Controls; package SetPoints "Package with models for control set points" extends Modelica.Icons.VariantsPackage; end SetPoints;
Block to compute the supply and return set point. This block computes the set point temperatures for the supply and return water temperature. The set point for the room air temperature can either be specified by a parameter, or it can be an input to the model. The latter allows to use this model with systems that have night set back.
within AixLib.Controls.SetPoints; block SupplyReturnTemperatureReset "Block to compute the supply and return set point" extends Modelica.Blocks.Icons.Block; parameter Real m = 1.3 "Exponent for heat transfer"; parameter Modelica.Units.SI.Temperature TSup_nominal "Supply temperature" parameter Modelica.Units.SI.Temperature TRet_nominal "Return temperature" parameter Modelica.Units.SI.Temperature TRoo_nominal=293.15 "Room temperature" parameter Modelica.Units.SI.Temperature TOut_nominal "Outside temperature" parameter Boolean use_TRoo_in = false "Get the room temperature set point from the input connector" parameter Modelica.Units.SI.Temperature TRoo=293.15 "Fixed value of room temperature set point" parameter Modelica.Units.SI.TemperatureDifference dTOutHeaBal(displayUnit="K") = 8 "Offset for heating curve"; Modelica.Blocks.Interfaces.RealInput TRoo_in(final quantity="ThermodynamicTemperature", final unit = "K", displayUnit = "degC", min=0) if use_TRoo_in "Room air temperature set point" Modelica.Blocks.Interfaces.RealInput TOut(final quantity="ThermodynamicTemperature", final unit = "K", displayUnit = "degC", min=0) "Outside temperature" Modelica.Blocks.Interfaces.RealOutput TSup(final quantity="ThermodynamicTemperature", final unit = "K", displayUnit = "degC", min=0) "Setpoint for supply temperature" Modelica.Blocks.Interfaces.RealOutput TRet(final quantity="ThermodynamicTemperature", final unit = "K", displayUnit = "degC", min=0) "Setpoint for return temperature" protected Modelica.Blocks.Interfaces.RealInput TRoo_in_internal(final quantity="ThermodynamicTemperature", final unit = "K", displayUnit = "degC", min=0) "Needed to connect to conditional connector"; Real qRel "Relative heating load = Q_flow/Q_flow_nominal"; Modelica.Units.SI.Temperature TOutOffSet "Effective outside temperature for heat transfer (takes into account room heat gains)"; parameter Modelica.Units.SI.Temperature TOutOffSet_nominal=TOut_nominal + dTOutHeaBal "Effective outside temperature for heat transfer at nominal conditions (takes into account room heat gains)"; equation connect(TRoo_in, TRoo_in_internal); if not use_TRoo_in then TRoo_in_internal = TRoo; end if; TOutOffSet = TOut + dTOutHeaBal; // Relative heating load, compared to nominal conditions qRel = max(0, (TRoo_in_internal-TOutOffSet)/(TRoo_nominal-TOutOffSet_nominal)); TSup = TRoo_in_internal + ((TSup_nominal+TRet_nominal)/2-TRoo_nominal) * qRel^(1/m) + (TSup_nominal-TRet_nominal)/2 * qRel; TRet = TSup - qRel * (TSup_nominal-TRet_nominal); end SupplyReturnTemperatureReset;
Model for a set point that is interpolated based on a user-specified table. This block can be used to schedule a set-point by using piecewise linear functions. For example, the instances
within AixLib.Controls.SetPoints; model Table "Model for a set point that is interpolated based on a user-specified table" extends Modelica.Blocks.Interfaces.SISO; parameter Real table[:,2]=fill(0.0, 1, 2) "Table matrix ( e.g., table=[u1, y1; u2, y2; u3, y3])"; parameter Real offset=0 "Offset of output signal"; parameter Boolean constantExtrapolation = true "If true, then y=y1 for u<u1, and y=yMax for u>uMax"; protected final parameter Integer nRow = if constantExtrapolation then size(table,1)+2 else size(table,1) "Number of rows"; final parameter Real[nRow,2] offsetVector = [zeros(nRow), offset*ones(nRow)] "Vector to take offset of output signal into account"; Modelica.Blocks.Tables.CombiTable1Dv tab(tableOnFile=false, final table=(if constantExtrapolation then cat( 1, [table[1, 1] - 1,table[1, 2]], table, [table[end, 1] + 1,table[end, 2]]) else table) + offsetVector) "Table used for interpolation" equation connect(u, tab.u[1]) connect(tab.y[1], y) AixLib.Controls.SetPoints.Table tabConExt(constantExtrapolation=true, table=[20, 0.0; 22, 0.5; 25, 0.5; 26, 1.0]); </pre> <p> will cause the following output: </p> <p> <img src=\"modelica://AixLib/Resources/Images/Controls/SetPoints/Table.png\" border=\"1\" alt=\"Table output.\"/> </p> <p> For the default setting <code>constantExtrapolation=true</code>, the block outputs <code>y=y1+offset</code> for <code>u &le; u1</code>, and <code>y=yMax+offset</code> for <code>u &ge; uMax</code>. Otherwise, the table is linearly extrapolated with a constant derivative. </p> <p> Note that the first column must be strictly increasing. </p> </html>", revisions="<html> <ul> <li> August 30, 2016, by Michael Wetter:<br/> Changed protected final parameter <code>nCol</code> to <code>nRow</code>.<br/> This is for <a href=\"https://github.com/lbl-srg/modelica-buildings/issues/555\">issue 555</a>. </li> <li> April 5, 2011, by Michael Wetter:<br/> Fixed wrong table declaration. </li> <li> July 13, 2010, by Michael Wetter:<br/> First implementation. </li> </ul> </html>"), Icon(graphics={ Text( extent={{-78,-45},{-40,-56}}, textColor={0,0,0}, textString="offset"), Line( points={{-42,-24},{-42,-74}}, color={95,95,95}, thickness=0.25, arrow={Arrow.None,Arrow.None}), Line( points={{-82,-24},{-22,-24},{26,24}}, color={0,0,255}, thickness=0.5), Line(points={{-82,64},{-82,-84}}, color={95,95,95}), Text( extent={{-80,88},{-39,68}}, textColor={0,0,0}, textString="y"), Polygon( points={{-82,86},{-88,64},{-76,64},{-82,86}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid), Polygon( points={{88,-74},{66,-68},{66,-80},{88,-74}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid), Line(points={{-92,-74},{80,-74}}, color={95,95,95}), Text( extent={{68,-84},{92,-95}}, textColor={0,0,0}, textString="u"), Polygon( points={{-42,-24},{-44,-34},{-39,-34},{-42,-24}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid), Polygon( points={{-42,-74},{-45,-64},{-40,-64},{-42,-74},{-42,-74}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid), Line( points={{26,24},{77,24}}, color={0,0,255}, thickness=0.5)}), __Dymola_LockedEditing="Model from IBPSA"); end Table;
Test model for occupancy schedule with look-ahead. Example that demonstrates the use of the occupancy schedule. The figure below shows how the time until the next occupancy starts or ends is decreased. The red line hits zero when the schedule indicates an occupied time, and the blue line hits zero when the schedule indicates a non-occupied time.
within AixLib.Controls.SetPoints.Examples; model OccupancySchedule "Test model for occupancy schedule with look-ahead" extends Modelica.Icons.Example; AixLib.Controls.SetPoints.OccupancySchedule occSchDay "Day schedule" AixLib.Controls.SetPoints.OccupancySchedule occSchWee(occupancy=3600*{7,19, 31,43,55,67,79,91,103,115,127,139}, period=7*24*3600) "Week schedule" end OccupancySchedule;
Collection of models that illustrate model use and test models
within AixLib.Controls.SetPoints; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
Test model for the heating curve. Example that demonstrates the use of the hot water temperature reset for a heating system. The parameters of the block <code>heaCur</code> are for a heating system with <i>60</i>&deg;C supply water temperature and <i>40</i>&deg;C return water temperature at an outside temperature of <i>-10</i>&deg;C and a room temperature of <i>20</i>&deg;C. The offset for the temperature reset is <i>8</i> Kelvin, i.e., above <i>12</i>&deg;C outside temperature, there is no heating load. The figure below shows the computed supply and return water temperatures.
within AixLib.Controls.SetPoints.Examples; model SupplyReturnTemperatureReset "Test model for the heating curve" extends Modelica.Icons.Example; AixLib.Controls.SetPoints.SupplyReturnTemperatureReset heaCur( m=1, TSup_nominal=333.15, TRet_nominal=313.15, TOut_nominal=263.15) "Temperature reset" Modelica.Blocks.Sources.Ramp TOut( height=40, duration=1, offset=263.15) "Signal for outside air temperature" AixLib.Controls.SetPoints.SupplyReturnTemperatureReset heaCur1( m=1, use_TRoo_in=true, TSup_nominal=333.15, TRet_nominal=313.15, TOut_nominal=263.15, dTOutHeaBal=15) "Temperature reset that uses room temperature as input" Modelica.Blocks.Sources.Step TRoo( offset=273.15 + 20, startTime=0.5, height=-5) "Night set back from 20 to 15 deg C" Modelica.Blocks.Sources.Constant TOut2(k=273.15 - 10) "Constant signal for outdoor air temperature" equation connect(TOut.y, heaCur.TOut) connect(TOut2.y, heaCur1.TOut) connect(TRoo.y, heaCur1.TRoo_in) end SupplyReturnTemperatureReset;
Test model for table that determines set points. Example that demonstrates the use of the block <a href=\"modelica://AixLib.Controls.SetPoints.Table\"> AixLib.Controls.SetPoints.Table</a>.
within AixLib.Controls.SetPoints.Examples; model Table "Test model for table that determines set points" extends Modelica.Icons.Example; AixLib.Controls.SetPoints.Table tabConExt(table=[20,0; 22,0.5; 25,0.5; 26,1]) Modelica.Blocks.Sources.Ramp TRoo( duration=1, offset=15, height=15) AixLib.Controls.SetPoints.Table tabLinExt(constantExtrapolation=false, table=[ 20,0; 22,0.5; 25,0.5; 26,1]) equation connect(TRoo.y, tabLinExt.u) connect(TRoo.y, tabConExt.u) end Table;
Package with functions for pacakge AixLib.Controls.HeatPump
within AixLib.Controls.SetPoints; package Functions "Package with functions for pacakge AixLib.Controls.HeatPump" end Functions;
Test model for occupancy schedule with look-ahead. Example that validates the occupancy schedule for a negative start time.
within AixLib.Controls.SetPoints.Validation; model OccupancyScheduleNegativeStartTime "Test model for occupancy schedule with look-ahead" extends Modelica.Icons.Example; AixLib.Controls.SetPoints.OccupancySchedule occSchDay(occupancy=3600*{7,24}) "Day schedule" OccupancySchedule occSchDay1(occupancy=3600*{0,2}) "Day schedule" OccupancySchedule occSchDay2( occupancy=3600*{7,10,17,20}, firstEntryOccupied=false) "Day schedule" end OccupancyScheduleNegativeStartTime;
Validation model for occupancy schedule with positive start time. Example that validates the occupancy schedule for a positive start time.
within AixLib.Controls.SetPoints.Validation; model OccupancySchedulePositiveStartTime "Validation model for occupancy schedule with positive start time" extends OccupancyScheduleNegativeStartTime; end OccupancySchedulePositiveStartTime;
Collection of validation models
within AixLib.Controls.SetPoints; package Validation "Collection of validation models" extends Modelica.Icons.ExamplesPackage; end Validation;
Package with models for ventilation control in buildings
within AixLib.Controls; package VentilationController "Package with models for ventilation control in buildings" extends Modelica.Icons.Package; end VentilationController;
transforms occupation and temperature into air exchange rate. Ventilation is determined from 4 effects:
within AixLib.Controls.VentilationController; model VentilationController "transforms occupation and temperature into air exchange rate" parameter Boolean useConstantOutput=false "provide constant ACH(=baseACH), false = no user induced infiltration (window opening)"; parameter Real baseACH=0.2 "baseline air changes per hour" parameter Real maxUserACH=1.0 "additional ACH value for max. user activity" parameter Real[2] maxOverheatingACH={3.0,2.0} "additional ACH value when overheating appears, transition range in K" parameter Real[3] maxSummerACH={1.0,273.15 + 10,273.15 + 17} "additional ACH in summer, Tmin, Tmax" parameter Real[3] winterReduction={0.2,maxSummerACH[2] - 10,maxSummerACH[2]} "reduction factor of userACH for cold weather." Real userACH "additional ACH value for max. user window opening activity"; Real dToh "relative overheating"; Real overheatingACH "additional ACH value when overheating appears"; Real dTamb "relative summer (0: winter, 1: summer)"; Real dTmin "relative winter (0: transition start (10 degC), 1: winter end (0 degC)"; Real redFac "reduction factor of user ventilation for cold outside air temperatures."; Real summerACH "additional ACH due to summer temperature"; Modelica.Blocks.Interfaces.RealInput relOccupation "relative occupation" output Modelica.Blocks.Interfaces.RealOutput y Modelica.Blocks.Interfaces.RealInput Tambient "ambient Temperature" Modelica.Blocks.Interfaces.RealInput Tzone "zone temperature" BaseClasses.OptimalTempDeCarliHumidity optimalTemp(cat=2) "optimal temperature according to investigations from deCarli" BaseClasses.DEMA dEMA(ystart=Tmean_start) "gliding exponential average of outdoor temperature" Modelica.Blocks.Interfaces.RealOutput Tamb_mean "mean outdoor temperature" parameter Real Tmean_start=277.85 "Start value of EMA"; output Modelica.Blocks.Interfaces.RealOutput Top "optimal temperature" equation assert(relOccupation < 1.01, "Error in ventilation model. Relative occupation must not exceed 1.0!"); optimalTemp.u[2] = 0.5 "assuming constant relative humidity in zone"; if useConstantOutput then userACH = 0; dToh = 0; overheatingACH = 0; dTamb = 0; dTmin = 0; redFac = 0; summerACH = 0; else userACH = relOccupation*maxUserACH "user induced ventilation"; dToh = (Tzone - optimalTemp.y[2])/maxOverheatingACH[2] "relative overheating"; overheatingACH = if dToh > 0 then min(dToh*maxOverheatingACH[1], maxOverheatingACH[1]) else 0; dTamb = (dEMA.y[2] - maxSummerACH[2])/(maxSummerACH[3] - maxSummerACH[2]) "determine when transition period occurs"; dTmin = (dEMA.y[2] - winterReduction[2])/(winterReduction[3] - winterReduction[2]); redFac = if dTmin > 0 then min(dTmin*(1 - winterReduction[1]), 1 - winterReduction[1]) + winterReduction[1] else winterReduction[1]; summerACH = if dTamb > 0 then min(dTamb*maxSummerACH[1], maxSummerACH[1]) else 0; end if; y = baseACH + userACH*redFac + overheatingACH + summerACH; connect(Tambient, dEMA.u) connect(dEMA.y[2], optimalTemp.u[1]) connect(dEMA.y[2], Tamb_mean) connect(optimalTemp.y[3], Top) end VentilationController;
double exponential moving average.
within AixLib.Controls.VentilationController.BaseClasses; block DEMA "double exponential moving average" extends Modelica.Blocks.Interfaces.SIMO(nout=2); protected Modelica.Blocks.Continuous.CriticalDamping ExpAVG( n=1, x_start=fill(ystart, ExpAVG.n), f=1/(Modelica.Constants.pi*period), normalized=false, initType=Modelica.Blocks.Types.Init.InitialState, y_start=ystart) Modelica.Blocks.Discrete.Sampler sampler(samplePeriod=sampleTime) public parameter Modelica.Units.SI.Time period=86400*4; parameter Modelica.Units.SI.Time sampleTime=86400; parameter Real ystart=279.15 "Start value of EMA"; protected Modelica.Blocks.Continuous.CriticalDamping ExpAVG1( n=1, x_start=fill(ystart, ExpAVG.n), f=1/(Modelica.Constants.pi*period), normalized=false, initType=Modelica.Blocks.Types.Init.InitialState, y_start=ystart) Modelica.Blocks.Math.Gain gain(k=2) public Modelica.Blocks.Math.Feedback DEMAcont "continous double exponential moving average" equation connect(u, ExpAVG.u) connect(sampler.y, y[1]) connect(ExpAVG.y, gain.u) connect(ExpAVG.y, ExpAVG1.u) connect(gain.y, DEMAcont.u1) connect(ExpAVG1.y, DEMAcont.u2) connect(DEMAcont.y, sampler.u) connect(DEMAcont.y, y[2]) end DEMA;
optimal operative Temperature according to Fanger and deCarli model including humidity evaluation. u:
within AixLib.Controls.VentilationController.BaseClasses; model OptimalTempDeCarliHumidity "optimal operative Temperature according to Fanger and deCarli model including humidity evaluation" import Modelica.Units.Conversions.from_degC; import Modelica.Units.Conversions.to_degC; extends Modelica.Blocks.Interfaces.MIMO(nin=2, nout=3); // u is 1. ambient temperature and 2. relative humidity; y is Min and max temperatures according to input temperature parameter Modelica.Units.SI.TemperatureDifference cat=2 "offset for quality category. cat I: 1 K, cat. II: 2 K, cat. III: 3 K."; Modelica.Units.SI.ThermodynamicTemperature Topt; protected parameter Modelica.Units.SI.Temperature Tclomax=from_degC(0) "mean outdoor air temperature when max clo value of 1.0 will be reached"; parameter Modelica.Units.SI.Temperature Tclomin=from_degC(27.778) "mean outdoor air temperature when min clo value of 0.5 will be reached"; equation if u[1] <= Tclomax then Topt =from_degC(AixLib.Utilities.Math.Functions.polynomial(to_degC(Tclomax), AixLib.Controls.VentilationController.BaseClasses.coefficients(u[2]))) "minimum optimal temperature"; elseif u[1] >= Tclomin then Topt =from_degC(AixLib.Utilities.Math.Functions.polynomial(to_degC(Tclomin), AixLib.Controls.VentilationController.BaseClasses.coefficients(u[2]))) "const. Temp. above 0.5 clo limit"; else Topt =from_degC(AixLib.Utilities.Math.Functions.polynomial(to_degC(u[1]), AixLib.Controls.VentilationController.BaseClasses.coefficients(u[2]))); end if; y = {Topt - cat,Topt + cat,Topt} "min, max, opt"; end OptimalTempDeCarliHumidity;
Package contains records for the models in the library.
within AixLib; package DataBase "Package contains records for the models in the library." extends Modelica.Icons.Package; end DataBase;
Records describing boiler efficiencies
within AixLib.DataBase; package Boiler "Records describing boiler efficiencies" extends Modelica.Icons.VariantsPackage; end Boiler;
Day and night mode records
within AixLib.DataBase.Boiler; package DayNightMode "Day and night mode records" extends Modelica.Icons.VariantsPackage; end DayNightMode;
General purpose records for boiler models
within AixLib.DataBase.Boiler; package General "General purpose records for boiler models" extends Modelica.Icons.VariantsPackage; end General;
Work load records
within AixLib.DataBase.Boiler; package WorkLoad "Work load records" extends Modelica.Icons.VariantsPackage; end WorkLoad;
Combined heat and power generation
within AixLib.DataBase; package CHP "Combined heat and power generation" extends Modelica.Icons.VariantsPackage; end CHP;
Medium model of a mixture of ideal gases based on NASA source
within AixLib.DataBase.CHP.ModularCHPEngineMedia; partial package CHPCombustionMixtureGasNasa "Medium model of a mixture of ideal gases based on NASA source" import Modelica.Math; import Modelica.Media.Interfaces.Choices.ReferenceEnthalpy; extends Modelica.Media.Interfaces.PartialMixtureMedium( ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.pTX, substanceNames=data[:].name, reducedX = false, singleState=false, reference_X=fill(1/nX,nX), SpecificEnthalpy(start=if referenceChoice==ReferenceEnthalpy.ZeroAt0K then 3e5 else if referenceChoice==ReferenceEnthalpy.UserDefined then h_offset else 0, nominal=1.0e5), Density(start=10, nominal=10), AbsolutePressure(start=10e5, nominal=10e5), Temperature(min=200, max=6000, start=500, nominal=500)); redeclare record extends ThermodynamicState "Thermodynamic state variables" end ThermodynamicState; // redeclare record extends FluidConstants "Fluid constants" // end FluidConstants; constant Modelica.Media.IdealGases.Common.DataRecord[:] data "Data records of ideal gas substances"; // ={Common.SingleGasesData.N2,Common.SingleGasesData.O2} constant Boolean excludeEnthalpyOfFormation=true "If true, enthalpy of formation Hf is not included in specific enthalpy h"; constant ReferenceEnthalpy referenceChoice=ReferenceEnthalpy.ZeroAt0K "Choice of reference enthalpy"; constant SpecificEnthalpy h_offset=0.0 "User defined offset for reference enthalpy, if referenceChoice = UserDefined"; // constant FluidConstants[nX] fluidConstants // "Additional data needed for transport properties"; constant MolarMass[nX] MMX=data[:].MM "Molar masses of components"; constant Integer methodForThermalConductivity(min=1,max=2)=1; redeclare replaceable model extends BaseProperties( T(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default), p(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default), Xi(each stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default), final standardOrderComponents=true) "Base properties (p, d, T, h, u, R, MM, X, and Xi of NASA mixture gas" equation assert(T >= 200 and T <= 6000, " Temperature T (=" + String(T) + " K = 200 K) is not in the allowed range 200 K <= T <= 6000 K required from medium model \"" + mediumName + "\"."); MM = molarMass(state); h = h_TX(T, X); R_s = data.R_s*X; u =h - R_s*T; d =p/(R_s*T); // connect state with BaseProperties state.T = T; state.p = p; state.X = if fixedX then reference_X else X; end BaseProperties; redeclare function setState_pTX "Return thermodynamic state as function of p, T and composition X" extends Modelica.Icons.Function; input AbsolutePressure p "Pressure"; input Temperature T "Temperature"; input MassFraction X[:]=reference_X "Mass fractions"; output ThermodynamicState state; algorithm state := if size(X,1) == 0 then ThermodynamicState(p=p,T=T,X=reference_X) else if size(X,1) == nX then ThermodynamicState(p=p,T=T, X=X) else ThermodynamicState(p=p,T=T, X=cat(1,X,{1-sum(X)})); end setState_pTX; redeclare function setState_phX "Return thermodynamic state as function of p, h and composition X" extends Modelica.Icons.Function; input AbsolutePressure p "Pressure"; input SpecificEnthalpy h "Specific enthalpy"; input MassFraction X[:]=reference_X "Mass fractions"; output ThermodynamicState state; algorithm state := if size(X,1) == 0 then ThermodynamicState(p=p,T=T_hX(h,reference_X),X=reference_X) else if size(X,1) == nX then ThermodynamicState(p=p,T=T_hX(h,X),X=X) else ThermodynamicState(p=p,T=T_hX(h,X), X=cat(1,X,{1-sum(X)})); end setState_phX; redeclare function setState_psX "Return thermodynamic state as function of p, s and composition X" extends Modelica.Icons.Function; input AbsolutePressure p "Pressure"; input SpecificEntropy s "Specific entropy"; input MassFraction X[:]=reference_X "Mass fractions"; output ThermodynamicState state; algorithm state := if size(X,1) == 0 then ThermodynamicState(p=p,T=T_psX(p,s,reference_X),X=reference_X) else if size(X,1) == nX then ThermodynamicState(p=p,T=T_psX(p,s,X),X=X) else ThermodynamicState(p=p,T=T_psX(p,s,X), X=cat(1,X,{1-sum(X)})); end setState_psX; redeclare function setState_dTX "Return thermodynamic state as function of d, T and composition X" extends Modelica.Icons.Function; input Density d "Density"; input Temperature T "Temperature"; input MassFraction X[:]=reference_X "Mass fractions"; output ThermodynamicState state; algorithm state :=if size(X, 1) == 0 then ThermodynamicState( p=d*(data.R_s*reference_X)*T, T=T, X=reference_X) else if size(X, 1) == nX then ThermodynamicState( p=d*(data.R_s*X)*T, T=T, X=X) else ThermodynamicState( p=d*(data.R_s*cat( 1, X, {1 - sum(X)}))*T, T=T, X=cat( 1, X, {1 - sum(X)})); end setState_dTX; redeclare function extends setSmoothState "Return thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b" algorithm state := ThermodynamicState( p=Modelica.Media.Common.smoothStep( x, state_a.p, state_b.p, x_small), T=Modelica.Media.Common.smoothStep( x, state_a.T, state_b.T, x_small), X=Modelica.Media.Common.smoothStep( x, state_a.X, state_b.X, x_small)); end setSmoothState; redeclare function extends pressure "Return pressure of ideal gas" algorithm p := state.p; end pressure; redeclare function extends temperature "Return temperature of ideal gas" algorithm T := state.T; end temperature; redeclare function extends density "Return density of ideal gas" algorithm d :=state.p/((state.X*data.R_s)*state.T); end density; redeclare function extends specificEnthalpy "Return specific enthalpy" extends Modelica.Icons.Function; algorithm h := h_TX(state.T,state.X); end specificEnthalpy; redeclare function extends specificInternalEnergy "Return specific internal energy" extends Modelica.Icons.Function; algorithm u := h_TX(state.T,state.X) - gasConstant(state)*state.T; end specificInternalEnergy; redeclare function extends specificEntropy "Return specific entropy" protected Real[nX] Y(unit="mol/mol")=massToMoleFractions(state.X, data.MM) "Molar fractions"; algorithm s := s_TX(state.T, state.X) - sum(state.X[i]*Modelica.Constants.R/MMX[i]* (if state.X[i]<Modelica.Constants.eps then Y[i] else Modelica.Math.log(Y[i]*state.p/reference_p)) for i in 1:nX); end specificEntropy; redeclare function extends specificGibbsEnergy "Return specific Gibbs energy" extends Modelica.Icons.Function; algorithm g := h_TX(state.T,state.X) - state.T*specificEntropy(state); end specificGibbsEnergy; redeclare function extends specificHelmholtzEnergy "Return specific Helmholtz energy" extends Modelica.Icons.Function; algorithm f := h_TX(state.T,state.X) - gasConstant(state)*state.T - state.T*specificEntropy(state); end specificHelmholtzEnergy; function h_TX "Return specific enthalpy" import Modelica.Media.Interfaces.Choices; extends Modelica.Icons.Function; input Modelica.Units.SI.Temperature T "Temperature"; input MassFraction X[nX]=reference_X "Independent Mass fractions of gas mixture"; input Boolean exclEnthForm=excludeEnthalpyOfFormation "If true, enthalpy of formation Hf is not included in specific enthalpy h"; input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy refChoice=referenceChoice "Choice of reference enthalpy"; input Modelica.Units.SI.SpecificEnthalpy h_off=h_offset "User defined offset for reference enthalpy, if referenceChoice = UserDefined"; output Modelica.Units.SI.SpecificEnthalpy h "Specific enthalpy at temperature T"; algorithm h :=(if fixedX then reference_X else X)* {Modelica.Media.IdealGases.Common.Functions.h_T( data[i], T, exclEnthForm, refChoice, h_off) for i in 1:nX}; end h_TX; function h_TX_der "Return specific enthalpy derivative" import Modelica.Media.Interfaces.Choices; extends Modelica.Icons.Function; input Modelica.Units.SI.Temperature T "Temperature"; input MassFraction X[nX] "Independent Mass fractions of gas mixture"; input Boolean exclEnthForm=excludeEnthalpyOfFormation "If true, enthalpy of formation Hf is not included in specific enthalpy h"; input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy refChoice=referenceChoice "Choice of reference enthalpy"; input Modelica.Units.SI.SpecificEnthalpy h_off=h_offset "User defined offset for reference enthalpy, if referenceChoice = UserDefined"; input Real dT "Temperature derivative"; input Real dX[nX] "Independent mass fraction derivative"; output Real h_der "Specific enthalpy at temperature T"; algorithm h_der := if fixedX then dT*sum((Modelica.Media.IdealGases.Common.Functions.cp_T( data[i], T)*reference_X[i]) for i in 1:nX) else dT*sum((Modelica.Media.IdealGases.Common.Functions.cp_T( data[i], T)*X[i]) for i in 1:nX)+ sum((Modelica.Media.IdealGases.Common.Functions.h_T( data[i], T)*dX[i]) for i in 1:nX); end h_TX_der; redeclare function extends gasConstant "Return gasConstant" algorithm R_s := data.R_s*state.X; end gasConstant; redeclare function extends specificHeatCapacityCp "Return specific heat capacity at constant pressure" algorithm cp := {Modelica.Media.IdealGases.Common.Functions.cp_T( data[i], state.T) for i in 1:nX}*state.X; end specificHeatCapacityCp; redeclare function extends specificHeatCapacityCv "Return specific heat capacity at constant volume from temperature and gas data" algorithm cv :={Modelica.Media.IdealGases.Common.Functions.cp_T(data[i], state.T) for i in 1:nX}*state.X - data.R_s*state.X; end specificHeatCapacityCv; function MixEntropy "Return mixing entropy of ideal gases / R" extends Modelica.Icons.Function; input Modelica.Units.SI.MoleFraction x[:] "Mole fraction of mixture"; output Real smix "Mixing entropy contribution, divided by gas constant"; algorithm smix := sum(if x[i] > Modelica.Constants.eps then -x[i]*Modelica.Math.log(x[i]) else x[i] for i in 1:size(x,1)); end MixEntropy; function s_TX "Return temperature dependent part of the entropy, expects full entropy vector" extends Modelica.Icons.Function; input Temperature T "Temperature"; input MassFraction[nX] X "Mass fraction"; output SpecificEntropy s "Specific entropy"; algorithm s := sum(Modelica.Media.IdealGases.Common.Functions.s0_T( data[i], T)*X[i] for i in 1:size(X,1)); end s_TX; redeclare function extends isentropicExponent "Return isentropic exponent" algorithm gamma := specificHeatCapacityCp(state)/specificHeatCapacityCv(state); end isentropicExponent; redeclare function extends velocityOfSound "Return velocity of sound" extends Modelica.Icons.Function; input ThermodynamicState state "Properties at upstream location"; algorithm a := sqrt(max(0,gasConstant(state)*state.T*specificHeatCapacityCp(state)/specificHeatCapacityCv(state))); end velocityOfSound; function isentropicEnthalpyApproximation "Approximate method of calculating h_is from upstream properties and downstream pressure" extends Modelica.Icons.Function; input AbsolutePressure p2 "Downstream pressure"; input ThermodynamicState state "Thermodynamic state at upstream location"; output SpecificEnthalpy h_is "Isentropic enthalpy"; protected SpecificEnthalpy h "Specific enthalpy at upstream location"; SpecificEnthalpy h_component[nX] "Specific enthalpy at upstream location"; IsentropicExponent gamma = isentropicExponent(state) "Isentropic exponent"; protected MassFraction[nX] X "Complete X-vector"; algorithm X := if reducedX then cat(1,state.X,{1-sum(state.X)}) else state.X; h_component :={Modelica.Media.IdealGases.Common.Functions.h_T( data[i], state.T, excludeEnthalpyOfFormation, referenceChoice, h_offset) for i in 1:nX}; h :=h_component*X; h_is := h + gamma/(gamma - 1.0)*(state.T*gasConstant(state))* ((p2/state.p)^((gamma - 1)/gamma) - 1.0); end isentropicEnthalpyApproximation; redeclare function extends isentropicEnthalpy "Return isentropic enthalpy" input Boolean exact = false "Flag whether exact or approximate version should be used"; algorithm h_is := if exact then specificEnthalpy_psX(p_downstream,specificEntropy(refState),refState.X) else isentropicEnthalpyApproximation(p_downstream,refState); end isentropicEnthalpy; function gasMixtureViscosity "Return viscosities of gas mixtures at low pressures (Wilke method)" extends Modelica.Icons.Function; input MoleFraction[:] yi "Mole fractions"; input MolarMass[size(yi,1)] M "Mole masses"; input DynamicViscosity[size(yi,1)] eta "Pure component viscosities"; output DynamicViscosity etam "Viscosity of the mixture"; protected Real fi[size(yi,1),size(yi,1)]; algorithm for i in 1:size(eta,1) loop assert(fluidConstants[i].hasDipoleMoment,"Dipole moment for " + fluidConstants[i].chemicalFormula + " not known. Can not compute viscosity."); assert(fluidConstants[i].hasCriticalData, "Critical data for "+ fluidConstants[i].chemicalFormula + " not known. Can not compute viscosity."); for j in 1:size(eta,1) loop if i==1 then fi[i,j] := (1 + (eta[i]/eta[j])^(1/2)*(M[j]/M[i])^(1/4))^2/(8*(1 + M[i]/M[j]))^(1/2); elseif j<i then fi[i,j] := eta[i]/eta[j]*M[j]/M[i]*fi[j,i]; else fi[i,j] := (1 + (eta[i]/eta[j])^(1/2)*(M[j]/M[i])^(1/4))^2/(8*(1 + M[i]/M[j]))^(1/2); end if; end for; end for; etam := sum(yi[i]*eta[i]/sum(yi[j]*fi[i,j] for j in 1:size(eta,1)) for i in 1:size(eta,1)); end gasMixtureViscosity; redeclare replaceable function extends dynamicViscosity "Return mixture dynamic viscosity" protected DynamicViscosity[nX] etaX "Component dynamic viscosities"; algorithm for i in 1:nX loop etaX[i] := Modelica.Media.IdealGases.Common.Functions.dynamicViscosityLowPressure( state.T, fluidConstants[i].criticalTemperature, fluidConstants[i].molarMass, fluidConstants[i].criticalMolarVolume, fluidConstants[i].acentricFactor, fluidConstants[i].dipoleMoment); end for; eta := gasMixtureViscosity(massToMoleFractions(state.X, fluidConstants[:].molarMass), fluidConstants[:].molarMass, etaX); end dynamicViscosity; function mixtureViscosityChung "Return the viscosity of gas mixtures without access to component viscosities (Chung, et. al. rules)" extends Modelica.Icons.Function; input Temperature T "Temperature"; input Temperature[nX] Tc "Critical temperatures"; input MolarVolume[nX] Vcrit "Critical volumes (m3/mol)"; input Real[nX] w "Acentric factors"; input Real[nX] mu "Dipole moments (debyes)"; input MolarMass[nX] MolecularWeights "Molecular weights (kg/mol)"; input MoleFraction[nX] y "Molar Fractions"; input Real[nX] kappa = zeros(nX) "Association Factors"; output DynamicViscosity etaMixture "Mixture viscosity (Pa.s)"; protected constant Real[size(y,1)] Vc = Vcrit*1000000 "Critical volumes (cm3/mol)"; constant Real[size(y,1)] M = MolecularWeights*1000 "Molecular weights (g/mol)"; Integer n = size(y,1) "Number of mixed elements"; Real sigmam3 "Mixture sigma3 in Angstrom"; Real sigma[size(y,1),size(y,1)]; Real edivkm; Real edivk[size(y,1),size(y,1)]; Real Mm; Real Mij[size(y,1),size(y,1)]; Real wm "Accentric factor"; Real wij[size(y,1),size(y,1)]; Real kappam "Correlation for highly polar substances such as alcohols and acids"; Real kappaij[size(y,1),size(y,1)]; Real mum; Real Vcm; Real Tcm; Real murm "Dimensionless dipole moment of the mixture"; Real Fcm "Factor to correct for shape and polarity"; Real omegav; Real Tmstar; Real etam "Mixture viscosity in microP"; algorithm //combining rules for i in 1:n loop for j in 1:n loop Mij[i,j] := 2*M[i]*M[j]/(M[i]+M[j]); if i==j then sigma[i,j] := 0.809*Vc[i]^(1/3); edivk[i,j] := Tc[i]/1.2593; wij[i,j] := w[i]; kappaij[i,j] := kappa[i]; else sigma[i,j] := (0.809*Vc[i]^(1/3)*0.809*Vc[j]^(1/3))^(1/2); edivk[i,j] := (Tc[i]/1.2593*Tc[j]/1.2593)^(1/2); wij[i,j] := (w[i] + w[j])/2; kappaij[i,j] := (kappa[i]*kappa[j])^(1/2); end if; end for; end for; //mixing rules sigmam3 := (sum(sum(y[i]*y[j]*sigma[i,j]^3 for j in 1:n) for i in 1:n)); //(epsilon/k)m edivkm := (sum(sum(y[i]*y[j]*edivk[i,j]*sigma[i,j]^3 for j in 1:n) for i in 1:n))/sigmam3; Mm := ((sum(sum(y[i]*y[j]*edivk[i,j]*sigma[i,j]^2*Mij[i,j]^(1/2) for j in 1:n) for i in 1:n))/(edivkm*sigmam3^(2/3)))^2; wm := (sum(sum(y[i]*y[j]*wij[i,j]*sigma[i,j]^3 for j in 1:n) for i in 1:n))/sigmam3; mum := (sigmam3*(sum(sum(y[i]*y[j]*mu[i]^2*mu[j]^2/sigma[i,j]^3 for j in 1:n) for i in 1:n)))^(1/4); Vcm := sigmam3/(0.809)^3; Tcm := 1.2593*edivkm; murm := 131.3*mum/(Vcm*Tcm)^(1/2); kappam := (sigmam3*(sum(sum(y[i]*y[j]*kappaij[i,j] for j in 1:n) for i in 1:n))); Fcm := 1 - 0.275*wm + 0.059035*murm^4 + kappam; Tmstar := T/edivkm; omegav := 1.16145*(Tmstar)^(-0.14874) + 0.52487*Math.exp(-0.77320*Tmstar) + 2.16178*Math.exp(-2.43787*Tmstar); etam := 26.69*Fcm*(Mm*T)^(1/2)/(sigmam3^(2/3)*omegav); etaMixture := etam*1e7; end mixtureViscosityChung; function lowPressureThermalConductivity "Return thermal conductivities of low-pressure gas mixtures (Mason and Saxena Modification)" extends Modelica.Icons.Function; input MoleFraction[:] y "Mole fraction of the components in the gas mixture"; input Temperature T "Temperature"; input Temperature[size(y,1)] Tc "Critical temperatures"; input AbsolutePressure[size(y,1)] Pc "Critical pressures"; input MolarMass[size(y,1)] M "Molecular weights"; input ThermalConductivity[size(y,1)] lambda "Thermal conductivities of the pure gases"; output ThermalConductivity lambdam "Thermal conductivity of the gas mixture"; protected MolarMass[size(y,1)] gamma; Real[size(y,1)] Tr "Reduced temperature"; Real[size(y,1),size(y,1)] A "Mason and Saxena Modification"; constant Real epsilon = 1.0 "Numerical constant near unity"; algorithm for i in 1:size(y,1) loop gamma[i] := 210*(Tc[i]*M[i]^3/Pc[i]^4)^(1/6); Tr[i] := T/Tc[i]; end for; for i in 1:size(y,1) loop for j in 1:size(y,1) loop A[i,j] := epsilon*(1 + (gamma[j]*(Math.exp(0.0464*Tr[i]) - Math.exp(-0.2412*Tr[i]))/ (gamma[i]*(Math.exp(0.0464*Tr[j]) - Math.exp(-0.2412*Tr[j]))))^(1/2)*(M[i]/M[j])^(1/4))^2/ (8*(1 + M[i]/M[j]))^(1/2); end for; end for; lambdam := sum(y[i]*lambda[i]/(sum(y[j]*A[i,j] for j in 1:size(y,1))) for i in 1:size(y,1)); end lowPressureThermalConductivity; redeclare replaceable function extends thermalConductivity "Return thermal conductivity for low pressure gas mixtures" input Integer method=methodForThermalConductivity "Method to compute single component thermal conductivity"; protected ThermalConductivity[nX] lambdaX "Component thermal conductivities"; DynamicViscosity[nX] eta "Component thermal dynamic viscosities"; SpecificHeatCapacity[nX] cp "Component heat capacity"; algorithm for i in 1:nX loop assert(fluidConstants[i].hasCriticalData, "Critical data for "+ fluidConstants[i].chemicalFormula + " not known. Can not compute thermal conductivity."); eta[i] := Modelica.Media.IdealGases.Common.Functions.dynamicViscosityLowPressure( state.T, fluidConstants[i].criticalTemperature, fluidConstants[i].molarMass, fluidConstants[i].criticalMolarVolume, fluidConstants[i].acentricFactor, fluidConstants[i].dipoleMoment); cp[i] := Modelica.Media.IdealGases.Common.Functions.cp_T( data[i],state.T); lambdaX[i] :=Modelica.Media.IdealGases.Common.Functions.thermalConductivityEstimate( Cp=cp[i], eta= eta[i], method=method,data=data[i]); end for; lambda := lowPressureThermalConductivity(massToMoleFractions(state.X, fluidConstants[:].molarMass), state.T, fluidConstants[:].criticalTemperature, fluidConstants[:].criticalPressure, fluidConstants[:].molarMass, lambdaX); end thermalConductivity; redeclare function extends isobaricExpansionCoefficient "Return isobaric expansion coefficient beta" algorithm beta := 1/state.T; end isobaricExpansionCoefficient; redeclare function extends isothermalCompressibility "Return isothermal compressibility factor" algorithm kappa := 1.0/state.p; end isothermalCompressibility; redeclare function extends density_derp_T "Return density derivative by pressure at constant temperature" algorithm ddpT := 1/(state.T*gasConstant(state)); end density_derp_T; redeclare function extends density_derT_p "Return density derivative by temperature at constant pressure" algorithm ddTp := -state.p/(state.T*state.T*gasConstant(state)); end density_derT_p; redeclare function density_derX "Return density derivative by mass fraction" extends Modelica.Icons.Function; input ThermodynamicState state "Thermodynamic state record"; output Density[nX] dddX "Derivative of density w.r.t. mass fraction"; algorithm dddX := {-state.p/(state.T*gasConstant(state))*molarMass(state)/data[ i].MM for i in 1:nX}; end density_derX; redeclare function extends molarMass "Return molar mass of mixture" algorithm MM := 1/sum(state.X[j]/data[j].MM for j in 1:size(state.X, 1)); end molarMass; function T_hX "Return temperature from specific enthalpy and mass fraction" extends Modelica.Icons.Function; input SpecificEnthalpy h "Specific enthalpy"; input MassFraction[nX] X "Mass fractions of composition"; input Boolean exclEnthForm=excludeEnthalpyOfFormation "If true, enthalpy of formation Hf is not included in specific enthalpy h"; input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy refChoice=referenceChoice "Choice of reference enthalpy"; input SpecificEnthalpy h_off=h_offset "User defined offset for reference enthalpy, if referenceChoice = UserDefined"; output Temperature T "Temperature"; protected function f_nonlinear "Solve h_TX(T,X) for T with given h" extends Modelica.Math.Nonlinear.Interfaces.partialScalarFunction; input SpecificEnthalpy h "Specific enthalpy"; input MassFraction[nX] X "Mass fractions of composition"; input Boolean exclEnthForm "If true, enthalpy of formation Hf is not included in specific enthalpy h"; input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy refChoice "Choice of reference enthalpy"; input SpecificEnthalpy h_off "User defined offset for reference enthalpy, if referenceChoice = UserDefined"; algorithm y := h_TX(T=u, X=X, exclEnthForm=exclEnthForm, refChoice=refChoice, h_off=h_off) - h; end f_nonlinear; algorithm T := Modelica.Math.Nonlinear.solveOneNonlinearEquation( function f_nonlinear(h=h, X=X, exclEnthForm=exclEnthForm, refChoice=refChoice, h_off=h_off), 200, 6000); end T_hX; function T_psX "Return temperature from pressure, specific entropy and mass fraction" extends Modelica.Icons.Function; input AbsolutePressure p "Pressure"; input SpecificEntropy s "Specific entropy"; input MassFraction[nX] X "Mass fractions of composition"; output Temperature T "Temperature"; protected function f_nonlinear "Solve specificEntropyOfpTX(p,T,X) for T with given s" extends Modelica.Math.Nonlinear.Interfaces.partialScalarFunction; input AbsolutePressure p "Pressure"; input SpecificEntropy s "Specific entropy"; input MassFraction[nX] X "Mass fractions of composition"; algorithm y := specificEntropyOfpTX(p=p, T=u, X=X) - s; end f_nonlinear; algorithm T := Modelica.Math.Nonlinear.solveOneNonlinearEquation( function f_nonlinear(p=p, s=s, X=X), 200, 6000); end T_psX; // redeclare function extends specificEnthalpy_psX // protected // Temperature T "Temperature"; // algorithm // T := temperature_psX(p,s,X); // h := specificEnthalpy_pTX(p,T,X); // end extends; // redeclare function extends density_phX // "Compute density from pressure, specific enthalpy and mass fraction" // protected // Temperature T "Temperature"; // SpecificHeatCapacity R "Gas constant"; // algorithm // T := temperature_phX(p,h,X); // R := if (not reducedX) then // sum(data[i].R*X[i] for i in 1:size(substanceNames, 1)) else // sum(data[i].R*X[i] for i in 1:size(substanceNames, 1)-1) + data[end].R*(1-sum(X[i])); // d := p/(R*T); // end density_phX; end CHPCombustionMixtureGasNasa;
Package with model for propylene glycol - water with constant properties
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package CHPCoolantPropyleneGlycolWater "Package with model for propylene glycol - water with constant properties" extends Modelica.Media.Interfaces.PartialSimpleMedium( mediumName="PropyleneGlycolWater(X_a = " + String(X_a) + ", property_T = " + String(property_T) + ")", final cp_const=specificHeatCapacityCp_TX_a(T=property_T, X_a=X_a), final cv_const=cp_const, final d_const=density_TX_a(T=property_T, X_a=X_a), final eta_const=dynamicViscosity_TX_a(T=property_T, X_a=X_a), final lambda_const=thermalConductivity_TX_a(T=property_T, X_a=X_a), a_const=1484, final T_min=fusionTemperature_TX_a(T=property_T, X_a=X_a), T_max=Modelica.Units.Conversions.from_degC(100), T0=273.15, MM_const=(X_a/simplePropyleneGlycolWaterConstants[1].molarMass + (1 - X_a)/ 0.018015268)^(-1), fluidConstants=simplePropyleneGlycolWaterConstants, p_default=300000, reference_p=300000, reference_T=273.15, reference_X={1}, AbsolutePressure(start=p_default), Temperature(start=T_default), Density(start=d_const)); constant Modelica.Units.SI.Temperature property_T "Temperature for evaluation of constant fluid properties"; constant Modelica.Units.SI.MassFraction X_a "Mass fraction of propylene glycol in water"; redeclare model BaseProperties "Base properties" Temperature T(stateSelect= if preferredMediumStates then StateSelect.prefer else StateSelect.default) "Temperature of medium"; InputAbsolutePressure p "Absolute pressure of medium"; InputMassFraction[nXi] Xi=fill(0, 0) "Structurally independent mass fractions"; InputSpecificEnthalpy h "Specific enthalpy of medium"; Modelica.Units.SI.SpecificInternalEnergy u "Specific internal energy of medium"; Modelica.Units.SI.Density d=d_const "Density of medium"; Modelica.Units.SI.MassFraction[nX] X={1} "Mass fractions (= (component mass)/total mass m_i/m)"; final Modelica.Units.SI.SpecificHeatCapacity R_s=0 "Gas constant (of mixture if applicable)"; final Modelica.Units.SI.MolarMass MM=MM_const "Molar mass (of mixture or single fluid)"; ThermodynamicState state "Thermodynamic state record for optional functions"; parameter Boolean preferredMediumStates=false "= true if StateSelect.prefer shall be used for the independent property variables of the medium" final parameter Boolean standardOrderComponents=true "If true, and reducedX = true, the last element of X will be computed from the other ones"; Modelica.Units.NonSI.Temperature_degC T_degC= Modelica.Units.Conversions.to_degC(T) "Temperature of medium in [degC]"; Modelica.Units.NonSI.Pressure_bar p_bar=Modelica.Units.Conversions.to_bar(p) "Absolute pressure of medium in [bar]"; // Local connector definition, used for equation balancing check connector InputAbsolutePressure = input Modelica.Units.SI.AbsolutePressure "Pressure as input signal connector"; connector InputSpecificEnthalpy = input Modelica.Units.SI.SpecificEnthalpy "Specific enthalpy as input signal connector"; connector InputMassFraction = input Modelica.Units.SI.MassFraction "Mass fraction as input signal connector"; equation assert(T >= T_min and T <= T_max, " Temperature T (= " + String(T) + " K) is not in the allowed range (" + String(T_min) + " K <= T <= " + String(T_max) + " K) required from medium model \"" + mediumName + "\". "); assert(X_a >= X_a_min and X_a <= X_a_max, " Mass fraction X_a (= " + String(X_a) + " ) is not in the allowed range (" + String(X_a_min) + " <= X_a <= " + String(X_a_max) + " ) required from medium model \"" + mediumName + "\". "); h = cp_const*(T-reference_T); u = h; state.T = T; state.p = p; end BaseProperties; protected constant Modelica.Units.SI.MassFraction X_a_min=0. "Minimum allowed mass fraction of propylene glycol in water"; constant Modelica.Units.SI.MassFraction X_a_max=0.6 "Maximum allowed mass fraction of propylene glycol in water"; // Fluid constants based on pure Propylene Glycol constant Modelica.Media.Interfaces.Types.Basic.FluidConstants[1] simplePropyleneGlycolWaterConstants( each chemicalFormula="C3H8O2", each structureFormula="CH3CH(OH)CH2OH", each casRegistryNumber="57-55-6", each iupacName="1,2-Propylene glycol", each molarMass=0.07609); // Coefficients for evaluation of physical properties constant AixLib.Media.Antifreeze.BaseClasses.PropertyCoefficients proCoe( X_a_ref=0.307031, T_ref=Modelica.Units.Conversions.from_degC(32.7083), nX_a=6, nT={4,4,4,3,2,1}, nTot=18, a_d={1.018e3,-5.406e-1,-2.666e-3,1.347e-5,7.604e-1,-9.450e-3,5.541e-5,-1.343e-7, -2.498e-3,2.700e-5,-4.018e-7,3.376e-9,-1.550e-4,2.829e-6,-7.175e-9,-1.131e-6, -2.221e-8,2.342e-8}, a_eta={6.837e-1,-3.045e-2,2.525e-4,-1.399e-6,3.328e-2,-3.984e-4,4.332e-6,-1.860e-8, 5.453e-5,-8.600e-8,-1.593e-8,-4.465e-11,-3.900e-6,1.054e-7,-1.589e-9,-1.587e-8, 4.475e-10,3.564e-9}, a_Tf={-1.325e1,-3.820e-5,7.865e-7,-1.733e-9,-6.631e-1,6.774e-6,-6.242e-8,-7.819e-10, -1.094e-2,5.332e-8,-4.169e-9,3.288e-11,-2.283e-4,-1.131e-8,1.918e-10,-3.409e-6, 8.035e-11,1.465e-8}, a_cp={3.882e3,2.699e0,-1.659e-3,-1.032e-5,-1.304e1,5.070e-2,-4.752e-5, 1.522e-6,-1.598e-1,9.534e-5,1.167e-5,-4.870e-8,3.539e-4,3.102e-5,-2.950e-7, 5.000e-5,-7.135e-7,-4.959e-7}, a_lambda={4.513e-1,7.955e-4,3.482e-8,-5.966e-9,-4.795e-3,-1.678e-5,8.941e-8, 1.493e-10,2.076e-5,1.563e-7,-4.615e-9,9.897e-12,-9.083e-8,-2.518e-9, 6.543e-11,-5.952e-10,-3.605e-11,2.104e-11}) "Coefficients for evaluation of thermo-physical properties"; replaceable function density_TX_a "Evaluate density of antifreeze-water mixture" extends Modelica.Icons.Function; input Modelica.Units.SI.Temperature T "Temperature of antifreeze-water mixture"; input Modelica.Units.SI.MassFraction X_a "Mass fraction of antifreeze"; output Modelica.Units.SI.Density d "Density of antifreeze-water mixture"; algorithm d :=polynomialProperty( X_a, T, proCoe.a_d) end density_TX_a; replaceable function dynamicViscosity_TX_a "Evaluate dynamic viscosity of antifreeze-water mixture" extends Modelica.Icons.Function; input Modelica.Units.SI.Temperature T "Temperature of antifreeze-water mixture"; input Modelica.Units.SI.MassFraction X_a "Mass fraction of antifreeze"; output Modelica.Units.SI.DynamicViscosity eta "Dynamic Viscosity of antifreeze-water mixture"; algorithm eta :=1e-3*exp(polynomialProperty( X_a, T, proCoe.a_eta)); end dynamicViscosity_TX_a; replaceable function fusionTemperature_TX_a "Evaluate temperature of fusion of antifreeze-water mixture" extends Modelica.Icons.Function; input Modelica.Units.SI.Temperature T "Temperature of antifreeze-water mixture"; input Modelica.Units.SI.MassFraction X_a "Mass fraction of antifreeze"; output Modelica.Units.SI.Temperature Tf "Temperature of fusion of antifreeze-water mixture"; algorithm Tf :=Modelica.Units.Conversions.from_degC(polynomialProperty( X_a, T, proCoe.a_Tf)); end fusionTemperature_TX_a; replaceable function polynomialProperty "Evaluates thermophysical property from 2-variable polynomial" extends Modelica.Icons.Function; input Real x "First independent variable"; input Real y "Second independent variable"; input Real a[sum(proCoe.nT)] "Polynomial coefficients"; output Real f "Value of thermophysical property"; protected Real dx; Real dy; Integer n; algorithm dx := 100*(x - proCoe.X_a_ref); dy := y - proCoe.T_ref; f := 0; n := 0; for i in 0:proCoe.nX_a - 1 loop for j in 0:proCoe.nT[i+1] - 1 loop n := n + 1; f := f + a[n]*dx^i*dy^j; end for; end for; end polynomialProperty; replaceable function specificHeatCapacityCp_TX_a "Evaluate specific heat capacity of antifreeze-water mixture" extends Modelica.Icons.Function; input Modelica.Units.SI.Temperature T "Temperature of antifreeze-water mixture"; input Modelica.Units.SI.MassFraction X_a "Mass fraction of antifreeze"; output Modelica.Units.SI.SpecificHeatCapacity cp "Specific heat capacity of antifreeze-water mixture"; algorithm cp :=polynomialProperty( X_a, T, proCoe.a_cp); end specificHeatCapacityCp_TX_a; replaceable function thermalConductivity_TX_a "Evaluate thermal conductivity of antifreeze-water mixture" extends Modelica.Icons.Function; input Modelica.Units.SI.Temperature T "Temperature of antifreeze-water mixture"; input Modelica.Units.SI.MassFraction X_a "Mass fraction of antifreeze"; output Modelica.Units.SI.ThermalConductivity lambda "Thermal conductivity of antifreeze-water mixture"; algorithm lambda :=polynomialProperty( X_a, T, proCoe.a_lambda); end thermalConductivity_TX_a; end CHPCoolantPropyleneGlycolWater;
Simple flue gas for overstoichiometric O2-fuel ratios
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package CHPFlueGasLambdaOnePlus "Simple flue gas for overstoichiometric O2-fuel ratios" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CHPCombustionMixtureGasNasa( mediumName="FlueGasLambdaPlus", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.O2, Modelica.Media.IdealGases.Common.SingleGasesData.H2O,Modelica.Media.IdealGases.Common.SingleGasesData.CO2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.O2, Modelica.Media.IdealGases.Common.FluidData.H2O,Modelica.Media.IdealGases.Common.FluidData.CO2}, substanceNames={"Nitrogen","Oxygen","Water","Carbondioxide"}, reference_X={0.768,0.232,0.0,0.0}); end CHPFlueGasLambdaOnePlus;
Air as mixture of N2 and O2
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package EngineCombustionAir "Air as mixture of N2 and O2" extends Modelica.Media.IdealGases.Common.MixtureGasNasa( mediumName="CombustionAirN2O2", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.O2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.O2}, substanceNames={"Nitrogen","Oxygen"}, reference_X = {0.768, 0.232}); //!!For the script calculating the combustion: Nitrogen has to be at first place for the composition of the fuel!!" constant ThermodynamicState stateAir = setState_pTX(reference_p, reference_T, reference_X); constant MolarMass MM = 1/sum(stateAir.X[j]/data[j].MM for j in 1:size(stateAir.X, 1)); constant MolarMass MMX[:] = data[:].MM; constant Real X[:] = stateAir.X; constant MoleFraction moleFractions_Air[:] = massToMoleFractions(X, MMX); end EngineCombustionAir;
Simple diesel fuel for CHP-engine combustion
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package LiquidFuel_Diesel "Simple diesel fuel for CHP-engine combustion" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CHPCombustionMixtureGasNasa( mediumName="Just dummy data and no use for calculation", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.CH4, Modelica.Media.IdealGases.Common.SingleGasesData.C2H4,Modelica.Media.IdealGases.Common.SingleGasesData.C2H6, Modelica.Media.IdealGases.Common.SingleGasesData.C3H8,Modelica.Media.IdealGases.Common.SingleGasesData.C4H10_n_butane, Modelica.Media.IdealGases.Common.SingleGasesData.C5H12_n_pentane, Modelica.Media.IdealGases.Common.SingleGasesData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.SingleGasesData.CO2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.CH4, Modelica.Media.IdealGases.Common.FluidData.C2H4,Modelica.Media.IdealGases.Common.FluidData.C2H6, Modelica.Media.IdealGases.Common.FluidData.C3H8,Modelica.Media.IdealGases.Common.FluidData.C4H10_n_butane, Modelica.Media.IdealGases.Common.FluidData.C5H12_n_pentane,Modelica.Media.IdealGases.Common.FluidData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.FluidData.CO2}, substanceNames={"Nitrogen","Methane","Ethene","Ethane","Propane", "n-Butane","n-Pentane","n-Hexane","Carbondioxide"}); constant AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord Fuel=DieselFuel() "Needed fuel data for combustion calculations" import Modelica.Units.SI.*; constant Boolean isGas = Fuel.isGasoline "True = Gasoline fuel, False = Liquid fuel"; constant MolarMass MM = Fuel.MM_liq "Molar mass of the fuel"; constant SpecificEnergy H_U = Fuel.H_U "Calorific Value of the fuel gas"; constant Real l_min = L_st*MM/0.02885; constant Real L_st = 4.31034*(2.664*Fuel.Xi_liq[1]+7.937*Fuel.Xi_liq[2]-Fuel.Xi_liq[3]) "Stoichiometric air consumption"; //Unused information for simulation stability constant MoleFraction moleFractions_Gas[:] = Fuel.Xi_mole; record DieselFuel "Data record for simple diesel fuel" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord( fuelType = "Simple diesel fuel", isGasoline = false, H_U = 42800000, MM_liq = 0.19, Xi_liq = {0.86,0.14,0.0}); end DieselFuel; end LiquidFuel_Diesel;
Simple LPG fuel for CHP-engine combustion
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package LiquidFuel_LPG "Simple LPG fuel for CHP-engine combustion" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CHPCombustionMixtureGasNasa( mediumName="Just dummy data and no use for calculation", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.CH4, Modelica.Media.IdealGases.Common.SingleGasesData.C2H4,Modelica.Media.IdealGases.Common.SingleGasesData.C2H6, Modelica.Media.IdealGases.Common.SingleGasesData.C3H8,Modelica.Media.IdealGases.Common.SingleGasesData.C4H10_n_butane, Modelica.Media.IdealGases.Common.SingleGasesData.C5H12_n_pentane, Modelica.Media.IdealGases.Common.SingleGasesData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.SingleGasesData.CO2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.CH4, Modelica.Media.IdealGases.Common.FluidData.C2H4,Modelica.Media.IdealGases.Common.FluidData.C2H6, Modelica.Media.IdealGases.Common.FluidData.C3H8,Modelica.Media.IdealGases.Common.FluidData.C4H10_n_butane, Modelica.Media.IdealGases.Common.FluidData.C5H12_n_pentane,Modelica.Media.IdealGases.Common.FluidData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.FluidData.CO2}, substanceNames={"Nitrogen","Methane","Ethene","Ethane","Propane", "n-Butane","n-Pentane","n-Hexane","Carbondioxide"}); constant AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord Fuel=LPGFuel() "Needed fuel data for combustion calculations" import Modelica.Units.SI.*; constant Boolean isGas = Fuel.isGasoline "True = Gasoline fuel, False = Liquid fuel"; constant MolarMass MM = Fuel.MM_liq "Molar mass of the fuel"; constant SpecificEnergy H_U = Fuel.H_U "Calorific Value of the fuel gas"; constant Real l_min = L_st*MM/0.02885; constant Real L_st = 4.31034*(2.664*Fuel.Xi_liq[1]+7.937*Fuel.Xi_liq[2]-Fuel.Xi_liq[3]) "Stoichiometric air consumption"; //Unused information for simulation stability constant MoleFraction moleFractions_Gas[:] = Fuel.Xi_mole; record LPGFuel "Data record for simple LPG fuel" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord( fuelType = "Simple LPG fuel", isGasoline = false, H_U = 45330000, MM_liq = 0.048, Xi_liq = {0.82,0.18,0.00}); end LPGFuel; end LiquidFuel_LPG;
Simple petrol fuel for CHP-engine combustion
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package LiquidFuel_Petrol "Simple petrol fuel for CHP-engine combustion" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CHPCombustionMixtureGasNasa( mediumName="Just dummy data and no use for calculation", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.CH4, Modelica.Media.IdealGases.Common.SingleGasesData.C2H4,Modelica.Media.IdealGases.Common.SingleGasesData.C2H6, Modelica.Media.IdealGases.Common.SingleGasesData.C3H8,Modelica.Media.IdealGases.Common.SingleGasesData.C4H10_n_butane, Modelica.Media.IdealGases.Common.SingleGasesData.C5H12_n_pentane, Modelica.Media.IdealGases.Common.SingleGasesData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.SingleGasesData.CO2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.CH4, Modelica.Media.IdealGases.Common.FluidData.C2H4,Modelica.Media.IdealGases.Common.FluidData.C2H6, Modelica.Media.IdealGases.Common.FluidData.C3H8,Modelica.Media.IdealGases.Common.FluidData.C4H10_n_butane, Modelica.Media.IdealGases.Common.FluidData.C5H12_n_pentane,Modelica.Media.IdealGases.Common.FluidData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.FluidData.CO2}, substanceNames={"Nitrogen","Methane","Ethene","Ethane","Propane", "n-Butane","n-Pentane","n-Hexane","Carbondioxide"}); constant AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord Fuel=PetrolFuel() "Needed fuel data for combustion calculations" import Modelica.Units.SI.*; constant Boolean isGas = Fuel.isGasoline "True = Gasoline fuel, False = Liquid fuel"; constant MolarMass MM = Fuel.MM_liq "Molar mass of the fuel"; constant SpecificEnergy H_U = Fuel.H_U "Calorific Value of the fuel gas"; constant Real l_min = L_st*MM/0.02885; constant Real L_st = 4.31034*(2.664*Fuel.Xi_liq[1]+7.937*Fuel.Xi_liq[2]-Fuel.Xi_liq[3]) "Stoichiometric air consumption"; //Unused information for simulation stability constant MoleFraction moleFractions_Gas[:] = Fuel.Xi_mole; record PetrolFuel "Data record for simple petrol fuel" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord( fuelType = "Simple petrol fuel", isGasoline = false, H_U = 42000000, MM_liq = 0.098, Xi_liq = {0.84,0.14,0.02}); end PetrolFuel; end LiquidFuel_Petrol;
Simple natural gas mixture for CHP-engine combustion
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package NaturalGasMixture_GeneralType "Simple natural gas mixture for CHP-engine combustion" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CHPCombustionMixtureGasNasa( mediumName="NaturalGasMixture_SelectableVolumetricProportions", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.CH4, Modelica.Media.IdealGases.Common.SingleGasesData.C2H4,Modelica.Media.IdealGases.Common.SingleGasesData.C2H6, Modelica.Media.IdealGases.Common.SingleGasesData.C3H8,Modelica.Media.IdealGases.Common.SingleGasesData.C4H10_n_butane, Modelica.Media.IdealGases.Common.SingleGasesData.C5H12_n_pentane, Modelica.Media.IdealGases.Common.SingleGasesData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.SingleGasesData.CO2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.CH4, Modelica.Media.IdealGases.Common.FluidData.C2H4,Modelica.Media.IdealGases.Common.FluidData.C2H6, Modelica.Media.IdealGases.Common.FluidData.C3H8,Modelica.Media.IdealGases.Common.FluidData.C4H10_n_butane, Modelica.Media.IdealGases.Common.FluidData.C5H12_n_pentane,Modelica.Media.IdealGases.Common.FluidData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.FluidData.CO2}, substanceNames={"Nitrogen","Methane","Ethene","Ethane","Propane", "n-Butane","n-Pentane","n-Hexane","Carbondioxide"}); constant AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord Fuel=NaturalGas_GeneralDefinition() "Needed natural gas data for calculations, manual redefinition of volumetric proportions of the gas components (Xi_mole) required (default:{1/9,1/9,...})!" import Modelica.Units.SI.*; constant Boolean isGas = Fuel.isGasoline "True = Gasoline fuel, False = Liquid fuel"; constant MoleFraction moleFractions_Gas[:] = Fuel.Xi_mole; constant MolarMass MM = sum(Fuel.Xi_mole[i]*Fuel.MMi[i] for i in 1:size(Fuel.MMi, 1)) "Molar mass of natural gas type from its composition"; constant MassFraction massFractions_Gas[:] = Modelica.Media.Interfaces.PartialMixtureMedium.moleToMassFractions(Fuel.Xi_mole, Fuel.MMi); constant SpecificEnergy H_U = sum(massFractions_Gas[i]*Fuel.H_Ui[i] for i in 1:size(Fuel.MMi, 1)) "Calorific Value of the fuel gas"; constant Real l_min = sum(Fuel.Xi_mole[i]*Fuel.nue_min[i] for i in 1:size(Fuel.MMi, 1))/0.21; constant Real L_st = l_min*0.02885/MM "Stoichiometric air consumption"; record NaturalGas_GeneralDefinition extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord( fuelType="GeneralTypeForRedefinition", isGasoline = true, Xi_mole={1/9,1/9,1/9,1/9, 1/9,1/9,1/9,1/9,1/9}); end NaturalGas_GeneralDefinition; end NaturalGasMixture_GeneralType;
Simple natural gas mixture (type Aachen) for CHP-engine combustion
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package NaturalGasMixture_TypeAachen "Simple natural gas mixture (type Aachen) for CHP-engine combustion" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CHPCombustionMixtureGasNasa( mediumName="NaturalGasMixtureForAachen", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.CH4, Modelica.Media.IdealGases.Common.SingleGasesData.C2H4,Modelica.Media.IdealGases.Common.SingleGasesData.C2H6, Modelica.Media.IdealGases.Common.SingleGasesData.C3H8,Modelica.Media.IdealGases.Common.SingleGasesData.C4H10_n_butane, Modelica.Media.IdealGases.Common.SingleGasesData.C5H12_n_pentane, Modelica.Media.IdealGases.Common.SingleGasesData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.SingleGasesData.CO2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.CH4, Modelica.Media.IdealGases.Common.FluidData.C2H4,Modelica.Media.IdealGases.Common.FluidData.C2H6, Modelica.Media.IdealGases.Common.FluidData.C3H8,Modelica.Media.IdealGases.Common.FluidData.C4H10_n_butane, Modelica.Media.IdealGases.Common.FluidData.C5H12_n_pentane,Modelica.Media.IdealGases.Common.FluidData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.FluidData.CO2}, substanceNames={"Nitrogen","Methane","Ethene","Ethane","Propane", "n-Butane","n-Pentane","n-Hexane","Carbondioxide"}); constant AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord Fuel=NaturalGasTypeAachen() "Needed natural gas data for calculations" import Modelica.Units.SI.*; constant Boolean isGas = Fuel.isGasoline "True = Gasoline fuel, False = Liquid fuel"; constant MoleFraction moleFractions_Gas[:] = Fuel.Xi_mole; constant MolarMass MM = sum(Fuel.Xi_mole[i]*Fuel.MMi[i] for i in 1:size(Fuel.MMi, 1)) "Molar mass of natural gas type from its composition"; constant MassFraction massFractions_Gas[:] = Modelica.Media.Interfaces.PartialMixtureMedium.moleToMassFractions(Fuel.Xi_mole, Fuel.MMi); constant SpecificEnergy H_U = sum(massFractions_Gas[i]*Fuel.H_Ui[i] for i in 1:size(Fuel.MMi, 1)) "Calorific Value of the fuel gas"; constant Real l_min = sum(Fuel.Xi_mole[i]*Fuel.nue_min[i] for i in 1:size(Fuel.MMi, 1))/0.21; constant Real L_st = l_min*0.02885/MM "Stoichiometric air consumption"; record NaturalGasTypeAachen extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord( fuelType="TypeAachen", isGasoline = true, Xi_mole={0.0089,0.9255,0,0.045,0.0063,0.0019,0.0004,0.0001,0.0119}); end NaturalGasTypeAachen; end NaturalGasMixture_TypeAachen;
Simple natural gas mixture (type H) for CHP-engine combustion
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package NaturalGasMixture_TypeH "Simple natural gas mixture (type H) for CHP-engine combustion" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CHPCombustionMixtureGasNasa( mediumName="NaturalGasMixtureTypeH", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.CH4, Modelica.Media.IdealGases.Common.SingleGasesData.C2H4,Modelica.Media.IdealGases.Common.SingleGasesData.C2H6, Modelica.Media.IdealGases.Common.SingleGasesData.C3H8,Modelica.Media.IdealGases.Common.SingleGasesData.C4H10_n_butane, Modelica.Media.IdealGases.Common.SingleGasesData.C5H12_n_pentane, Modelica.Media.IdealGases.Common.SingleGasesData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.SingleGasesData.CO2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.CH4, Modelica.Media.IdealGases.Common.FluidData.C2H4,Modelica.Media.IdealGases.Common.FluidData.C2H6, Modelica.Media.IdealGases.Common.FluidData.C3H8,Modelica.Media.IdealGases.Common.FluidData.C4H10_n_butane, Modelica.Media.IdealGases.Common.FluidData.C5H12_n_pentane,Modelica.Media.IdealGases.Common.FluidData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.FluidData.CO2}, substanceNames={"Nitrogen","Methane","Ethene","Ethane","Propane", "n-Butane","n-Pentane","n-Hexane","Carbondioxide"}); constant AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord Fuel=NaturalGasTypeH() "Needed natural gas data for calculations" import Modelica.Units.SI.*; constant Boolean isGas = Fuel.isGasoline "True = Gasoline fuel, False = Liquid fuel"; constant MoleFraction moleFractions_Gas[:] = Fuel.Xi_mole; constant MolarMass MM = sum(Fuel.Xi_mole[i]*Fuel.MMi[i] for i in 1:size(Fuel.MMi, 1)) "Molar mass of natural gas type from its composition"; constant MassFraction massFractions_Gas[:] = Modelica.Media.Interfaces.PartialMixtureMedium.moleToMassFractions(Fuel.Xi_mole, Fuel.MMi); constant SpecificEnergy H_U = sum(massFractions_Gas[i]*Fuel.H_Ui[i] for i in 1:size(Fuel.MMi, 1)) "Calorific Value of the fuel gas"; constant Real l_min = sum(Fuel.Xi_mole[i]*Fuel.nue_min[i] for i in 1:size(Fuel.MMi, 1))/0.21; constant Real L_st = l_min*0.02885/MM "Stoichiometric air consumption"; record NaturalGasTypeH extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord( fuelType="TypeH", isGasoline = true, Xi_mole={0.007,0.854,0,0.08,0.029,0.01,0,0, 0.02}); end NaturalGasTypeH; end NaturalGasMixture_TypeH;
Simple natural gas mixture (type L) for CHP-engine combustion
within AixLib.DataBase.CHP.ModularCHPEngineMedia; package NaturalGasMixture_TypeL "Simple natural gas mixture (type L) for CHP-engine combustion" extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CHPCombustionMixtureGasNasa( mediumName="NaturalGasMixtureTypeL", data={Modelica.Media.IdealGases.Common.SingleGasesData.N2,Modelica.Media.IdealGases.Common.SingleGasesData.CH4, Modelica.Media.IdealGases.Common.SingleGasesData.C2H4,Modelica.Media.IdealGases.Common.SingleGasesData.C2H6, Modelica.Media.IdealGases.Common.SingleGasesData.C3H8,Modelica.Media.IdealGases.Common.SingleGasesData.C4H10_n_butane, Modelica.Media.IdealGases.Common.SingleGasesData.C5H12_n_pentane, Modelica.Media.IdealGases.Common.SingleGasesData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.SingleGasesData.CO2}, fluidConstants={Modelica.Media.IdealGases.Common.FluidData.N2,Modelica.Media.IdealGases.Common.FluidData.CH4, Modelica.Media.IdealGases.Common.FluidData.C2H4,Modelica.Media.IdealGases.Common.FluidData.C2H6, Modelica.Media.IdealGases.Common.FluidData.C3H8,Modelica.Media.IdealGases.Common.FluidData.C4H10_n_butane, Modelica.Media.IdealGases.Common.FluidData.C5H12_n_pentane,Modelica.Media.IdealGases.Common.FluidData.C6H14_n_hexane, Modelica.Media.IdealGases.Common.FluidData.CO2}, substanceNames={"Nitrogen","Methane","Ethene","Ethane","Propane", "n-Butane","n-Pentane","n-Hexane","Carbondioxide"}); constant AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord Fuel=NaturalGasTypeL() "Needed natural gas data for calculations" import Modelica.Units.SI.*; constant Boolean isGas = Fuel.isGasoline "True = Gasoline fuel, False = Liquid fuel"; constant MoleFraction moleFractions_Gas[:] = Fuel.Xi_mole; constant MolarMass MM = sum(Fuel.Xi_mole[i]*Fuel.MMi[i] for i in 1:size(Fuel.MMi, 1)) "Molar mass of natural gas type from its composition"; constant MassFraction massFractions_Gas[:] = Modelica.Media.Interfaces.PartialMixtureMedium.moleToMassFractions(Fuel.Xi_mole, Fuel.MMi); constant SpecificEnergy H_U = sum(massFractions_Gas[i]*Fuel.H_Ui[i] for i in 1:size(Fuel.MMi, 1)) "Calorific Value of the fuel gas"; constant Real l_min = sum(Fuel.Xi_mole[i]*Fuel.nue_min[i] for i in 1:size(Fuel.MMi, 1))/0.21; constant Real L_st = l_min*0.02885/MM "Stoichiometric air consumption"; record NaturalGasTypeL extends AixLib.DataBase.CHP.ModularCHPEngineMedia.CombustionEngineFuelDataBaseRecord( fuelType="TypeL", isGasoline = true, Xi_mole={0.126,0.82,0,0.033,0.006,0.003,0,0, 0.012}); end NaturalGasTypeL; end NaturalGasMixture_TypeL;
Package that provides records describing media properties
within AixLib.DataBase; package Media "Package that provides records describing media properties" extends Modelica.Icons.Package; end Media;
Package that provides records describing properties of different refrigerants
within AixLib.DataBase.Media; package Refrigerants "Package that provides records describing properties of different refrigerants" extends Modelica.Icons.Package; end Refrigerants;
Base data definition for fitting coefficients of thermodynamic state properties. This record is a base data definition for fitting coefficients of the thermodynamic state properties depending on two independent state variables. These thermodynamic state properties are given as fitted formulas in order to reduce the overall computing time of the refrigerant model. Therefore, the fitting approach is based on \"Fast_Propane\" model developed by Sangi et al..
within AixLib.DataBase.Media.Refrigerants; record ThermodynamicStatePropertiesBaseDataDefinition "Base data definition for fitting coefficients of thermodynamic state properties" extends Modelica.Icons.Record; parameter String name "Short description of the record" parameter Integer T_phNt[:] "Polynomial order for p (SC) | Polynomial order for h (SC) | Total number of terms (SC) | Polynomial order for p (SH) | Polynomial order for h (SH) | Total number of terms (SH)" parameter Real Tl_phA[:] "Coefficients a for supercooled regime" parameter Real Tl_phB[:] "Coefficients b for supercooled regime" parameter Real Tl_phC[:] "Coefficients c for supercooled regime" parameter Real Tl_phD[:] "Coefficient d for supercooled regime" parameter Real Tv_phA[:] "Coefficients a for superheated regime" parameter Real Tv_phB[:] "Coefficients b for superheated regime" parameter Real Tv_phC[:] "Coefficients c for superheated regime" parameter Real Tv_phD[:] "Coefficient d for superheated regime" parameter Real T_phIO[:] "Mean SC p | Std SC p | Mean SC h | Std SC h | Mean SC T | Std SC T | Mean SH p | Std SH p | Mean SH h | Std SH h | Mean SH T | Std SH T" parameter Integer T_psNt[:] "Polynomial order for p (SC) | Polynomial order for s (SC) | Total number of terms (SC) | Polynomial order for p (SH) | Polynomial order for s (SH) | Total number of terms (SH)" parameter Real Tl_psA[:] "Coefficients a for supercooled regime" parameter Real Tl_psB[:] "Coefficients b for supercooled regime" parameter Real Tl_psC[:] "Coefficients c for supercooled regime" parameter Real Tl_psD[:] "Coefficient d for supercooled regime" parameter Real Tv_psA[:] "Coefficients a for superheated regime" parameter Real Tv_psB[:] "Coefficients b for superheated regime" parameter Real Tv_psC[:] "Coefficients c for superheated regime" parameter Real Tv_psD[:] "Coefficient d for superheated regime" parameter Real T_psIO[:] "Mean SC p | Std SC p | Mean SC s | Std SC s | Mean SC T | Std SC T | Mean SH p | Std SH p | Mean SH s | Std SH s | Mean SH T | Std SH T" parameter Integer d_pTNt[:] "Polynomial order for p (SC) | Polynomial order for T (SC) | Total number of terms (SC) | Polynomial order for p (SH) | Polynomial order for T (SH) | Total number of terms (SH)" parameter Real dl_pTA[:] "Coefficients a for supercooled regime" parameter Real dl_pTB[:] "Coefficients b for supercooled regime" parameter Real dl_pTC[:] "Coefficients c for supercooled regime" parameter Real dl_pTD[:] "Coefficient d for supercooled regime" parameter Real dv_pTA[:] "Coefficients a for superheated regime" parameter Real dv_pTB[:] "Coefficients b for superheated regime" parameter Real dv_pTC[:] "Coefficients c for superheated regime" parameter Real dv_pTD[:] "Coefficient d for superheated regime" parameter Real d_pTIO[:] "Mean SC p | Std SC p | Mean SC T | Std SC T | Mean SC d | Std SC d | Mean SH p | Std SH p | Mean SH T | Std SH T | Mean SH d | Std SH d" end ThermodynamicStatePropertiesBaseDataDefinition;
Record with fitting coefficients calculated for first implementation. In this record, fitting coefficients are provided for thermodynamic properties at bubble and dew line. For detailed information of these thermodynamic properties as well as the fitting coefficients in general, please checkout <a href= \"modelica://AixLib.DataBase.Media.Refrigerants.BubbleDewStatePropertiesBaseDataDefinition\"> AixLib.DataBase.Media.Refrigerants.BubbleDewStatePropertiesBaseDataDefinition</a> . The fitting coefficients are used in a hybrid refrigerant model provided in <a href= \"modelica://AixLib.Media.Refrigerants\">AixLib.Media.Refrigerants</a>. For detailed information, please checkout <a href= \"modelica://AixLib.Media.Refrigerants.Interfaces.TemplateHybridTwoPhaseMediumRecord\"> AixLib.Media.Refrigerants.Interfaces.TemplateHybridTwoPhaseMediumRecord</a>.
within AixLib.DataBase.Media.Refrigerants.R134a; record BDSP_IIR_P1_395_T233_370 "Record with fitting coefficients calculated for first implementation" extends AixLib.DataBase.Media.Refrigerants.BubbleDewStatePropertiesBaseDataDefinition( name="Coefficients taken from Engelpracht", psat_Nt=5, psat_N={-5.29535582243675, -5.15024230998653, -3.13553371894143, 3.81009392578704, -10.0339381768489}, psat_E={0.927890501793078, 0.927889861253321, 3.24457658937591, 0.866053953377016, 7.91909121618172}, Tsat_Nt=46, Tsat_N={1.54078824620738e-07, -2.51410678214919e-06, 1.45676923487723e-05, -2.34880154091625e-05, -8.8004505404823e-05, 0.000263544471499524, 0.000812655495029447, -0.00387216171551954, 0.00144605394607974, 0.0132879323848205, -0.0224369802824247, 0.0285800338394785, -0.0221624492210123, -0.203868199876426, 0.350873407219832, -0.56578842983819, 12.0552196723002, -67.2418238751773, 192.835068220202, -292.332077985936, -66.889680648556, 1354.35656921788, -2373.87104764859, -153.61878036749, 5736.13316518914, -5643.63993911996, -4453.93622361223, 10945.3908704179, -1564.02920810349, -9868.33934727912, 5640.99015202781, 4762.95378316372, -4812.32805012381, -1053.97842181797, 2199.05007804956, -55.2137430573454, -591.55848346164, 83.7642169620632, 95.5617640252349, -20.8432510011223, -4.89010119898524, -2.89915392364256, 7.26052113404336, -12.7560329244594, 36.1617450994282, 318.322815465239}, Tsat_IO={1173800.40711465, 1099321.32004152, 0, 1}, dl_Nt=51, dl_N={-0.00352419814120293, -0.0051580379775832, 0.0965814503072823, 0.144857990589315, -1.16726237424692, -1.82395288996062, 7.97544046479868, 13.4009909278429, -31.7450644002113, -61.8153512769025, 56.8020521069703, 171.535249548539, 100.352770722198, -181.683550900637, -859.48468801174, -610.226996198121, 1761.84707403932, 3146.45218750924, 2353.3594353821, -5996.13044335048, -25581.0559142409, 1308.41019778136, 85905.3178848696, 23570.9797554869, -184363.294029955, -72757.9476832706, 285747.546166906, 127830.260345799, -333529.603869706, -155973.130039214, 297641.54611928, 139542.906755691, -203413.444060992, -92974.0053711724, 105653.494874395, 46017.3538315087, -41045.0235439939, -16664.3675714077, 11627.7646496055, 4294.75635803336, -2313.40684857554, -754.303131177625, 305.562374521598, 84.2002201352372, -25.0453395096642, -6.45648421752394, -1.69200599769564, -7.63593969610268, -23.3610969355503, -159.727367002064, 1196.56605282943}, dl_IO={303.15, 40.457817538765, 0, 1}, dv_Nt=51, dv_N={0.00366375716685372, 0.0053538769982365, -0.100436390057465, -0.150363600886821, 1.21437618965309, 1.8933138763485, -8.30322148217756, -13.9104041772412, 33.0986104378207, 64.1589511321415, -59.5651148209404, -177.972153492235, -102.486577824078, 187.987443782542, 889.436057503728, 636.298667648207, -1828.93235899714, -3275.90468897169, -2428.03282530501, 6249.17042512684, 26505.848889568, -1406.59981060971, -89079.8043571255, -24396.147383262, 191251.949508916, 75446.4637710722, -296500.979192201, -132629.575901049, 346146.181681826, 161873.719238785, -308945.463671975, -144845.545577487, 211163.498509716, 96517.4282752838, -109689.578460464, -47774.8025384588, 42616.5117812756, 17301.75826985, -12073.8168754595, -4459.21050037244, 2402.29470924636, 783.202988492362, -317.322783612849, -87.4191158401829, 26.0367018503651, 6.71078750827968, 1.54774937069529, 7.45650506262154, 22.8841379731046, 44.9601731987046, 37.7920259477397}, dv_IO={303.15, 40.457817538765, 0, 1}, hl_Nt=46, hl_N={0.000184961183468728, -0.0030179158953129, 0.0174899646269803, -0.0282560159402985, -0.105207275191974, 0.315194701935429, 0.974770473817121, -4.63930659057721, 1.7383261464603, 15.8672736904888, -26.8117923739426, 34.4573923119077, -27.0840074954698, -243.891647476847, 418.633103433743, -675.810930446719, 14451.1767301123, -80546.6165653585, 230931.822047154, -350354.845541073, -79149.6184000711, 1621602.99991981, -2846012.05183644, -179385.075668919, 6871922.20419042, -6768870.58089433, -5330455.34053076, 13118286.5709535, -1881959.25885099, -11823004.0525545, 6763949.30238296, 5704097.14300617, -5767487.65638426, -1261137.45165689, 2634880.09022467, -66756.3566692043, -708605.95775703, 100403.959019043, 114542.458212433, -25097.6059600101, -5668.24234828214, -3713.55063995873, 9323.02142560806, -15530.9613962048, 55045.0924054574, 264165.769863097}, hl_IO={1173800.40711509, 1099321.32004199, 0, 1}, hv_Nt=20, hv_N={0.000146114755723916, -0.0019919160005003, 0.0109988406358016, -0.0311947330620793, 0.0499552429639684, -0.0665601068588061, 0.147469798302808, -0.277432585048023, 0.191088567972776, 0.165337515949091, -0.308799991735697, 0.0767890190523656, 0.096151215082195, -0.130568776308635, 0.206740480104201, -0.245243281452568, 0.246372277496221, -0.550946254566628, 0.847986730088046, 0.716885920461567}, hv_IO={1173800.40711465, 1099321.32004152, 409576.287023374, 16957.9188539679}, sl_Nt=46, sl_N={9.28755787765749e-07, -1.5150913803503e-05, 8.77316967122217e-05, -0.000140844251958289, -0.000533996613727705, 0.00159622206078928, 0.00490073872961946, -0.023370265008107, 0.00863828261595032, 0.0805687876822656, -0.135254807011812, 0.168969874580144, -0.128293354719008, -1.22607691354417, 2.10119705402605, -3.38412616555908, 72.6461571722029, -405.466030416176, 1161.67231329233, -1754.92919607002, -420.688351064553, 8167.35604991928, -14253.0603537498, -1011.92405629391, 34546.516132289, -33831.6703317772, -26951.4046285962, 65805.1780388705, -9213.65456150566, -59432.1771053041, 33811.7330015974, 28745.7895776656, -28912.1120633901, -6394.80667362487, 13226.7122676853, -313.368646868979, -3562.0724687124, 501.449619305607, 574.322894904955, -123.098484249474, -32.2623996097734, -13.0844367240743, 36.7035466683415, -58.7522396485261, 169.757060451784, 1214.3997345905}, sl_IO={1173800.40711509, 1099321.32004199, 0, 1}, sv_Nt=46, sv_N={-4.54727474435905e-07, 7.41017757537388e-06, -4.27648894607494e-05, 6.70715032108244e-05, 0.000270926474744898, -0.000802286705973783, -0.00241040447476498, 0.0115494481330778, -0.00405980844377531, -0.0407765869650566, 0.0666478893759725, -0.0749446096999996, 0.049805775690857, 0.596694219851247, -1.00920319342854, 1.6208955320976, -35.6318873943596, 199.561613366245, -569.493750614901, 846.143321140556, 247.736627905861, -4022.96989824516, 6873.61207413149, 697.553504737119, -16906.205356694, 16191.4119093199, 13480.1370544075, -31938.750447298, 4039.97184361304, 29080.9454888102, -16180.5286901209, -14203.8869477235, 13990.5043701977, 3235.84611771843, -6435.0171344795, 110.433794468402, 1741.94692574345, -238.319982484079, -278.8342183201, 55.3988893994062, 21.1056166847968, -1.4710810714657, -5.50913731662347, 0.564362494967034, -13.7886033447905, 1709.22837116714}, sv_IO={1173800.40711465, 1099321.32004152, 0, 1}); end BDSP_IIR_P1_395_T233_370;
Record with fitting coefficients calculated for first implementation. In this record, fitting coefficients are provided for the Helmholtz equation of state (EoS). For detailed information of the EoS as well as the fitting coefficients, please checkout <a href= \"modelica://AixLib.DataBase.Media.Refrigerants.HelmholtzEquationOfStateBaseDateDefinition\"> AixLib.DataBase.Media.Refrigerants.HelmholtzEquationOfStateBaseDateDefinition</a> . The fitting coefficients are used in a hybrid refrigerant model provided in <a href= \"modelica://AixLib.Media.Refrigerants\">AixLib.Media.Refrigerants</a>. For detailed information, please checkout <a href= \"modelica://AixLib.Media.Refrigerants.Interfaces.TemplateHybridTwoPhaseMediumRecord\"> AixLib.Media.Refrigerants.Interfaces.TemplateHybridTwoPhaseMediumRecord</a>.
within AixLib.DataBase.Media.Refrigerants.R134a; record EoS_IIR_P1_395_T233_370 "Record with fitting coefficients calculated for first implementation" extends AixLib.DataBase.Media.Refrigerants.HelmholtzEquationOfStateBaseDateDefinition( name="Coefficients taken from Tillner-Roth and Baehr, An International Standard Formulation for the thermodynamic Properties of 1,1,1,2‐Tetrafluoroethane (HFC‐134a) for Temperatures from 170 K to 455 K and Pressures up to 70 MPa", f_IdgNl=1, f_IdgL1={-1.629789}, f_IdgL2={1}, f_IdgNp=4, f_IdgP1={-1.02084672674949,9.04757355104757,-9.723916,-3.92717}, f_IdgP2={0,1,-0.5,-0.75}, f_IdgNe=0, f_IdgE1={0}, f_IdgE2={0}, f_ResNp=8, f_ResP1={0.05586817,0.498223,0.02458698,0.0008570145,0.0004788584, -1.800808,0.2671641,-0.04781652}, f_ResP2={2,1,3,6,6,1,1,2}, f_ResP3={-0.5,0,0,0,1.5,1.5,2,2}, f_ResNb=13, f_ResB1={0.01423987,0.3324062,-0.007485907,0.0001017263,-0.5184567, -0.08692288,0.2057144,-0.005000457,0.0004603262,-0.003497836, 0.006995038,-0.01452184,-0.0001285458}, f_ResB2={5,2,2,4,1,4,1,2,4,1,5,3,10}, f_ResB3={1,3,5,1,5,5,6,10,10,10,18,22,50}, f_ResB4={1,1,1,2,2,2,2,2,2,3,3,3,4}, f_ResNG=0, f_ResG1={0}, f_ResG2={0}, f_ResG3={0}, f_ResG4={0}, f_ResG5={0}, f_ResG6={0}, f_ResG7={0}); end EoS_IIR_P1_395_T233_370;
Package provides records for R134a
within AixLib.DataBase.Media.Refrigerants; package R134a "Package provides records for R134a" extends Modelica.Icons.VariantsPackage; end R134a;
Record with fitting coefficients calculated for first implementation. In this record, fitting coefficients are provided for thermodynamic properties calculated from two independent state variables. For detailed information of these thermodynamic properties as well as the fitting coefficients, please checkout <a href= \"modelica://AixLib.DataBase.Media.Refrigerants.ThermodynamicStatePropertiesBaseDataDefinition\"> AixLib.DataBase.Media.Refrigerants.ThermodynamicStatePropertiesBaseDataDefinition</a> . The fitting coefficients are used in a hybrid refrigerant model provided in <a href= \"modelica://AixLib.Media.Refrigerants\">AixLib.Media.Refrigerants</a>. For detailed information, please checkout <a href= \"modelica://AixLib.Media.Refrigerants.Interfaces.TemplateHybridTwoPhaseMediumRecord\"> AixLib.Media.Refrigerants.Interfaces.TemplateHybridTwoPhaseMediumRecord</a>.
within AixLib.DataBase.Media.Refrigerants.R134a; record TSP_IIR_P1_395_T233_370 "Record with fitting coefficients calculated for first implementation" extends AixLib.DataBase.Media.Refrigerants.ThermodynamicStatePropertiesBaseDataDefinition( name="Coefficients taken from Engelpracht", T_phNt={4, 9, 40, 4, 9, 40}, Tl_phA={0.0532548969281581, -0.0327402932674217, 0.00529495748475652, -0.0147899438674052}, Tl_phB={59.7998195834653, -6.62177534265252, -2.9999979725331, 1.18395227550521, 2.80248047103141, -2.62761643515741, -3.56947078020548, 0.491461507071165, 0.927463043044066}, Tl_phC={-1.19878518364951, -0.962577907835024, 0.878481585133851, 3.91182176711109, 1.04265487024909, -0.48195831147019, 3.9963905002665, -1.69733815644078, -0.731437549563384, 0.0770329850582095, -1.83698529629045, -2.43696481656084, 0.468070335493652, 0.181462921419216, -1.82312663184436, -0.0230311877679581, 0.982708752218969, 0.0536451024965748, 1.14817103067673, 0.640727250560578, 0.128969357549004, -0.134539808379163, 1.23170727519629, 0.0597699698084911, -0.129555670548255, -0.0975402807270774}, Tl_phD={314.827695408612}, Tv_phA={19.7159455145757, -0.349661716358068, -0.0779836049824056, -0.0404894448559818}, Tv_phB={44.9076643959871, 1.61226716995587, -1.69537088625365, 1.26072555204728, -0.567008612580563, 0.0701057832233571, 0.0254180887275049, -0.0124041988508943, 0.0028610409309618}, Tv_phC={-0.00106840793875426, 0.0416365945399298, -0.0195802880749286, -0.179660544834243, -0.076962508011698, 0.0509650798466933, -0.00279310782986392, 0.617814317683068, -0.0790534022062859, -0.0468161156252338, 1.14842192548223, -0.919924069116996, -0.322612907855446, 0.169304169481087, -2.53676746445355, 0.126032916849538, 0.683339136223397, -0.12360236699935, 4.44394813815231, 0.335016787119797, -0.246814891775665, -0.113020154572386, -10.1366697046488, 0.120870986010151, -0.0231738848883972, 0.136566349184184}, Tv_phD={363.221803450648}, T_phIO={3258359.21215142,1352817.03780238, 258541.38494292, 87545.3330013087, 0, 1, 1623982.43177388, 1517145.25710131, 464371.882231745, 51004.186742787, 0, 1}, T_psNt={4, 10, 45, 4, 10, 45}, Tl_psA={0.94996237530845, 0.303157516353388, 0.0425905424516415, -0.00612110456282157}, Tl_psB={52.1272715438709, 0.934991565642564, -1.66612434799561, -1.27792380300538, 0.410987961018363, 1.20370954075399, -0.533205810766702, -1.00320676865041, 0.0173571141739969, 0.180140992292161}, Tl_psC={-0.291069659186083, -0.0872169090380506, 0.210931565927688, 1.54473840594432, 0.242658047959267, -0.125471470126885, 1.27724167635143, -0.749529598236941, -0.260793835526211, 0.0285723567918958, -1.20931903922332, -1.20679390142769, 0.14579825633924, 0.0761667567718539, -0.980601828987551, -0.0414786123544972, 0.67239714034787, 0.0115047530756927, 0.633536586430794, 0.603963042415619, 0.449251036040618, -0.143342451130932, 0.739997965709238, 0.284571979372862, 0.00615406154781733, -0.170430522133426, 0.674829627189691, 0.191394330126145, -0.041146019162364, -0.0717852001683681}, Tl_psD={300.587264376628}, Tv_psA={40.390945841519, 3.15200862940067, 0.84009020654906, 0.177443077694145}, Tv_psB={39.8941858976051, 2.0764693478832, -0.364336953952206, 0.0421908648150418, 0.0677619152714318, -0.0204430553521217, -0.0190222016179443, 0.0122643123754593, -0.00234908647943673, 0.00012413799291331}, Tv_psC={-0.00140522490504156, 0.00329122730110688, -0.00937491577006562, 0.0333827070862789, 0.0508721324649598, -0.0216247475662101, -0.148892361231698, -0.0330211687434747, 0.122997152293476, -0.023644132786541, 0.160671867686228, -0.256585546262645, -0.210848453821976, 0.131206121652008, 0.102631340846465, 0.499615855820928, 0.0559247407428316, -0.207112807377818, -0.320168181386132, -0.147739984347582, 0.113844709544168, 0.0165765359506585, 0.588939883715035, 0.00902349232653274, 0.0295039397995595, 0.146603156395031, -0.434825078991382, -0.932894048645235, -0.34837692742088, -0.0914682411901647}, Tv_psD={327.5152079225}, T_psIO={14.7875365886205,0.663511063673611, 1126.31192475932, 244.853512874793, 0, 1, 13.204266881401, 1.16895892611495, 1831.0596916082, 116.879525072462, 0, 1}, d_pTNt={3, 12, 46, 18, 4, 85}, dl_pTA={7.87433412548864, -0.393021216688428, -0.0297809665090564}, dl_pTB={-152.964391932951, -26.5844725397398, -13.2573880132147, 8.42443025706179, 14.2596863645139, -18.3785897660491, -24.8669510003648, 7.78387180871463, 15.7146697953855, 0.681093877003925, -3.80893784483356, -1.02415118562434}, dl_pTC={2.06494548963484, 7.57753444222479, -1.26044732839976, 0.305045780960498, -5.16251152860913, 0.227139340077688, -24.4943337560739, -2.88562398358126, 1.13671327198115, -14.5056545529004, 11.723519090061, 1.48106761398927, 28.7134548150431, 12.5950803196686, -1.02019713556307, 22.307603797593, -8.24807441103373, -3.24960897757928, -10.5027246393796, -12.0818129588016, -0.922165432363117, -6.49123842323816, 0.746728622500784, 1.59789449316334, 5.70882420483716, 2.56319794925055, 0.824892590067656, 7.146645111271, -0.411530121945932, -0.0588201589015566}, dl_pTD={1189.94427795653}, dv_pTA={63.4239308958369, 18.3003263667046, 9.39421881473955, 7.09177356543309, 5.23708459011804, 0.578782340741552, -1.54042394843668, 1.25422245124727, 3.20297513437295, 2.27421493369135, -0.504581868379304, -1.12599416061308, 1.55331005888042, 1.16161743095121, -1.20184737545216, -0.74648142212366, 0.278070675613861, 0.1689335064038}, dv_pTB={-12.4136441424452, 3.88226290732021, -1.70439246480624, 0.562626262975482}, dv_pTC={-1.17017884482496, -2.3852489066477, 3.06658887799103, 4.57803202704379, 7.60586826210336, -3.6374054137502, 11.1305887867053, -10.531890937117, -10.6025332817454, 1.67395801589396, -4.11656519288863, -37.829721696342, 10.8160047767693, 5.39724210896898, -15.8509141937486, 0.16539060896887, 56.1542951833691, -4.37751446853329, -0.700734627984774, 58.9914336041491, 12.6985686213048, -30.0162045272803, 3.29957742403242, 29.3966215270787, -98.1518521184536, -11.3492996193995, -11.3408317015857, -14.6134355681511, -70.1869342443377, 56.8538866067529, -10.8064971385458, -1.52226374447057, 45.0040674986077, 50.1097731625293, 2.5492410749415, 4.97951280387615, 44.4419747118542, -34.0879999837732, 2.67944204720335, -0.501886352998431, -6.26134528520153, -47.2205597266305, -11.7666587360995, 9.71258637652847, -10.6315428426648, 4.53156357787073, -19.9076698455612, 20.8686520295642, -11.5331539200892, 19.2381594479155, -19.3570225767985, 23.2916795123783, -17.0315966365249, 5.95211177024792, -20.0890389234895, 18.9596025990082, -12.5541351899702, 1.61845307417717, -20.9996689026322, 11.4012827945148, -6.08216841759289, 1.6139077221972}, dv_pTD={73.118571695972}, d_pTIO={3067141.02087822,1250016.64160742, 306.333739723678, 39.7052211222868, 0, 1.007596524, 1600766.20840426, 1019029.80447803, 345.780142922559, 24.3460840999553, 0, 0.999}); end TSP_IIR_P1_395_T233_370;
Record with fitting coefficients taken from the Fast_Propane model. In this record, fitting coefficients are provided for thermodynamic properties at bubble and dew line. For detailed information of these thermodynamic properties as well as the fitting coefficients, please checkout <a href= \"modelica://AixLib.DataBase.Media.Refrigerants.BubbleDewStatePropertiesBaseDataDefinition\"> AixLib.DataBase.Media.Refrigerants.BubbleDewStatePropertiesBaseDataDefinition</a> . The fitting coefficients are used in a hybrid refrigerant model provided in <a href= \"modelica://AixLib.Media.Refrigerants\">AixLib.Media.Refrigerants</a>. For detailed information, please checkout <a href= \"modelica://AixLib.Media.Refrigerants.Interfaces.TemplateHybridTwoPhaseMediumRecord\"> AixLib.Media.Refrigerants.Interfaces.TemplateHybridTwoPhaseMediumRecord</a>.
within AixLib.DataBase.Media.Refrigerants.R290; record BDSP_IIR_P05_30_T263_343 "Record with fitting coefficients taken from the Fast_Propane model" extends AixLib.DataBase.Media.Refrigerants.BubbleDewStatePropertiesBaseDataDefinition( name="Coefficients taken from Fast_Propane model developed by Sangi et al.", psat_Nt=5, psat_N={-6.7722, 1.6938, -1.3341, -3.1876, 0.94937}, psat_E={1, 1.5, 2.2, 4.8, 6.5}, Tsat_Nt=36, Tsat_N={398148862.940126, -199919955.396472, -757908233.955288, 367952699.725659, 667046798.608578, -312549990.204649, -357938868.07772, 161410013.061604, 130510724.837043, -56445981.8598188, -34132767.2831829, 14097753.337877, 6597033.14683305, -2588996.07334184, -956016.453555908, 354129.363109993, 104671.21653575, -36365.4299997343, -8551.71765339857, 2737.41277992834, 548.032269738263, -169.618396241937, -14.0609083306686, -0.171965430903563, 5.1496074119545, -3.2101839991522, 2.10314346387695, -1.50075370184942, 1.08909694031671, -0.809987090417357, 0.624647765942656, -0.509758482228388, 0.452113517399419, -0.485252422559269, 0.812915722176255, 0.049784532}, Tsat_IO={1570581.06473046, 2557900, 314.714456959068, 89.9988984287752}, dl_Nt=27, dl_N={168.562039493205, 102.498679842295, -417.252850518645, -379.369839448631, 259.875445333347, 360.650888848736, -34.286073230572, -167.388526468939, -38.3089822429208, 32.2321439731247, 16.240179568742, -1.02099838936652, -2.73648898021723, -1.28146729979824, -0.699142505344287, -0.486571806528472, -0.362711228684454, -0.295698328266597, -0.257687633710071, -0.232292001969948, -0.214228995994567, -0.20556940574841, -0.209973677149465, -0.241754621811309, -0.31988094531161, -0.921191170759037, 0.0299586382685047}, dl_IO={303.15, 90, 479.63605641964, 158.710809951891}, dv_Nt=30, dv_N={24729.5537485333, -4790.47306548912, -52999.2668562323, 7058.92241323013, 52982.2892015502, -2370.58912808463, -31858.637385946, -1861.34451993193, 12491.6995976091, 2253.53926320725, -3122.52067135369, -1051.27601610942, 412.3820502853, 267.637744405501, 12.9822226129711, -27.0147438072994, -10.2971934822874, -0.739113632299647, 1.49114325185849, 1.35527523720564, 0.923630488185071, 0.672792235972464, 0.560751132479985, 0.509690199864535, 0.490192151807828, 0.495282411314377, 0.590898303947074, 0.811832008381672, 0.808375476827012, -0.0754744015174044}, dv_IO={303.15, 90, 28.4811865500103, 66.6559013317995}, hl_Nt=41, hl_N={-9294767843.63885, 4601044486.87677, 20637884091.3137, -9916466348.59996, -21359403718.5665, 9947264847.89552, 13636958532.2276, -6142679157.11019, -6000574809.17466, 2607836222.80069, 1926833832.78873, -805551262.020446, -466601813.162386, 187005402.363897, 86860131.7909424, -33235234.3082519, -12561996.4230609, 4567071.19402525, 1416354.0638898, -486313.365924655, -124542.594195178, 40167.0083231862, 8397.46595050577, -2498.28167363608, -462.619336965067, 137.536958919031, 6.47029425217843, 2.64758244293881, -5.32098880051055, 3.46672373461629, -2.26302221729487, 1.59069973995372, -1.13913175345066, 0.832473481266347, -0.610337601733258, 0.487787294421858, -0.381084129429948, 0.372237411342447, -0.34966667159822, 0.849926390294104, 0.0361438659731507}, hl_IO={1570581.06473046, 2557900, 315624.984387066, 256478.426329608}, hv_Nt=41, hv_N={-18775386313.6055, 9394086287.20505, 41644196829.4943, -20247895189.1885, -43051291028.3205, 20309540510.172, 27452478313.3802, -12538264110.1784, -12063991762.716, 5319760814.06607, 3868950611.13826, -1641348684.22018, -936106557.039505, 380310593.940752, 174364505.252102, -67425029.5319391, -25335355.2373842, 9258056.41821587, 2898773.57918601, -997509.402878578, -263711.217390457, 88279.4166642683, 18539.6674822496, -7265.37195240485, -791.349145978091, 783.380077339674, -118.386708715477, -87.4509889200359, 28.7466309562791, 22.7165909170454, -12.9134840899498, 0.37918804346481, -1.09461342269619, 2.21831905224981, -1.37432108544607, 0.840516589045987, -0.879264408088915, 0.602870738214699, -0.988765189667206, 0.73697777870168, 0.0980593948500622}, hv_IO={1570581.06473046, 2557900, 611770.95439052, 72569.9367503185}, sl_Nt=41, sl_N={-15349607814.6221, 7636274154.59154, 34083168950.6415, -16468859514.8044, -35274256182.5208, 16529163595.4961, 22520438414.7263, -10212384678.3319, -9909434496.20396, 4337708567.68782, 3182094478.82347, -1340537038.4187, -770642130.02999, 311344581.740643, 143483390.503767, -55358907.3112437, -20756825.7164981, 7610600.46375838, 2341379.49521742, -810782.536880512, -205991.835180489, 66975.5024566354, 13911.5167143464, -4172.85884728481, -763.056131634308, 226.059931948838, 12.7752539636391, 3.11268958206643, -7.85167676769299, 5.00328992083909, -3.24391515196012, 2.26101216009097, -1.60045805379047, 1.15217954418816, -0.838779616598381, 0.651059130787342, -0.506702271997059, 0.465184273228716, -0.435627195532008, 0.805470640142587, 0.0457609974234471}, sl_IO={1570581.06473046, 2557900, 1376.30588505819, 826.068105213303}, sv_Nt=41, sv_N={77490431827.9399, -38415276654.6987, -172242854661.379, 82962121367.1925, 178399484846.286, -83356734431.6106, -113970547248.801, 51553752249.9676, 50177422017.5857, -21921194748.1992, -16120343329.1663, 6783508534.79747, 3904793200.14042, -1578181058.50373, -726577962.8212, 281202937.346275, 104799948.851401, -38715062.2946953, -11716161.8016396, 4105031.67420979, 1007213.05553646, -326165.883627773, -65541.5043152719, 16329.6212516804, 3852.60757433586, 91.0319174951408, -343.494332982509, -224.377993905924, 107.45943824896, 24.4635507698644, -8.50688453256311, -13.0500554559933, 6.58097770859788, -1.42438707828771, 1.58146106221061, -1.50959232991508, 0.66941156982168, -0.759627313555789, -0.113920392204933, -0.624499077638527, -0.00619048868799449}, sv_IO={1570581.06473046, 2557900, 2335.75170536325, 97.9077112667096}); end BDSP_IIR_P05_30_T263_343;