How to use the pyomo.environ.Param function in Pyomo

To help you get started, we’ve selected a few Pyomo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IDAES / idaes-pse / idaes / generic_models / properties / cubic_eos / BT_PR.py View on Github external
self.mw_comp = Param(self.component_list,
                             mutable=False,
                             initialize=extract_data(mw_comp_data),
                             doc="molecular weight kg/mol")

        # Constants for specific heat capacity, enthalpy and entropy
        cp_ig_data = {('benzene', '1'): -3.392E1,
                      ('benzene', '2'): 4.739E-1,
                      ('benzene', '3'): -3.017E-4,
                      ('benzene', '4'): 7.130E-8,
                      ('toluene', '1'): -2.435E1,
                      ('toluene', '2'): 5.125E-1,
                      ('toluene', '3'): -2.765E-4,
                      ('toluene', '4'): 4.911E-8}

        self.cp_ig = Param(self.component_list,
                           ['1', '2', '3', '4'],
                           mutable=False,
                           initialize=extract_data(cp_ig_data),
                           doc="Parameters to compute cp_comp")

        # Standard heats of formation
        # Source: NIST Webbook, https://webbook.nist.gov
        # Retrieved 25th September 2019
        dh_form_data = {'benzene': 82.9e3,
                        'toluene': 50.1e3}

        self.enth_mol_form_ref = Param(self.component_list,
                                       mutable=False,
                                       initialize=extract_data(dh_form_data),
                                       doc="Standard heats of formation")
