## Objects

## Main.Objects History

Show minor edits - Show changes to markup

- Thermo_* - Thermodynamic properties (* see below for specific properties)

- Thermo_* - Thermodynamic properties (* see Thermo information for specific properties)

### Thermo objects

Thermo objects access data from the underlying thermodynamic database. There are many compounds accessible in the database. To reduce the size of the APMonitor executable, only some of the more common compounds are currently incorporated. Additional compounds can be easily added but require a rebuild of the executable.

#### Temperature Independent Property Data

Temperature independent property data do not vary with temperature. They are defined as constants for each of the species declared in the Compounds ... End Compounds section of the model. If the Compounds ... End Compounds section is missing, all available compounds are included in the model.

(:table border=1 width=100%:) (:cellnr:) thermo_mw (:cell:) Molecular Weight (:cell:) kg/kmol (:cellnr:) thermo_tc (:cell:) Critical Temperature (:cell:) K (:cellnr:) thermo_pc (:cell:) Critical Pressure (:cell:) Pa (:cellnr:) thermo_vc (:cell:) Critical Volume (:cell:) m^3/kmol (:cellnr:) thermo_ccf (:cell:) Crit Compress Factor (:cell:) unitless (:cellnr:) thermo_mp (:cell:) Melting Point (:cell:) K (:cellnr:) thermo_tpt (:cell:) Triple Pt Temperature (:cell:) K (:cellnr:) thermo_tpp (:cell:) Triple Pt Pressure (:cell:) Pa (:cellnr:) thermo_nbp (:cell:) Normal Boiling Point (:cell:) K (:cellnr:) thermo_lmv (:cell:) Liq Molar Volume (:cell:) m^3/kmol (:cellnr:) thermo_ighf (:cell:) IG Heat of Formation (:cell:) J/kmol (:cellnr:) thermo_iggf (:cell:) IG Gibbs of Formation (:cell:) J/kmol (:cellnr:) thermo_igae (:cell:) IG Absolute Entropy (:cell:) J/kmol*K (:cellnr:) thermo_shf (:cell:) Std Heat of Formation (:cell:) J/kmol (:cellnr:) thermo_sgf (:cell:) Std Gibbs of Formation (:cell:) J/kmol (:cellnr:) thermo_sae (:cell:) Std Absolute Entropy (:cell:) J/kmol*K (:cellnr:) thermo_hfmp (:cell:) Heat Fusion at Melt Pt (:cell:) J/kmol (:cellnr:) thermo_snhc (:cell:) Std Net Heat of Comb (:cell:) J/kmol (:cellnr:) thermo_af (:cell:) Acentric Factor (:cell:) unitless (:cellnr:) thermo_rg (:cell:) Radius of Gyration (:cell:) m (:cellnr:) thermo_sp (:cell:) Solubility Parameter (:cell:) (J/m^3)^0.5 (:cellnr:) thermo_dm (:cell:) Dipole Moment (:cell:) c*m (:cellnr:) thermo_r (:cell:) van der Waals Volume (:cell:) m^3/kmol (:cellnr:) thermo_q (:cell:) van der Waals Area (:cell:) m^2 (:cellnr:) thermo_ri (:cell:) Refractive Index (:cell:) unitless (:cellnr:) thermo_fp (:cell:) Flash Point (:cell:) K (:cellnr:) thermo_lfl (:cell:) Lower Flammability Limit (:cell:) K (:cellnr:) thermo_ufl (:cell:) Upper Flammability Limit (:cell:) K (:cellnr:) thermo_lflt (:cell:) Lower Flamm Limit Temp (:cell:) K (:cellnr:) thermo_uflt (:cell:) Upper Flamm Limit Temp (:cell:) K (:cellnr:) thermo_ait (:cell:) Auto Ignition Temp (:cell:) K (:tableend:)

#### Temperature Dependent Property Data

The temperature dependent thermo objects produce values based on a specified temperature. When a temperature dependent property object is declared, a new temperature variable will be created. This variable can be adjusted or linked to an existing temperature of interest.

