LBL logo

Buildings.Utilities.IO.BCVTB.BaseClasses

Package with base classes for Buildings.Utilities.IO.BCVTB

Information

This package contains base classes that are used to construct the models in Buildings.Utilities.IO.BCVTB.

Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).

Package Content

NameDescription
Buildings.Utilities.IO.BCVTB.BaseClasses.FluidInterface FluidInterface Partial class for fluid interface that can be coupled to BCVTB
Buildings.Utilities.IO.BCVTB.BaseClasses.establishClientSocket establishClientSocket Establishes the client socket connection
Buildings.Utilities.IO.BCVTB.BaseClasses.exchangeReals exchangeReals Exchanges values of type Real with the socket
Buildings.Utilities.IO.BCVTB.BaseClasses.closeClientSocket closeClientSocket Closes the socket for the inter process communication


Buildings.Utilities.IO.BCVTB.BaseClasses.FluidInterface Buildings.Utilities.IO.BCVTB.BaseClasses.FluidInterface

Partial class for fluid interface that can be coupled to BCVTB

Buildings.Utilities.IO.BCVTB.BaseClasses.FluidInterface

Information

This is a partial model that is used to construct models for interfacing fluid flow systems with the BCVTB interface.

Extends from Buildings.BaseClasses.BaseIcon (Base icon).

Parameters

TypeNameDefaultDescription
Booleanuse_m_flow_infalseGet the mass flow rate from the input connector
MassFlowRatem_flow0Fixed mass flow rate going out of the fluid port [kg/s]
Nominal condition
MassFlowRatem_flow_nominal Nominal mass flow rate, used for regularization near zero flow [kg/s]
Advanced
MassFlowRatem_flow_small1E-4*m_flow_nominalFor bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required) [kg/s]

Connectors

TypeNameDescription
input RealInputm_flow_inPrescribed mass flow rate
input RealInputT_inPrescribed boundary temperature
FluidPorts_bports[nPorts] 
output RealOutputHSen_flowSensible enthalpy flow rate, positive if flow into the component [W]

Modelica definition

partial model FluidInterface 
  "Partial class for fluid interface that can be coupled to BCVTB"
  import Buildings;
  extends Buildings.BaseClasses.BaseIcon;

  replaceable package Medium =
      Modelica.Media.Interfaces.PartialMedium "Medium model within the source";

  parameter Integer nPorts=0 "Number of ports";
  Modelica.Blocks.Interfaces.RealInput m_flow_in if     use_m_flow_in 
    "Prescribed mass flow rate";
  Modelica.Blocks.Interfaces.RealInput T_in "Prescribed boundary temperature";

   parameter Boolean use_m_flow_in = false 
    "Get the mass flow rate from the input connector";
  parameter Medium.MassFlowRate m_flow = 0 
    "Fixed mass flow rate going out of the fluid port";

  parameter Medium.MassFlowRate m_flow_nominal(min=0) 
    "Nominal mass flow rate, used for regularization near zero flow";
  parameter Medium.MassFlowRate m_flow_small(min=0) = 1E-4*m_flow_nominal 
    "For bi-directional flow, temperature is regularized in the region |m_flow| < m_flow_small (m_flow_small > 0 required)";

  Buildings.Fluid.Sensors.EnthalpyFlowRate totEntFloRat[nPorts](
    redeclare final package Medium = Medium,
    each final m_flow_nominal=m_flow_nominal) 
    "Total enthalpy flow rate (sensible plus latent)";
  Modelica.Fluid.Interfaces.FluidPorts_b ports[
                                nPorts](
                     redeclare each package Medium = Medium,
                     m_flow(each max=if flowDirection==Modelica.Fluid.Types.PortFlowDirection.Leaving then 0 else 
                                     +Modelica.Constants.inf,
                            each min=if flowDirection==Modelica.Fluid.Types.PortFlowDirection.Entering then 0 else 
                                     -Modelica.Constants.inf));

  Modelica.Blocks.Math.Sum sumHTot_flow(nin=nPorts) 
    "Sum of total enthalpy flow rates";
  Modelica.Blocks.Interfaces.RealOutput HSen_flow(unit="W") 
    "Sensible enthalpy flow rate, positive if flow into the component";
  Buildings.Fluid.Sources.MassFlowSource_T bou(
    redeclare package Medium = Medium,
    final use_T_in=true,
    final nPorts=nPorts,
    use_X_in=false,
    use_C_in=false,
    final use_m_flow_in=true);
