Skip to content

Instantly share code, notes, and snippets.

@ofan666
ofan666 / intel.py
Last active August 29, 2015 14:01
A working and passed all test for Numpy/Scipy with icc/ifort 14.0.2 and Intel MKL 11.1 Update 2.
# 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']
@ofan666
ofan666 / intelccompiler.py
Last active August 29, 2015 14:01
For Numpy/Scipy with icc/ifort 14.0.2 and Intel MKL 11.1 Update 2.
# 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)
@ofan666
ofan666 / ex_vogel_IPR_uOil.py
Created February 22, 2012 07:16
Undersaturated Oil Reservoir IPR using Vogel's method based on test points - http://petropy.blogspot.com/2011/09/ipr-using-vogels-method-based-on-test.html
# 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]
#!/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
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
@ofan666
ofan666 / ex_LTI_TransientRespond.py
Created February 22, 2012 06:55
LTI Transient-Response Analysis using Python(scipy, matplotlib) - http://ofan666.blogspot.com/2011/04/lti-transient-response-analysis-using.html
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]
@ofan666
ofan666 / TDMAsolver.py
Created February 21, 2012 11:11
Tridiagonal Matrix Algorithm solver in Python, using Numpy array - http://ofan666.blogspot.com/2012/02/tridiagonal-matrix-algorithm-solver-in.html
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