(:table border=1 width=100%:) (:cellnr:) thermo_sd (:cell:) Solid Density (:cell:) kmol/m^3 (:cellnr:) thermo_ld (:cell:) Liquid Density (:cell:) kmol/m^3 (:cellnr:) thermo_svp (:cell:) Solid Vapor Pressure (:cell:) Pa (:cellnr:) thermo_lvp (:cell:) Liquid Vapor Pressure (:cell:) Pa (:cellnr:) thermo_hvap (:cell:) Heat of Vaporization (:cell:) J/kmol (:cellnr:) thermo_scp (:cell:) Solid Heat Capacity (:cell:) J/kmol*K (:cellnr:) thermo_lcp (:cell:) Liquid Heat Capacity (:cell:) J/kmol*K (:cellnr:) thermo_igcp (:cell:) Ideal Gas Heat Capacity (:cell:) J/kmol*K (:cellnr:) thermo_svc (:cell:) Second Virial Coefficient (:cell:) m^3/kmol (:cellnr:) thermo_lv (:cell:) Liquid Viscosity (:cell:) Pa*s (:cellnr:) thermo_vv (:cell:) Vapor Viscosity (:cell:) Pa*s (:cellnr:) thermo_sk (:cell:) Solid Thermal Conductivity (:cell:) W/m*K (:cellnr:) thermo_lk (:cell:) Liq Thermal Conductivity (:cell:) W/m*K (:cellnr:) thermo_vk (:cell:) Vap Thermal Conductivity (:cell:) W/m*K (:cellnr:) thermo_st (:cell:) Surface Tension (:cell:) N/m (:cellnr:) thermo_sh (:cell:) Solid Enthalpy (:cell:) J/kmol (:cellnr:) thermo_lh (:cell:) Liq Enthalpy (:cell:) J/kmol (:cellnr:) thermo_vh (:cell:) Vap Enthalpy (:cell:) J/kmol (:tableend:)

Python GEKKO has equation functions and pre-built objects. Some of the pre-built objects and equation functions are:

Python GEKKO has equation functions and pre-built objects. GEKKO has objects in the Deep Learning (Brain) and Thermo & Flowsheet Chemical libraries. Some of the other pre-built objects and equation functions are:

**if3(cond,x1,x2)**switch between x1 (cond<0) and x2 (cond>=0)

Thermo objects access data from the underlying thermodynamic database. There are over 1700 compounds accessible in the database. To reduce the size of the APMonitor executable, only some of the more common compounds are currently incorporated. Additional compounds can be easily added but require a rebuild of the executable.

Thermo objects access data from the underlying thermodynamic database. There are many compounds accessible in the database. To reduce the size of the APMonitor executable, only some of the more common compounds are currently incorporated. Additional compounds can be easily added but require a rebuild of the executable.

**pwl**piece-wise linear function

**vsum(x)**vertical sum of a single variable in the data direction

**Array(type,size)**array of GEKKO objects

In Python GEKKO, objects are defined as components of the model as *m.object_name()*.

In Python GEKKO, objects are defined as components of the model such as *m.abs3()*.

(:sourceend:)

**Python GEKKO Example Usage (Array, abs3, sum)**

(:source lang=python:) from gekko import GEKKO import numpy as np m = GEKKO() x1 = m.Param(-2) x2 = m.Param(-1) x3 = np.linspace(0,1,6) x4 = m.Array(m.Param,3) y4 = m.Array(m.Var,3) for i in range(3):

x4[i].value=-0.2 y4[i] = m.abs3(x4[i])

- create variable

y = m.Var()

- y = 0.6 = -2 -1 + 3 + 0.6

m.Equation(y == sum([x1,x2]) + sum(x3) + sum(y4)) m.solve() # solve print('x1: ' + str(x1.value)) print('x2: ' + str(x2.value)) print('y: ' + str(y.value))

**sum**summation of elements in a list or numpy array

**abs2(x)**absolute value with MPCC (continuous first/second deriv)

**abs2(x)**absolute value with MPCC

**max2(x1,x2)**maximum value with MPCC**max3(x1,x2)**maximum value with binary variable for switch**min2(x1,x2)**minimum value with MPCC**min3(x1,x2)**minimum value with binary variable for switch

**sign2(x)**signum operator with MPCC (continuous first/second deriv)

**sign2(x)**signum operator with MPCC

**sign2(x)**signum operator with MPCC (continuous first/second deriv)**sign3(x)**signum operator with binary variable for switch

In Python GEKKO, some of the objects and functions are:

Python GEKKO has equation functions and pre-built objects. Some of the pre-built objects and equation functions are:

(:source lang=python:)

(:sourceend:)