protected 
  parameter Modelica.Fluid.Types.PortFlowDirection flowDirection=
                   Modelica.Fluid.Types.PortFlowDirection.Bidirectional 
    "Allowed flow direction";
equation 
  connect(m_flow_in, bou.m_flow_in);
  if not use_m_flow_in then
    bou.m_flow_in = m_flow;
  end if;

  connect(totEntFloRat.port_b, bou.ports);
  connect(sumHTot_flow.u, totEntFloRat.H_flow);
  connect(bou.T_in, T_in);
end FluidInterface;

Buildings.Utilities.IO.BCVTB.BaseClasses.establishClientSocket

Establishes the client socket connection

Information

Function that establishes a socket connection to the BCVTB.

For the xml file name, on Windows use two backslashes to separate directories, i.e., use

  xmlFileName="C:\\examples\\dymola-room\\socket.cfg"

Inputs

TypeNameDefaultDescription
StringxmlFileName"socket.cfg"Name of xml file that contains the socket information

Outputs

TypeNameDescription
IntegersocketFDSocket file descripter, or a negative value if an error occured

Modelica definition

function establishClientSocket 
  "Establishes the client socket connection"

  input String xmlFileName = "socket.cfg" 
    "Name of xml file that contains the socket information";
  output Integer socketFD 
    "Socket file descripter, or a negative value if an error occured";
  external "C"
     socketFD=establishModelicaClient(xmlFileName);
end establishClientSocket;

Buildings.Utilities.IO.BCVTB.BaseClasses.exchangeReals

Exchanges values of type Real with the socket

Information

Function to exchange data of type Real with the socket. This function must only be called once in each communication interval.

Inputs

TypeNameDefaultDescription
IntegersocketFD Socket file descripter
IntegerflaWri Communication flag to write to the socket stream
TimesimTimWri Current simulation time in seconds to write [s]
RealdblValWri[nDblWri] Double values to write
IntegernDblWri Number of double values to write
IntegernDblRea Number of double values to read

Outputs

TypeNameDescription
IntegerflaReaCommunication flag read from the socket stream
TimesimTimReaCurrent simulation time in seconds read from socket [s]
RealdblValRea[nDblRea]Double values read from socket
IntegerretValThe exit value, which is negative if an error occured

Modelica definition

function exchangeReals 
  "Exchanges values of type Real with the socket"

  input Integer socketFD(min=1) "Socket file descripter";
  input Integer flaWri "Communication flag to write to the socket stream";
  input Modelica.SIunits.Time simTimWri 
    "Current simulation time in seconds to write";
  input Real[nDblWri] dblValWri "Double values to write";
  input Integer nDblWri "Number of double values to write";
  input Integer nDblRea "Number of double values to read";
  output Integer flaRea "Communication flag read from the socket stream";
  output Modelica.SIunits.Time simTimRea 
    "Current simulation time in seconds read from socket";
  output Real[nDblRea] dblValRea "Double values read from socket";
  output Integer retVal "The exit value, which is negative if an error occured";
  external "C"
     retVal=exchangeModelicaClient(socketFD,
       flaWri, flaRea,
       simTimWri,
       dblValWri, nDblWri,
       simTimRea,
       dblValRea, nDblRea);
end exchangeReals;

Buildings.Utilities.IO.BCVTB.BaseClasses.closeClientSocket

Closes the socket for the inter process communication

Information

Function that closes the inter-process communication.

Inputs

TypeNameDefaultDescription
IntegersocketFD Socket file descripter, or a negative value if an error occured

Outputs

TypeNameDescription
IntegerretValReturn value of the function that closes the socket connection

Modelica definition

function closeClientSocket 
  "Closes the socket for the inter process communication"

  input Integer socketFD 
    "Socket file descripter, or a negative value if an error occured";
  output Integer retVal 
    "Return value of the function that closes the socket connection";
  external "C"
     retVal=closeModelicaClient(socketFD);
end closeClientSocket;

Automatically generated Wed Feb 29 16:55:16 2012.