This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
import numpypy as np # for compatibility with numpy in pypy | |
except: | |
import numpy as np # if using numpy in cpython | |
## Tri Diagonal Matrix Algorithm(a.k.a Thomas algorithm) solver | |
def TDMAsolver(a, b, c, d): | |
''' | |
TDMA solver, a b c d can be NumPy array type or Python list type. | |
refer to http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import min, max | |
from scipy import linspace | |
from scipy.signal import lti, step, impulse | |
# making transfer function | |
# example from Ogata Modern Control Engineering | |
# 4th edition, International Edition page 307 | |
# num and den, can be list or numpy array type | |
num = [6.3223, 18, 12.811] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
# using mpmath for arbitrary precision, | |
# sympy for showing the equation in pretty way | |
if sys.platform == 'linux2': | |
import mpmath as mp, sympy as sm | |
elif sys.platform == 'win32': | |
import sympy as sm | |
mp = sm.mpmath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
# using mpmath for arbitrary precision, | |
# sympy for showing the equation in pretty way | |
if sys.platform == 'linux2': | |
import mpmath as mp, sympy as sm | |
elif sys.platform == 'win32': | |
import sympy as sm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing modules | |
from matplotlib import pyplot as plt # plotting | |
import numpy as np # numerical array | |
# Undersaturated Oil Reservoir | |
### Known data ### | |
# Reservoir | |
P_res = 5500.0 # Reservoir Pressure [psia] | |
P_bp = 3000.0 # Bubble Point Pressure [psia] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# snippet from numpy 1.8.1 | |
class IntelEM64TCCompiler(UnixCCompiler): | |
""" A modified Intel x86_64 compiler compatible with a 64bit gcc built Python. | |
""" | |
compiler_type = 'intelem' | |
cc_exe = 'icc -m64 -fPIC' | |
cc_args = "-fPIC" | |
def __init__ (self, verbose=0, dry_run=0, force=0): | |
UnixCCompiler.__init__ (self, verbose, dry_run, force) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# snippet from numpy 1.8.1 | |
class IntelEM64TFCompiler(IntelFCompiler): | |
compiler_type = 'intelem' | |
compiler_aliases = () | |
description = 'Intel Fortran Compiler for 64-bit apps' | |
version_match = intel_version_match('EM64T-based|Intel\\(R\\) 64|64|IA-64|64-bit') | |
possible_executables = ['ifort', 'efort', 'efc'] |