Modelica Buildings library fluid sensors

27 Views Asked by At

I encountered a problem, when I tried to use Buidlings.Fluid.Sensors.TraceSubstances to get the concentration of CO2, the system gave me an error:

[Buildings.Fluid.Sensors.TraceSubstances: 21:3-23:55]: Assertion triggered during translation: "Trace substance '" + "CO2" + "' is not present in medium '" + "Air" + "'." + "Check sensor parameter and medium model."

model testdac_3
       replaceable package Medium =
       Modelica.Media.Interfaces.PartialMedium "Medium in the component"
        annotation (choices(
        choice(redeclare package Medium = Buildings.Media.Air(extraPropertiesNames={"CO2"}) "Moist air")));
       import Modelica.Constants;
      parameter Boolean allowFlowReversal = true
       "= false to simplify equations, assuming, but not enforcing, no flow reversal"
       annotation(Dialog(tab="Assumptions"), Evaluate=true);
       Modelica.Fluid.Interfaces.FluidPort_b port_out(redeclare package Medium =
        Medium, m_flow(start=0, max=if allowFlowReversal then +Constants.inf else
                0))
      "Fluid connector b (positive design flow direction is from port_a to port_b)"
        annotation (Placement(transformation(extent={{-90,-70},{-110,-50}})));
        Modelica.Fluid.Interfaces.FluidPort_a port_in(redeclare package Medium =
        Medium, m_flow(start=0, min=if allowFlowReversal then -Constants.inf else
                0),C_outflow(
                    each min=0,
                    each max=1))
      "Fluid connector a (positive design flow direction is from port_a to port_b)"
         annotation (Placement(transformation(extent={{110,-70},{90,-50}})));
       Modelica.Fluid.Sensors.Temperature Tads(redeclare package Medium=Medium);
       Buildings.Fluid.Sensors.TraceSubstances senCO2(
       redeclare package Medium = Medium, warnAboutOnePortConnection=false)
                                       "Sensor at volume";
    
     protected
      parameter Medium.Density rho_default=Medium.density(sta_default)
    "Density, used to compute fluid volume";
       parameter Medium.ThermodynamicState sta_default=
     Medium.setState_pTX(T=Medium.T_default, p=Medium.p_default, X=Medium.X_default)
      "Default medium state";

    equation
    connect(port_in,port_out);
    connect(Tads.port,port_in);
    connect(senCO2.port,port_in);
end testdac_3;

enter image description here

enter image description here

enter image description here

I want to add a new sub-system in the mixingbox to regulate the CO2 concentration.

0

There are 0 best solutions below