from matplotlib import pylab as plt import numpy as np from IPython import embed """ Main entry point of the simulation. """ from src import Warp from src.DIRK import DIRK_Monolithic endpts = [[[-10.0, 0.0, -1.0], [10.0, 0.0, -1.0]]] warp = Warp(endpts) zero = Constant((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)) extend = Constant((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)) left = CompiledSubDomain("near(x[0], side) && on_boundary", side=-10.0) right = CompiledSubDomain( "near(x[0], side) && near(x[2], -1.0) && on_boundary", side=10.0) def apply_BCs(K, R, hold=False): bcleft = MultiMeshDirichletBC(warp.mmfs, zero, left) bcleft.apply(K, R) if not hold: bcright = MultiMeshDirichletBC(warp.mmfs, extend, right)
endpts.append([[2.5 + scale * l[0], -5.0, scale * l[1]], [2.5 + scale * l[0], 5.0, scale * l[1]]]) for l in pattern: endpts.append([[-5.0, scale * l[0] + 2.5, scale * l[1]], [5.0, scale * l[0] + 2.5, scale * l[1]]]) for l in pattern: endpts.append([[-5.0, scale * l[0] - 2.5, scale * l[1]], [5.0, scale * l[0] - 2.5, scale * l[1]]]) # endpts = [ # [ [ 1.0,-10.0, -0.1], [ 1.0,10.0, -0.1] ], # [ [ -3.0,-10.0, -0.1], [ -3.0,10.0, -0.1] ], # [ [-10.0, 0.05,-0.05], [10.0, 0.05, -0.05] ] , # [ [-10.0, -0.06,-0.05], [10.0, -0.06, -0.05] ] ] warp = Warp(endpts, cutoff=1.0) zero = Constant((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)) extend = Constant((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)) left = CompiledSubDomain("on_boundary", side=-10.0) right = CompiledSubDomain( "near(x[0], side) && near(x[2], -1.0) && on_boundary", side=10.0) def apply_BCs(K, R, t, hold=False): # embed() bcleft = MultiMeshDirichletBC(warp.mmfs, zero, left) bcleft.apply(K, R) if not hold:
from src.DIRK import * from src import Warp from src.Forms import MultiphysicsProblem # TODO: Pass in M # Make a warp data structure and march it one step endpts = [[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]], [[0.0, 0.1, 0.0], [1.0, 0.1, 0.0]], [[0.0, 0.4, 0.0], [1.0, 0.4, 0.0]]] defaults = {'mu': 10.0, 'radius': 0.2} props = [{'radius': 0.1}, {'mu': 1.0}, {}] warp = Warp(endpts, props, defaults, MultiphysicsProblem) warp.update() def sys(time): return warp.assemble_forms(['F', 'AX', 'AV'], 'W') def bcapp(K, R, time, hold): print "Meh. Save this for an engineering test", time pass dirk = DIRK_Monolithic(0.1, LDIRK[2], sys, warp.update, bcapp, warp.fields['wx'].vector(), warp.fields['wv'].vector(),
import numpy as np from IPython import embed """ Main entry point of the simulation. """ from src import Warp endpts = [[[-0.0, -1.0, -0.1], [-0.0, 1.0, -0.1]], [[0.9, -1.0, -0.1], [0.9, 1.0, -0.1]], [[-1.0, 0.0, 0.0], [1.0, 0.0, 0.0]], [[-1.0, 0.2, 0.0], [1.0, 0.2, 0.0]]] warp = Warp(endpts, cutoff=0.3) warp.create_contacts() #[(0,2), (1,2)]) DelT = MultiMeshFunction(warp.Tmmfs) warp.assemble_thermal_system() warp.apply_thermal_bcs(Constant(1.0)) solve(warp.AT, DelT.vector(), warp.RT) for i, fib in enumerate(warp.fibrils): fib.T.vector()[:] = DelT.vector()[warp.Tmdof.part(i).dofs()] warp.output_states("post/fibril_{0}_temp.pvd", 1) # warp.output_contacts("post/contact_{2}_{0}_{1}.pvd") embed()
""" from src import Warp from src.DIRK import DIRK_Monolithic endpts = [] restL = 1.75 width = 1.5 scale = 0.15 for x in np.linspace(-width+scale,width-scale, width/scale): endpts.append([ [ -restL, x, 0.0 ], [ restL, x, 0.0 ] ]) NW = len(endpts) warp = Warp(endpts, cutoff=1.5) zero = Constant((0.0,0.0,0.0)) #, 0.0,0.0,0.0, 0.0,0.0,0.0, 0.0,0.0)) bound = CompiledSubDomain("on_boundary") subs = MultiMeshSubSpace(warp.mmfs,0) bcall = MultiMeshDirichletBC(subs, zero, bound) def apply_BCs(K,R,t,hold=False): bcall.apply(K,R) def initialize(): for i,fib in enumerate(warp.fibrils): fib.wx.interpolate(Expression(( "x[0]*sq + o*sin(x[0]*p)", "A1*cos((x[0]*p)/2.)",
from IPython import embed """ Main entry point of the simulation. """ from src import Warp endpts = [ [[-10.0, 0.0, -0.149], [10.0, 0.0, -0.149]], # [ [-1.0, 0.0,0.0], [1.0, 0.0, 0.0] ] , [[-10.0, 0.0, 0.0], [10.0, 0.0, 0.0]] ] warp = Warp(endpts, monolithic=False, cutoff=1.5) Delw = MultiMeshFunction(warp.mmfs) embed() maxiter = 10 tol = 1.0e-12 Nsteps = 64 for t in xrange(1, Nsteps): warp.create_contacts() # embed() it = 0 eps = 1.0 print "Simulation step ", t, ":" extend = Expression(( " 0.0", "-(x[1]*cos(theta)-x[2]*sin(theta)-x[1]-(x[1]*cos(old_theta)-x[2]*sin(old_theta)-x[1]))",
from matplotlib import pylab as plt import numpy as np from IPython import embed """ Main entry point of the simulation. """ from src import Warp endpts = [[[-10.0, 0.0, -1.0], [10.0, 0.0, -1.0]]] warp = Warp(endpts) Delw = MultiMeshFunction(warp.mmfs) warp.assemble_system() embed() maxiter = 10 tol = 1.0e-9 it = 0 eps = 1.0 warp.create_contacts() while eps > tol and it < maxiter: warp.assemble_system() warp.AX.ident_zeros()
# # Define the end points # pattern = [[-0.5, sqrt(3.0) / 2.0], [0.5, sqrt(3.0) / 2.0], [-1.0, 0.0], [0.0, 0.0], [1.0, 0.0], [-0.5, -sqrt(3.0) / 2.0], [0.5, -sqrt(3.0) / 2.0]] endpts = [] scale = 0.16 for l in pattern: endpts.append([[-5.0, scale * l[0], scale * l[1]], [5.0, scale * l[0], scale * l[1]]]) # endpts = [[ [ -5.0, 0.074, 0.0], [ 5.0, 0.074, 0.0 ] ], # [ [ -5.0, -0.074, 0.0 ], [ 5.0, -0.074, 0.0 ] ]] warp = Warp(endpts, monolithic=True, cutoff=0.5) # contactpairs = [ (0,3), (1,3), (2,3), # (4,3), (5,3), (6,3) ] # # Set up the BC applying routines # zero = Constant((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)) # rotate = Expression((" 0.0", # " 0.0", " rate", # "0.0","0.0","0.0", "0.0","0.0","0.0", "0.0","0.0"), # rate=Rate, # theta=0.0, # old_theta=0.0) rotate = Expression(( " 0.0",