def PHI_(x): """ x must be in SI (metres) for this function to work PHI is only calculated correctly when the arg is mm """ return -1. * np.log2(x * 1000.) def DD_(x): return 2.**(-x) # Top and bottom mesh created separately meshA = pss.Mesh(X=500, Y=1200, cellsize=2.5e-6) meshB = pss.Mesh(X=500, Y=1200, cellsize=2.5e-6) meshA.label = 'A' meshB.label = 'B' # target volume (area) fraction vfrac = 0.5 # Store grain objects in list, 'grains' grains = [] # Minimum krubeim phi = min resolution (4 cppr) # Max ... '' '' '' '' = max resolution (200 cppr) # Max res is one which still fits in the domain minphi = -np.log2(2 * 4 * 2.5e-3) maxphi = -np.log2(2 * 200 * 2.5e-3)
import pySALESetup as pss import numpy as np mesh1 = pss.Mesh(X=100,Y=500,cellsize=.5e-5) # Two test areas A and B in each test area one type of grain is tested in 4 different orientations # in principle each grain is independent of all the others. How will each respond? x = .25e-3 yA = 1.875e-3 yB = 0.625e-3 r = 0.5 r *= np.pi off = .5 R = [[-1.,-1.], [-1.,1.], [1.,-1.], [1.,-1.]] R[2][1] += off #grain = pss.Grain(shape='file',File='grain_arearatio-0.725.txt',eqr=20.,rot=r) #grain1 = pss.Grain(shape='polygon',poly_params=R,eqr=20.,rot=r) #grain2 = pss.Grain(shape='polygon',poly_params=R,eqr=20.,rot=r*3) grain = pss.Grain(shape='circle',eqr=20)
# reverse of krumbein phi def DD_(x): return 2.**(-x) # reverse of krumbein phi # duplicate of above; except converts to metres # and returns radius, not diameter def reverse_phi(p): return (2**(-p)) * .5 * 1.e-3 # Top and bottom mesh created separately # Create four meshes meshA = pss.Mesh(X=500, Y=500, cellsize=2.5e-6) meshA.label = 'A' # target volume (area) fraction vfrac = 0.5 # Store grain objects in list, 'grains' grainsA = [] grainsB = [] # Minimum krubeim phi = min resolution (4 cppr) # Max ... '' '' '' '' = max resolution (200 cppr) # Max res is one which still fits in the domain minres = 10 maxphi = -np.log2(10 * 2.5e-3) minphi = -np.log2(90 * 2.5e-3)
import pySALESetup as pss import numpy as np mesh1 = pss.Mesh(X=200,Y=600,cellsize=.5e-5) # square rot 00 poly_params=[[-1.,-1.],[-1.,1.],[1.,1.],[1.,-1.]] # square rot 45 poly_params=[[-1.,0.],[0.,1.],[1.,0.],[0.,-1.]] #grain1 = pss.Grain(shape='polygon',eqr=10.,poly_params=poly_params) #grain2 = pss.Grain(shape='polygon',eqr=10.,poly_params=poly_params) #grain1 = pss.Grain(eqr=10.) #grain2 = pss.Grain(eqr=10.) # Test area A (square lattice) ymin = 2.e-3 ymax = 2.5e-3 XcoordsA = np.linspace(0.,1.e-3,5) YcoordsA = np.linspace(2.e-3,3.e-3,5) # Test area B (hexagonal lattice) ymin = .5e-3 ymax = 1.e-3 XcoordsB = np.linspace(0.,1.e-3,5) YcoordsB = np.linspace(0.e-3,1.e-3,5) c = 0 rot = 0 for yA,yB in zip(YcoordsA,YcoordsB): phi = rot*np.pi/180. print phi grain = pss.Grain(shape='polygon',eqr=10.,poly_params=poly_params,rot=phi)
import pySALESetup as pss import numpy as np mesh1 = pss.Mesh(X=500,Y=1500) grain1 = pss.Grain(eqr=50.) grain2 = pss.Grain(eqr=50.) # Test area A (square lattice) ymin = 2.e-3 ymax = 2.5e-3 XcoordsA = np.linspace(0.,1.e-3,5) YcoordsA = np.linspace(2.e-3,2.5e-3,3) # Test area B (hexagonal lattice) ymin = .5e-3 ymax = 1.e-3 XcoordsB = np.linspace(0.,1.e-3,5) YcoordsB = np.linspace(.5e-3,1.e-3,3) c = 0 for yA,yB in zip(YcoordsA,YcoordsB): if c == 0: c = 1 else: c = 0 for xA,xB in zip(XcoordsA,XcoordsB): if c == 0: xB += .125e-3 elif c == 1: pass #xB -= .125e-3 grain1.place(xA,yA,1,mesh1) grain2.place(xB,yB,2,mesh1)