(:table border=1 width=100% align=left bgcolor=#EEEEEE cellspacing=0:) (:cellnr:)

(:source lang=python:)

(:tableend:)

(:sourceend:)

Some pre-built objects are available in the APMonitor language to facilitate flowsheets of processing equipment while others are to simplify model building.

Objects are available in Python GEKKO and the APMonitor language to simplify the description of complex models.

- abs(x) absolute value |x|
- abs2(x) absolute value with MPCC (continuous first/second deriv)
- abs3(x) absolute value with binary variable for switch
- acos(x) inverse cosine, cos^-1(x)
- acosh(x) inverse hyperbolic cosine, cosh^-1(x)
- arx auto-regressive exogenous input (time series) model
- asin(x) inverse sine, sin^-1(x)
- asinh(x) inverse hyperbolic sine, sinh^-1(x)
- atan(x) inverse tangent, tan^-1(x)
- atanh(x) inverse hyperbolic tangent, tanh^-1(x)
- bspline bspline for 2D data
- cos(x) cosine
- cspline cubic spline for 1D data
- erf(x) error function
- erfc(x) complementary error function
- exp(x) e^x
- log(x) log_e (x), natural log
- log10(x) log_10 (x), log base 10
- periodic periodic (initial=final) for dynamic problems
- sin(x) sine
- sinh(x) hyperbolic sine
- sqrt(x) square root
- state_space continuous/discrete and dense/sparse state space
- tan(x) tangent
- tanh(x) hyperbolic tangent

**Python GEKKO Example (abs3)**

**abs(x)**absolute value |x|**abs2(x)**absolute value with MPCC (continuous first/second deriv)**abs3(x)**absolute value with binary variable for switch**acos(x)**inverse cosine, cos^-1(x)**acosh(x)**inverse hyperbolic cosine, cosh^-1(x)**arx**auto-regressive exogenous input (time series) model**asin(x)**inverse sine, sin^-1(x)**asinh(x)**inverse hyperbolic sine, sinh^-1(x)**atan(x)**inverse tangent, tan^-1(x)**atanh(x)**inverse hyperbolic tangent, tanh^-1(x)**bspline**bspline for 2D data**cos(x)**cosine**cspline**cubic spline for 1D data**erf(x)**error function**erfc(x)**complementary error function**exp(x)**e^x**log(x)**log_e (x), natural log**log10(x)**log_10 (x), log base 10**periodic**periodic (initial=final) for dynamic problems**sin(x)**sine**sinh(x)**hyperbolic sine**sqrt(x)**square root**state_space**continuous/discrete and dense/sparse state space**tan(x)**tangent**tanh(x)**hyperbolic tangent

**Python GEKKO Example Usage (abs3)**

In Python GEKKO, objects are defined as components of the model.

### Python GEKKO Object Library

In Python GEKKO, some of the objects and functions are:

- abs(x) absolute value |x|
- abs2(x) absolute value with MPCC (continuous first/second deriv)
- abs3(x) absolute value with binary variable for switch
- acos(x) inverse cosine, cos^-1(x)
- acosh(x) inverse hyperbolic cosine, cosh^-1(x)
- arx auto-regressive exogenous input (time series) model
- asin(x) inverse sine, sin^-1(x)
- asinh(x) inverse hyperbolic sine, sinh^-1(x)
- atan(x) inverse tangent, tan^-1(x)
- atanh(x) inverse hyperbolic tangent, tanh^-1(x)
- bspline bspline for 2D data
- cos(x) cosine
- cspline cubic spline for 1D data
- erf(x) error function
- erfc(x) complementary error function
- exp(x) e^x
- log(x) log_e (x), natural log
- log10(x) log_10 (x), log base 10
- periodic periodic (initial=final) for dynamic problems
- sin(x) sine
- sinh(x) hyperbolic sine
- sqrt(x) square root
- state_space continuous/discrete and dense/sparse state space
- tan(x) tangent
- tanh(x) hyperbolic tangent

**Python GEKKO Example (abs3)**

In Python GEKKO, objects are defined as components of the model such as *m.abs3()*.

### APMonitor Object Library

### Python GEKKO Object Library

In Python GEKKO, some of the objects and functions are:

- abs(x) absolute value |x|
- abs2(x) absolute value with MPCC (continuous first/second deriv)
- abs3(x) absolute value with binary variable for switch
- acos(x) inverse cosine, cos^-1(x)
- acosh(x) inverse hyperbolic cosine, cosh^-1(x)
- arx auto-regressive exogenous input (time series) model
- asin(x) inverse sine, sin^-1(x)
- asinh(x) inverse hyperbolic sine, sinh^-1(x)
- atan(x) inverse tangent, tan^-1(x)
- atanh(x) inverse hyperbolic tangent, tanh^-1(x)
- bspline bspline for 2D data
- cos(x) cosine
- cspline cubic spline for 1D data
- erf(x) error function
- erfc(x) complementary error function
- exp(x) e^x
- log(x) log_e (x), natural log
- log10(x) log_10 (x), log base 10
- periodic periodic (initial=final) for dynamic problems
- sin(x) sine
- sinh(x) hyperbolic sine
- sqrt(x) square root
- state_space continuous/discrete and dense/sparse state space
- tan(x) tangent
- tanh(x) hyperbolic tangent

### APMonitor Object Library

In Python GEKKO, some of the objects are:

- abs2 = absolute value with MPCC (continuous first/second deriv)
- abs3 = absolute value with binary variable for switch
- arx = auto-regressive exogenous input (time series) model
- bspline = bspline for 2D data
- cspline = cubic spline for 1D data
- periodic = periodic (initial=final) for dynamic problems
- state_space = continuous/discrete and dense/sparse state space

In Python GEKKO, objects are defined as components of the model.

(:source lang=python:) from gekko import GEKKO

- define new GEKKO model

m = GEKKO()

- variable

x = m.Var(-0.5)

- calculate y=abs(x) with abs3

y = m.abs3(x)

- solve with APOPT (MINLP solver)

m.solve()

- print solution

print('x: ' + str(x.value)) print('y: ' + str(y.value)) (:sourceend:)

### Object Library

### Python GEKKO Object Library

In Python GEKKO, some of the objects and functions are:

- abs(x) absolute value |x|
- abs2(x) absolute value with MPCC (continuous first/second deriv)
- abs3(x) absolute value with binary variable for switch
- acos(x) inverse cosine, cos^-1(x)
- acosh(x) inverse hyperbolic cosine, cosh^-1(x)
- arx auto-regressive exogenous input (time series) model
- asin(x) inverse sine, sin^-1(x)
- asinh(x) inverse hyperbolic sine, sinh^-1(x)
- atan(x) inverse tangent, tan^-1(x)
- atanh(x) inverse hyperbolic tangent, tanh^-1(x)
- bspline bspline for 2D data
- cos(x) cosine
- cspline cubic spline for 1D data
- erf(x) error function
- erfc(x) complementary error function
- exp(x) e^x
- log(x) log_e (x), natural log
- log10(x) log_10 (x), log base 10
- periodic periodic (initial=final) for dynamic problems
- sin(x) sine
- sinh(x) hyperbolic sine
- sqrt(x) square root
- state_space continuous/discrete and dense/sparse state space
- tan(x) tangent
- tanh(x) hyperbolic tangent

### APMonitor Object Library

Pre-build objects are available in the APMonitor language to facilitate flowsheets of chemical processing equipment. Objects are defined in the *Objects ... End Objects* section of the model file. New instances of an object are defined by declaring a new object name equal to the parent object type.

Some pre-built objects are available in the APMonitor language to facilitate flowsheets of processing equipment while others are to simplify model building.

In Python GEKKO, some of the objects are:

- abs2 = absolute value with MPCC (continuous first/second deriv)
- abs3 = absolute value with binary variable for switch
- arx = auto-regressive exogenous input (time series) model
- bspline = bspline for 2D data
- cspline = cubic spline for 1D data
- periodic = periodic (initial=final) for dynamic problems
- state_space = continuous/discrete and dense/sparse state space

In APMonitor, objects are defined in the *Objects ... End Objects* section of the model file. New instances of an object are defined by declaring a new object name equal to the parent object type.

- ARX, Linear Time Invariant Model

- VSum - Summation of a single variable in data dimension

! example use of ABS as MPEC

c = abs

a = abs

Connections x = a.x y = a.y End Connections Parameters x = -5 End Parameters Variables y End Variables

Objects c = abs End Objects

The object library consists of chemical processing equipment such as feed streams, reactors, pumps, mixers, flash columns, vessels, and distillation stages. It also includes other elements that support distributed control system emulation such as a LAG and a PID controller.

The object library consists of common mathematical functions and chemical processing equipment such as feed streams, reactors, pumps, mixers, flash columns, vessels, and distillation stages. It also includes other elements that support distributed control system emulation such as a LAG and a PID controller.

## Objects

(:table border=1 width=80%:)

(:table border=1 width=100%:)

(:table border=1 width=80%:)

(:table border=1 width=100%:)

(:table border=1 width=50% align=left bgcolor=#EEEEEE cellspacing=0:)

(:table border=1 width=100% align=left bgcolor=#EEEEEE cellspacing=0:)

- LTI - Linear time-invariant, discrete or continuous

- PWL - Piece-wise Linear

- Abs - Absolute value (MPEC)

- Max - Maximum value (MPEC)
- Min - Minimum value (MPEC)

- Periodic - Periodic boundary condition

- Sign - Number Sign (-1 or 1)

(:tableend:)

(:tableend:)

## Example - Mixer Application

- Solve Mixer Example Problem

- Sum - Summation of multiple parameters and/or variables

- Table - Data table that creates parameters or initializes variables

(:cellnr:) thermo_sh (:cell:) Solid Enthalpy (:cell:) J/kmol (:cellnr:) thermo_lh (:cell:) Liq Enthalpy (:cell:) J/kmol (:cellnr:) thermo_vh (:cell:) Vap Enthalpy (:cell:) J/kmol