Skip to content

Instantly share code, notes, and snippets.

@tkphd
Created September 9, 2015 14:38
Show Gist options
  • Save tkphd/2f8ac66fe2f883fee352 to your computer and use it in GitHub Desktop.
Save tkphd/2f8ac66fe2f883fee352 to your computer and use it in GitHub Desktop.
from fipy import *
from scipy import interpolate
import numpy as np
mesh = Grid1D(dx=3, nx=10)
datx = mesh.cellCenters[0]
daty = np.sin(4*np.pi*datx/10)
valumesh = Grid1D(dx=1, nx=10)
valu = CellVariable(name="val", mesh=valumesh)
x = mesh.cellCenters[0]
liny = interpolate.interp1d(datx, daty, kind='linear')
print liny(1.5)
valu.setValue(liny(x), where=np.ones(10))
view = Viewer(vars=(valu,))
view.plot()
raw_input("Consider graph. Press return to terminate program...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment