How to use the gekko.gekko function in gekko

To help you get started, we’ve selected a few gekko 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 BYU-PRISM / GEKKO / tests / hw_LMPC.py View on Github external
u_ss = 280.0
# Feed Temperature (K)
Tf = 350
# Feed Concentration (mol/m^3)
Caf = 1

# Steady State Initial Conditions for the States
Ca_ss = 1
T_ss = 304
x0 = np.empty(2)
x0[0] = Ca_ss
x0[1] = T_ss

#%% GEKKO linear MPC

m = gekko()

m.time = [0,.1,.2,.3,.4,.5,.75,1,1.5,2,3,4,5]

# initial conditions
Tc0 = 280
T0 = 304
Ca0 = 1.0

tau = m.Const(value = 0.5)
Kp = m.Const(value = 1)

m.Tc = m.MV(value = Tc0,lb=250,ub=350)
m.T = m.CV(value = T_ss,ub=400)

m.Equation(tau * m.T.dt() == -(m.T - T0) + Kp * (m.Tc - Tc0))
github BYU-PRISM / GEKKO / tests / exam_2016_3.py View on Github external
import gekko
import numpy as np

#%% Initialize model

m = gekko.gekko()

## Parameters
N = m.Param(value=3.2e6)
mu = m.Param(value=7.8e-4)
gamma = m.FV(value=0.07)
rep_frac = m.Param(value=0.45)
cases = m.MV(value=180,lb=0)

##Variables
beta = m.Var(value=10)
S = m.Var(value=0.06*N.value,lb=0,ub=N.value)
I = m.Var(value=0.0001*N.value,lb=0,ub=N.value)

##Intermediate
R = m.Intermediate(beta*S*I/N)
github BYU-PRISM / GEKKO / examples / mpc_nonlinear.py View on Github external
# Steady State Initial Condition
u_ss = 280.0
# Feed Temperature (K)
Tf = 350
# Feed Concentration (mol/m^3)
Caf = 1

# Steady State Initial Conditions for the States
Ca_ss = 1
T_ss = 304
x0 = np.empty(2)
x0[0] = Ca_ss
x0[1] = T_ss

#%% GEKKO nonlinear MPC
m = gekko()
m.time = [0,0.02,0.04,0.06,0.08,0.1,0.12,0.15,0.2]

# Volumetric Flowrate (m^3/sec)
q = 100
# Volume of CSTR (m^3)
V = 100
# Density of A-B Mixture (kg/m^3)
rho = 1000
# Heat capacity of A-B Mixture (J/kg-K)
Cp = 0.239
# Heat of reaction for A->B (J/mol)
mdelH = 5e4
# E - Activation energy in the Arrhenius Equation (J/mol)
# R - Universal Gas Constant = 8.31451 J/mol-K
EoverR = 8750
# Pre-exponential factor (1/sec)