Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
modelibPy11.py
Go to the documentation of this file.
1# /opt/local/bin/python3.12 modelibPy11.py
2import sys
3import os
4import matplotlib.pyplot as plt
5import numpy as np
6sys.path.append("../build/tools/pyMoDELib")
7import pyMoDELib
8
9simulationDir=os.path.abspath("../tutorials/crossSlip")
10ddBase=pyMoDELib.DefectiveCrystalBase(simulationDir)
11
12# Microstructure Generation
13microstructureGenerator=pyMoDELib.MicrostructureGenerator(ddBase)
14
15spec=pyMoDELib.ShearLoopDensitySpecification()
16spec.targetDensity=5.0e12
17spec.radiusDistributionMean=1.0e-07
18spec.radiusDistributionStd=0.0e-8
19spec.numberOfSides=20
20spec.allowedGrainIDs=np.array([-1]); # set of grain IDs where loops are allowed. Use -1 for all grains
21allowedSlipSystemIDs=np.array([-1]); # set of allowed slip system IDs. Use -1 for all slip systems
22#microstructureGenerator.addShearLoopDensity(spec)
23
24spec=pyMoDELib.ShearLoopIndividualSpecification()
25spec.slipSystemIDs=[0,-1]
26spec.loopRadii=[27.0e-8,27.0e-8]
27spec.loopCenters=np.array([[200.0,0.0,0.0],[0.0,0.0,0.0]])
28spec.loopSides=[10,10]
29#microstructureGenerator.addShearLoopIndividual(spec)
30
31spec=pyMoDELib.PeriodicDipoleDensitySpecification()
32spec.targetDensity=5.0e13
33#microstructureGenerator.addPeriodicDipoleDensity(spec)
34
35spec=pyMoDELib.PeriodicDipoleIndividualSpecification()
36spec.slipSystemIDs=[0,-1]
37spec.exitFaceIDs=[1,0]
38spec.dipoleCenters=np.array([[200.0,0.0,0.0],[0.0,0.0,0.0]])
39spec.dipoleHeights=[100.,100.]
40spec.nodesPerLine=[4,4]
41spec.glideSteps=[10.,10.]
42#microstructureGenerator.addPeriodicDipoleIndividual(spec)
43
44spec=pyMoDELib.PrismaticLoopDensitySpecification()
45spec.targetDensity=5.0e13
46spec.radiusDistributionMean=3e-08
47spec.radiusDistributionStd=0e-08
48spec.allowedGrainIDs=np.array([-1]); # set of grain IDs where loops are allowed. Use -1 for all grains
49allowedSlipSystemIDs=np.array([-1]); # set of slip system IDs whose Burgers vector are allowed to be the prism axis. Use -1 for all slip systems
50microstructureGenerator.addPrismaticLoopDensity(spec)
51
52spec=pyMoDELib.PrismaticLoopIndividualSpecification()
53spec.slipSystemIDs=[0,7,13]
54spec.loopRadii=[5e-8,2e-7,2e-8]
55spec.loopCenters=np.array([[0,0,0],[500,600,500],[500,500,500]])
56spec.glideSteps=[10.,10.,300.]
57#microstructureGenerator.addPrismaticLoopIndividual(spec)
58
59spec=pyMoDELib.FrankLoopsDensitySpecification()
60spec.targetDensity=5.0e12
61spec.radiusDistributionMean=1.0e-07
62spec.radiusDistributionStd=0.0e-8
63spec.numberOfSides=20
64spec.areVacancyLoops=1
65microstructureGenerator.addFrankLoopsDensity(spec)
66
67spec=pyMoDELib.FrankLoopsIndividualSpecification()
68spec.planeIDs=[0,-1]
69spec.loopRadii=[27.0e-8,27.0e-8]
70spec.loopCenters=np.array([[200.0,0.0,0.0],[0.0,0.0,0.0]])
71spec.loopSides=[10,10]
72spec.isVacancyLoop=[1,0]
73#microstructureGenerator.addFrankLoopsIndividual(spec)
74
75spec=pyMoDELib.StackingFaultTetrahedraDensitySpecification()
76spec.targetDensity=1.0e21
77spec.sizeDistributionMean=2.5e-08
78spec.sizeDistributionStd=1.0e-9
79#microstructureGenerator.addStackingFaultTetrahedraDensity(spec)
80
81spec=pyMoDELib.StackingFaultTetrahedraIndividualSpecification()
82spec.planeIDs=[0,1]
83spec.areInverted=[0,0]
84spec.sizes=[2.5e-08,2.5e-08]
85spec.basePoints=np.array([[0.0,0.0,0.0],[100.0,0.0,0.0]])
86#microstructureGenerator.addStackingFaultTetrahedraIndividual(spec)
87
88spec=pyMoDELib.SphericalInclusionDensitySpecification()
89spec.targetDensity=1e20;
90spec.diameterLognormalDistribution_M=3.11e-8; #[m] of log-normal diameter M
91spec.diameterLognormalDistribution_S=0.38; #[-] of log-normal distribution parameter S
92spec.diameterLognormalDistribution_A=1.05e-8; #[m] log-normal distribution parameter A
93spec.crystalEigenDistortion=[0.003,0.0,0.0,0.0,0.003,0.0,0.0,0.0,0.003] # [-] inclusion eigendistortion components 11,12,13,21,22,23,31,32,33
94spec.patternVector_SI=[0.0,0.0,0.0e-7]; # [m] defines a planar pattern for the inclusions. Direction is plane normal, magnitude is plane spacing. Zero to zero for no pattern
95spec.allowOverlap=0;
96spec.allowOutside=0;
97spec.velocityReductionFactor=1.0;
98spec.phaseID=0;
99#microstructureGenerator.addSphericalInclusionDensity(spec)
100
101spec=pyMoDELib.SphericalInclusionIndividualSpecification()
102spec.radii_SI=[27.0e-9,27.0e-9]
103spec.centers=np.array([[200.0,0.0,0.0],[-200.0,0.0,0.0]])
104spec.crystalEigenDistortions=np.array([[1.0e-3,0.0,0.0,0.0,1.0e-3,0.0,0.0,0.0,1.0e-3],[2.0e-3,0.0,0.0,0.0,2.0e-3,0.0,0.0,0.0,2.0e-3]])
105spec.velocityReductionFactors=[1.0,1.0]
106spec.phaseIDs=[0,0]
107spec.allowOverlap=0
108spec.allowOutside=0
109#microstructureGenerator.addSphericalInclusionIndividual(spec)
110
111spec=pyMoDELib.PolyhedronInclusionIndividualSpecification()
112spec.mshFile="../Library/Meshes/unitCube8_2D.msh"
113spec.X0=np.array([[300.0,100.0,0.0],[-200.0,0.0,0.0]])
114spec.F=np.array([[200.0,0.0,0.0],[0.0,200.0,0.0],[0.0,0.0,200.0]])
115spec.crystalEigenDistortion=np.array([[1.0e-3,0.0,0.0,0.0,1.0e-3,0.0,0.0,0.0,1.0e-3]])
116spec.velocityReductionFactor=1.0
117spec.phaseID=0
118microstructureGenerator.addPolyhedronInclusionIndividual(spec)
119
120microstructureGenerator.writeConfigFiles(1) # write evel_0.txt (optional)
121
122# DefectiveCrystal
123defectiveCrystal=pyMoDELib.DefectiveCrystal(ddBase)
124defectiveCrystal.initializeConfiguration(microstructureGenerator.configIO)
125
126points=np.array([[0.0,0.0,0.0],[1.0,0.0,0.0],[2.0,0.0,0.0]])
127#
128disp=defectiveCrystal.displacement(points)
129print(disp)
130
131# DislocationNetwork
132DN=defectiveCrystal.dislocationNetwork()
133print(len(DN.loops()))
134print(len(DN.loopNodes()))
135
136meshSize=100
137for loopID in DN.loops():
138 loop=DN.loops().getRef(loopID)
139# meshedLoopVector=loop.meshed(meshSize)
140# for meshedLoop in meshedLoopVector:
141# disp=meshedLoop.plasticDisplacement(points)
142# print(disp)
143#
144#rp=ddBase.poly.grain(1)
145
146
147
148
149
150#print(rp)
151
152#mesh=pyMoDELib.SimplicialMesh()
153#print(mesh.xMin())
154
155#
156
192