Skip to content

Instantly share code, notes, and snippets.

View wd15's full-sized avatar

Daniel Wheeler wd15

View GitHub Profile
@wd15
wd15 / sfepy_lcbcs.py
Last active August 29, 2015 14:05
Sfepy code to test periodic displacements
import numpy as np
from sfepy.base.goptions import goptions
goptions['verbose'] = False
from sfepy.discrete.fem import Field
try:
from sfepy.discrete.fem import FEDomain as Domain
except ImportError:
from sfepy.discrete.fem import Domain
from sfepy.discrete import (FieldVariable, Material, Integral, Function,
Equation, Equations, Problem)
@wd15
wd15 / gist:8274429e3b4179c3d74f
Created September 4, 2014 20:32
Sfepy code to test displacement in 3D
import numpy as np
from sfepy.base.goptions import goptions
goptions['verbose'] = True
from sfepy.discrete.fem import Field
try:
from sfepy.discrete.fem import FEDomain as Domain
except ImportError:
from sfepy.discrete.fem import Domain
from sfepy.discrete import (FieldVariable, Material, Integral, Function,
Equation, Equations, Problem)
import numpy as np
from pymks import MKSRegressionModel
from pymks.datasets import make_elastic_FE_strain_delta
from pymks import DiscreteIndicatorBasis
from pymks.datasets.elastic_FE_simulation import ElasticFESimulation
from pymks.tools import draw_strains_compare
import matplotlib.pyplot as plt
elastic_modulus = (80, 100)
poissons_ratio = (0.3, 0.3)
@wd15
wd15 / pickle_mks.py
Last active August 29, 2015 14:06
Demo of how to pickle an MKS model
from pymks.datasets import make_elastic_FE_strain_delta
X_delta, strains_delta = make_elastic_FE_strain_delta(elastic_modulus=(80, 120),
poissons_ratio=(0.3, 0.3),
size=(15, 15))
from pymks import MKSRegressionModel
from pymks.bases import DiscreteIndicatorBasis
basis = DiscreteIndicatorBasis(n_states=2)
@wd15
wd15 / show.py
Last active August 29, 2015 14:06
Plotting subdomain with FiPy
import fipy as fp
L = 12
nx = 200.
ny = nx
dx = L/nx
dy = L/ny
mesh = fp.Grid2D(nx=nx, ny=ny, dx=dx, dy=dy) + [[-L/2]]
x, y = mesh.getCellCenters()
import fipy as fp
L = 12
nx = 200.
ny = nx
dx = L/nx
dy = L/ny
mesh = fp.Grid2D(nx=nx, ny=ny, dx=dx, dy=dy) + [[-L/2]]
x, y = mesh.getCellCenters()
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 23 07:33:14 2014
@author: olive
"""
""" a model to calculate radial injeciton of heat and a non reactive tracer
in a 2 layer domain
data from hecht mendez"""
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wd15
wd15 / vanleer.py
Last active August 29, 2015 14:09
Demo of Van Leer convection term in FiPy showing how it preserves the shock quite well
from fipy import CellVariable, Grid1D, TransientTerm
from fipy import MatplotlibViewer, VanLeerConvectionTerm
from fipy import FaceVariable, ImplicitSourceTerm
length = 1.
nx = 100
dx = length/nx
mesh = Grid1D(dx=dx, nx=nx)
TG = CellVariable(mesh = mesh, hasOld = True, name = 'TG')
@wd15
wd15 / gist:dd9d9950169fb570c564
Created February 5, 2015 16:06
mesh2Dvector.py
import fipy as fp
nx = ny = 20
mesh = fp.Grid2D(nx=nx, ny=ny, dx=0.25, dy=0.25)
noise = fp.GaussianNoiseVariable(mesh=mesh,
mean=0.5,
variance=0.01).value