github IDAES / idaes-pse / idaes / property_models / saponification_thermo.py View on Github external
'''
        super(PhysicalParameterData, self).build()

        self.state_block_class = StateBlock

        # List of valid phases in property package
        self.phase_list = Set(initialize=['Liq'])

        # Component list - a list of component identifiers
        self.component_list = Set(initialize=['H2O', 'NaOH',
                                              'EthylAcetate',
                                              'SodiumAcetate',
                                              'Ethanol'])

        # Heat capacity of water
        self.cp_mol = Param(mutable=False,
                            initialize=75.327,
                            doc="Molar heat capacity of water [J/mol.K]")

        # Density of water
        self.dens_mol = Param(mutable=False,
                              initialize=55388.0,
                              doc="Molar density of water [mol/m^3]")

        # Thermodynamic reference state
        self.pressure_ref = Param(within=PositiveReals,
                                  mutable=True,
                                  default=101325.0,
                                  doc='Reference pressure [Pa]')
        self.temperature_ref = Param(within=PositiveReals,
                                     mutable=True,
                                     default=298.15,
github Pyomo / pyomo / pyomo / contrib / pynumero / examples / gas_network_model.py View on Github external
model.TDEC = aml.Param(initialize=9.5)

    model.eps = aml.Param(initialize=0.025, within=aml.PositiveReals)
    model.z = aml.Param(initialize=0.80, within=aml.PositiveReals)
    model.rhon = aml.Param(initialize=0.72, within=aml.PositiveReals)
    model.R = aml.Param(initialize=8314.0, within=aml.PositiveReals)
    model.M = aml.Param(initialize=18.0, within=aml.PositiveReals)
    model.pi = aml.Param(initialize=3.14, within=aml.PositiveReals)
    model.nu2 = aml.Param(within=aml.PositiveReals,mutable=True)
    model.lam = aml.Param(model.LINK, within=aml.PositiveReals, mutable=True)
    model.A = aml.Param(model.LINK, within=aml.NonNegativeReals, mutable=True)
    model.Tgas = aml.Param(initialize=293.15, within=aml.PositiveReals)
    model.Cp = aml.Param(initialize=2.34, within=aml.PositiveReals)
    model.Cv = aml.Param(initialize=1.85, within=aml.PositiveReals)
    model.gam = aml.Param(initialize=model.Cp/model.Cv, within=aml.PositiveReals)
    model.om = aml.Param(initialize=(model.gam-1.0)/model.gam, within=aml.PositiveReals)

    # scaling and constants
    model.ffac = aml.Param(within=aml.PositiveReals, initialize=(1.0e+6*model.rhon)/(24.0*3600.0))
    model.ffac2 = aml.Param(within=aml.PositiveReals, initialize=3600.0/(1.0e+4 * model.rhon))
    model.pfac = aml.Param(within=aml.PositiveReals, initialize=1.0e+5)
    model.pfac2 = aml.Param(within=aml.PositiveReals, initialize=1.0e-5)
    model.dfac = aml.Param(within=aml.PositiveReals, initialize=1.0e-3)
    model.lfac = aml.Param(within=aml.PositiveReals, initialize=1.0e+3)

    model.c1 = aml.Param(model.LINK, within=aml.PositiveReals, mutable=True)
    model.c2 = aml.Param(model.LINK, within=aml.PositiveReals, mutable=True)
    model.c3 = aml.Param(model.LINK, within=aml.PositiveReals, mutable=True)
    model.c4 = aml.Param(within=aml.PositiveReals, mutable=True)

    # cost factors
github squoilin / MicroGrids / MicroGrids / Model_Creation.py View on Github external
'''
    This function creates the instance for the resolution of the optimization in Pyomo.
    The problem is solved by discretizing the efficiency curve of the generators and uses binary variables
    
    :param model: Pyomo model as defined in the Micro-Grids library.
    
    '''
    from pyomo.environ import  Param, RangeSet, NonNegativeReals, Var, Binary, NonNegativeIntegers
    from Initialize import Initialize_years, Initialize_Demand, Initialize_PV_Energy, Marginal_Cost_Generator, Start_Cost,Marginal_Cost_Generator_1 # Import library with initialitation funtions for the parameters
   
    # Time parameters
    model.Periods = Param(within=NonNegativeReals) # Number of periods of analysis of the energy variables
    model.Years = Param() # Number of years of the project
    model.StartDate = Param() # Start date of the analisis
    model.PlotTime = Param() # Quantity of days that are going to be plot
    model.PlotDay = Param() # Start day for the plot
    model.Scenarios = Param()  
    model.PlotScenario = Param()
    #SETS
    model.periods = RangeSet(1, model.Periods) # Creation of a set from 1 to the number of periods in each year
    model.years = RangeSet(1, model.Years) # Creation of a set from 1 to the number of years of the project
    model.Slops = RangeSet(1,2)
    model.scenario = RangeSet(1, model.Scenarios) # Creation of a set from 1 to the numbero scenarios to analized
    
    # PARAMETERS
    
    # Parameters of the PV 
    model.PV_Nominal_Capacity = Param(within=NonNegativeReals) # Nominal capacity of the PV in W/unit
    model.Inverter_Efficiency = Param() # Efficiency of the inverter in %
    model.PV_invesment_Cost = Param(within=NonNegativeReals) # Cost of solar panel in USD/W
    model.PV_Energy_Production = Param(model.scenario, model.periods, within=NonNegativeReals, initialize=Initialize_PV_Energy) # Energy produccion of a solar panel in W
github IDAES / idaes-pse / idaes / examples / workshops / Module_3_Custom_Unit_Model / methanol_param_VLE.py View on Github external
('CO', 'B'): 530.22,
                                     ('CO', 'C'): -13.15,
                                     ('H2', 'A'): 13.6333,
                                     ('H2', 'B'): 164.9,
                                     ('H2', 'C'): 3.19,
                                     ('CH3OH', 'A'): 18.5875,
                                     ('CH3OH', 'B'): 3626.55,
                                     ('CH3OH', 'C'): -34.29}

        Cp = self.config.Cp
        Cv = Cp - const.gas_constant*1e-3
        gamma = Cp / Cv

        self.gamma = Param(within=NonNegativeReals, mutable=True, default=gamma, doc='Ratio of Cp to Cv')

        self.Cp = Param(within=NonNegativeReals, mutable=True, default=Cp, doc='Constant pressure heat capacity [MJ/(kgmol K)]')
github IDAES / idaes-pse / idaes / generic_models / properties / iapws95.py View on Github external
# Thermal conductivity parameters.
        # "Release on the IAPWS Formulation 2011 for the Thermal Conductivity
        # of Ordinary Water Substance"
        self.tc_L0 = Param(
            RangeSet(0, 5),
            initialize={
                0: 2.443221e-3,
                1: 1.323095e-2,
                2: 6.770357e-3,
                3: -3.454586e-3,
                4: 4.096266e-4,
            },
            doc="0th order thermal conductivity parameters",
        )

        self.tc_L1 = Param(
            RangeSet(0, 5),
            RangeSet(0, 6),
            initialize={
                (0, 0): 1.60397357,
                (1, 0): 2.33771842,
                (2, 0): 2.19650529,
                (3, 0): -1.21051378,
                (4, 0): -2.7203370,
                (0, 1): -0.646013523,
                (1, 1): -2.78843778,
                (2, 1): -4.54580785,
                (3, 1): 1.60812989,
                (4, 1): 4.57586331,
                (0, 2): 0.111443906,
                (1, 2): 1.53616167,
                (2, 2): 3.55777244,
github IDAES / idaes-pse / idaes / power_generation / unit_models / boiler_heat_exchanger.py View on Github external
Args:
            None

        Returns:
            None
        """
        # Set references to balance terms at unit level
        add_object_reference(self, "heat_duty", self.side_1.heat)
        if self.config.has_pressure_change is True:
            add_object_reference(self, "deltaP_tube", self.side_1.deltaP)
            add_object_reference(self, "deltaP_shell", self.side_2.deltaP)

        # Performance parameters and variables
        # Wall thermal conductivity
        self.therm_cond_wall = Param(initialize=43.0,
                                     within=PositiveReals,
                                     doc="Thermal conductivity of "
                                     "the wall - W/(m K)")

        # Loss coefficient for a 180 degree bend (u-turn),
        # usually related to radius to inside diameter ratio
        self.k_loss_uturn = Param(initialize=0.5,
                                  within=PositiveReals,
                                  mutable=True,
                                  doc='Loss coefficient of a tube u-turn')

        # Heat transfer resistance due to the fouling on tube side
        # (typical boiler hx)
        self.tube_r_fouling = Param(initialize=0.00017,
                                    within=NonNegativeReals,
                                    mutable=True,
github Pyomo / pyomo / pyomo / contrib / pynumero / examples / gas_network_model.py View on Github external
def rule_pmin(m, n):
        if n == 'n1':
            return 57.0
        elif n == 'n13':
            return 39.0
        else:
            return 34.0

    model.pmin = aml.Param(model.NODE, initialize=rule_pmin, mutable=True)

    def rule_pmax(m, n):
        if n == 'n13':
            return 41.0
        return 70.0
    model.pmax = aml.Param(model.NODE, initialize=rule_pmax, mutable=True)

    # supply
    model.SUP = aml.Set(initialize=[1])
    model.sloc = aml.Param(model.SUP, initialize='n1')
    model.smin = aml.Param(model.SUP, within=aml.NonNegativeReals, initialize=0.000, mutable=True)
    model.smax = aml.Param(model.SUP, within=aml.NonNegativeReals, initialize=30, mutable=True)
    model.scost = aml.Param(model.SUP, within=aml.NonNegativeReals)

    # demand
    model.DEM = aml.Set(initialize=[1])
    model.dloc = aml.Param(model.DEM, initialize='n13')
    model.d = aml.Param(model.DEM, within=aml.PositiveReals, initialize=10, mutable=True)

    # physical data

    model.TDEC = aml.Param(initialize=9.5)
github IDAES / idaes-pse / idaes / property_models / BFW_properties.py View on Github external
2: -2.0901E3,
                    3: 8.125,
                    4: -1.4116E-2,
                    5: 9.3701E-6}
        self.cp_param = Param(RangeSet(5), initialize=cp_param,
                              doc="specific heat parameters")

        # Viscosity coefficients Temp range - 273.16 K to 646.15 K
        # Viscosity is in centipoise converted to Pa.s
        # Source: DIPPR (From Aspen Properties)
        visc_d_phase_param = {1: -45.9352,
                              2: 3703.6,
                              3: 5.866,
                              4: -5.879E-29,
                              5: 10}
        self.visc_d_phase_param = Param(RangeSet(5),
                                        initialize=visc_d_phase_param,
                                        doc="dynamic viscosity parameters")

        # Thermal conductivoty coefficients Temp range - 273.16 K to 633.15 K
        # Thermal conductivity is in W/m-K
        # Source: DIPPR (From Aspen Properties)
        therm_cond_phase_param = {1: -0.432,
                                  2: 5.7255E-3,
                                  3: -8.078E-6,
                                  4: 1.861E-9}
        self.therm_cond_phase_param = Param(RangeSet(4),
                                            initialize=therm_cond_phase_param,
                                            doc="thermal conductivity W/m/K")

        self.mw = Param(initialize=18.015E-3, doc="molecular weight Kg/mol")
github IDAES / idaes-pse / idaes / core / util / unit_costing.py View on Github external
else:
                    raise Exception('pump type not supported')
            self.base_pump_cost_eq = Constraint(rule=base_pump_rule)

            def CP_pump_rule(self):
                return self.pump_purchase_cost == \
                    (self.FT * self.material_factor *
                     (self.parent_block().flowsheet().
                      costing.CE_index/394)*self.base_cost)
            self.cp_pump_cost_eq = Constraint(rule=CP_pump_rule)

            # electric motor cost correlations ------------------------------
            pump_motor_type_dic = {'open': 1,
                                   'enclosed': 1.4,
                                   'explosion_proof': 1.8}
            self.motor_FT = Param(mutable=True,
                                  initialize=pump_motor_type_dic
                                  [pump_motor_type_factor],
                                  doc='motor type factor')

            # pump fractional efficiency
            np = -0.316 + 0.24015*log(Q_gpm) - 0.01199*log(Q_gpm)**2
            # fractional efficiency of the electric motor
            nm = 0.80 + 0.0319*log(work_hp) - 0.00182*log(work_hp)**2

            # power consumption in horsepower
            @self.Expression()
            def power_consumption_hp(self):
                return (Q_gpm*self.pump_head
                        * dens_mass_lb_ft3/7.48052)/(33000*np*nm)

            def base_motor_cost_rule(self):