Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
"""
fea method for a one-dimensional model problem:
require:
- numpy: 1.8.1
- scipy: 0.14.0
Yung Wong <yungwong<yungwong.seu@gmail.com>
May 26 09:26:38 2014
@windstriver
windstriver / flow_over_flat_plate.c
Created December 23, 2014 12:52
N-S equation, time marching
/*
* Navierstokes Time marching 2D.
* Balaji Sankar.
*/
//The Only stuff you need to Change are in this box.
//*Please*Do not tamper with the other stuff unless you know exactly what you are doing.
//Blasius solution
//=============================================================
// Number of divisions in X axis
#define IMAX 70
@windstriver
windstriver / apdl_mac
Created April 20, 2015 06:20
ANSYS Workbench Sending Commands to Mechanical APDL
! set parameters
xlen=3
ylen=4
zlen=7
! define model
/prep7
block,,xlen,,ylen,,zlen
et,1,185
mp,ex,1,1e6
@windstriver
windstriver / sap2000_oapi_python
Created April 20, 2015 06:25
Remarks This example is written for Python 3.0 or higher. It is based on the Sap2000 verification problem Example 1-001. This example creates the example verification problem from scratch, runs the analysis, extracts results, and compares the results with hand calculated values.. Example 1. Download and install Python 3.0 or higher for Windows. …
import os
import win32com.client
#create Sap2000 object
SapObject = win32com.client.Dispatch("Sap2000v15.SapObject")
#start Sap2000 application
SapObject.ApplicationStart()
#create SapModel object
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[scale=2]
\shade[top color=blue,bottom color=gray!50] (0,0) parabola (1.5,2.25) |- (0,0);
\draw (1.05cm,2pt) node[above] {$\displaystyle\int_0^{3/2}\!\!x^2\mathrm{d}x$};
@windstriver
windstriver / architecture_of_matplotlib.py
Last active August 30, 2015 00:43
A simple Python script illustrating the architecture of matplotlib http://www.aosabook.org/en/matplotlib.html
# A simple Python script illustrating the architecture of matplotlib.
# It defines the backend, connects a Figure to it,
# uses the array library numpy to create 10,000 normally distributed random
# numbers, and plots a histogram of these.
# http://www.aosabook.org/en/matplotlib.html
# Import the FigureCanvas from the backend of your choice
# and attach the Figure artist to it.
import numpy as np
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
@windstriver
windstriver / tikz_datavisualization.tex
Created August 30, 2015 00:49
Data visualization example from TikZ & PGF Manual
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization}
\usetikzlibrary{datavisualization.formats.functions}
\begin{document}
\begin{tikzpicture}
\datavisualization [scientific axes=clean]
[
@windstriver
windstriver / parametric_plot_with_tikz.tex
Created August 30, 2015 01:32
An example of parametric plot using TikZ from *TikZ & PGF Manual*.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2]
\draw[gray,very thin] (-1.9,-1.9) grid (2.9,3.9)
[step=0.25cm] (-1,-1) grid (1,1);
\draw[blue] (1,-2.1) -- (1,4.1); % asymptote
\draw[->] (-2,0) -- (3,0) node[right] {$x(t)$};
@windstriver
windstriver / brillouin-function.tex
Created June 27, 2016 12:06
Example: Plot of the Brillouin Function
% Brillouin Function
% Author: Mark Wibrow
\documentclass[tikz,border=10pt]{standalone}
\usepackage{amsmath}
\usetikzlibrary{arrows.meta}
\directlua{
function coth (i)
return math.cosh(i) / math.sinh(i)
end
@windstriver
windstriver / fun.py
Created June 28, 2016 01:38
Plot complex function using TikZ & Python
import numpy as np
def coth(x):
return np.cosh(x)/np.sinh(x)
def brilloutin(J, x):
if x == 0:
return 0
else:
return (2*J+1)/(2*J)*coth((2*J+1)/(2*J)*x) - 1/(2*J)*coth(1/(2*J)*x)