Skip to content

Commit 0166334

Browse files
committed
Merge branch 'test-examples-with-doctest' into 'development'
example output tested with doctest See merge request damask/DAMASK!951
2 parents 514b84f + 60389f3 commit 0166334

16 files changed

+316
-144
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*.pdf binary
1111
*.dream3d binary
1212
*.pbz2 binary
13+
*.vtk binary
1314

1415
# ignore files from MSC.Marc in language statistics
1516
install/MarcMentat/** linguist-vendored

python/damask/_colormap.py

+2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def from_range(low: FloatSequence,
185185
--------
186186
>>> import damask
187187
>>> damask.Colormap.from_range((0,0,1),(0,0,0),'blue_to_black')
188+
Colormap: blue_to_black
188189
189190
"""
190191
toMsh = dict(
@@ -248,6 +249,7 @@ def from_predefined(name: str,
248249
--------
249250
>>> import damask
250251
>>> damask.Colormap.from_predefined('strain')
252+
Colormap: strain
251253
252254
"""
253255
if name in cm.__dict__:

python/damask/_configmaterial.py

+114-74
Original file line numberDiff line numberDiff line change
@@ -197,42 +197,43 @@ def from_table(table: Table,*,
197197
Examples
198198
--------
199199
>>> import damask
200-
>>> import damask.ConfigMaterial as cm
200+
>>> from damask import ConfigMaterial as cm
201201
>>> t = damask.Table.load('small.txt')
202202
>>> t
203-
3:pos pos pos 4:qu qu qu qu phase homog
204-
0 0 0 0 0.19 0.8 0.24 -0.51 Aluminum SX
205-
1 1 0 0 0.8 0.19 0.24 -0.51 Steel SX
206-
2 1 1 0 0.8 0.19 0.24 -0.51 Steel SX
203+
3:pos pos pos 4:qu qu qu qu phase homog
204+
0 0 0 0 1.0 0.0 0.0 0.0 Aluminum SX
205+
1 1 0 0 0.0 1.0 0.0 0.0 Steel SX
206+
2 1 1 0 0.0 1.0 0.0 0.0 Steel SX
207+
207208
>>> cm.from_table(t,O='qu',phase='phase',homogenization='homog')
208-
material:
209-
- constituents:
210-
- O: [0.19, 0.8, 0.24, -0.51]
211-
v: 1.0
212-
phase: Aluminum
213-
homogenization: SX
214-
- constituents:
215-
- O: [0.8, 0.19, 0.24, -0.51]
216-
v: 1.0
217-
phase: Steel
218-
homogenization: SX
219209
homogenization: {SX: null}
220210
phase: {Aluminum: null, Steel: null}
211+
material:
212+
- constituents:
213+
- phase: Aluminum
214+
O: [1.0, 0.0, 0.0, 0.0]
215+
v: 1.0
216+
homogenization: SX
217+
- constituents:
218+
- phase: Steel
219+
O: [0.0, 1.0, 0.0, 0.0]
220+
v: 1.0
221+
homogenization: SX
221222
222223
>>> cm.from_table(t,O='qu',phase='phase',homogenization='single_crystal')
223-
material:
224-
- constituents:
225-
- O: [0.19, 0.8, 0.24, -0.51]
226-
v: 1.0
227-
phase: Aluminum
228-
homogenization: single_crystal
229-
- constituents:
230-
- O: [0.8, 0.19, 0.24, -0.51]
231-
v: 1.0
232-
phase: Steel
233-
homogenization: single_crystal
234224
homogenization: {single_crystal: null}
235225
phase: {Aluminum: null, Steel: null}
226+
material:
227+
- constituents:
228+
- phase: Aluminum
229+
O: [1.0, 0.0, 0.0, 0.0]
230+
v: 1.0
231+
homogenization: single_crystal
232+
- constituents:
233+
- phase: Steel
234+
O: [0.0, 1.0, 0.0, 0.0]
235+
v: 1.0
236+
homogenization: single_crystal
236237
237238
"""
238239
kwargs = {}
@@ -463,74 +464,113 @@ def material_add(self,*,
463464
>>> import damask
464465
>>> m = damask.ConfigMaterial()
465466
>>> m = m.material_add(phase = ['Ferrite','Martensite','Ferrite'],
466-
... O = damask.Rotation.from_random(3),
467+
... O = damask.Rotation.from_random(3,rng_seed=20191102),
467468
... homogenization = 'SX')
468469
>>> m
470+
homogenization: {SX: null}
471+
phase: {Ferrite: null, Martensite: null}
469472
material:
470473
- constituents:
471-
- O: [0.577764, -0.146299, -0.617669, 0.513010]
474+
- phase: Ferrite
475+
O: [0.0047, -0.9582, 0.1084, 0.2645]
472476
v: 1.0
473-
phase: Ferrite
474477
homogenization: SX
475478
- constituents:
476-
- O: [0.184176, 0.340305, 0.737247, 0.553840]
479+
- phase: Martensite
480+
O: [0.9147, -0.1907, 0.2901, -0.2068]
477481
v: 1.0
478-
phase: Martensite
479482
homogenization: SX
480483
- constituents:
481-
- O: [0.47925185, -0.04294454, 0.78760173, -0.3849116 ]
484+
- phase: Ferrite
485+
O: [0.1068, -0.4427, 0.1369, 0.8797]
482486
v: 1.0
483-
phase: Ferrite
484487
homogenization: SX
485-
homogenization: {SX: null}
486-
phase: {Ferrite: null, Martensite: null}
487488
488-
Create hundred materials that each approximate a duplex stainless steel microstructure
489+
Create five materials that each approximate a duplex stainless steel microstructure
489490
with three austenite and one relatively bigger ferrite grain of random orientation each:
490491
492+
>>> import numpy as np
491493
>>> import damask
492494
>>> m = damask.ConfigMaterial()
493-
>>> m = m.material_add(phase = np.array(['Austenite']*3+['Ferrite']),
494-
... O = damask.Rotation.from_random((100,4)),
495-
... v = np.array([0.2]*3+[0.4]),
495+
>>> N_materials = 5
496+
>>> m = m.material_add(phase = np.array([['Austenite']*3+['Ferrite']]),
497+
... O = damask.Rotation.from_random((N_materials,4),rng_seed=20191102),
498+
... v = np.array([[0.2]*3+[0.4]]),
496499
... homogenization = 'Taylor')
497500
>>> m
498-
material:
499-
- constituents:
500-
- v: 0.2
501-
phase: Austenite
502-
O: [0.46183665006602664, 0.2215160420973196, -0.5594313187331139, 0.6516702781083836]
503-
- v: 0.2
504-
phase: Austenite
505-
O: [0.11321658382410027, 0.6354079414360444, 0.00562701344273936, 0.7638108992590535]
506-
- v: 0.2
507-
phase: Austenite
508-
O: [0.050991978809077604, 0.8069522034362003, -0.11352928955610851, -0.5773552285027659]
509-
- v: 0.4
510-
phase: Ferrite
511-
O: [0.9460076150721788, 0.15880754622367604, -0.0069841062241482385, -0.28249066842661014]
512-
homogenization: Taylor
513-
.
514-
.
515-
.
516-
- constituents:
517-
- v: 0.2
518-
phase: Austenite
519-
O: [0.12531400788494199, -0.18637769037997565, 0.31737548053338394, -0.9213210951197429]
520-
- v: 0.2
521-
phase: Austenite
522-
O: [0.37453930577161404, -0.33529507696450805, -0.3266564259130028, -0.800370601162502]
523-
- v: 0.2
524-
phase: Austenite
525-
O: [0.035776891752713764, -0.720706371010592, -0.4540438656728926, -0.5226342017569017]
526-
- v: 0.4
527-
phase: Ferrite
528-
O: [0.6782596727966124, -0.20800082041703685, -0.138636083554039, 0.6909989227925536]
529-
homogenization: Taylor
530-
531501
homogenization: {Taylor: null}
532-
533502
phase: {Austenite: null, Ferrite: null}
503+
material:
504+
- constituents:
505+
- phase: Austenite
506+
v: 0.2
507+
O: [0.004702411137213036, -0.9582446864633862, 0.1084379916089085, 0.2645490694937509]
508+
- phase: Austenite
509+
v: 0.2
510+
O: [0.9147097460704486, -0.19068436891182194, 0.29014401444532145, -0.20678975501215882]
511+
- phase: Austenite
512+
v: 0.2
513+
O: [0.10677819003833185, -0.4427133706883004, 0.13690394495734726, 0.879693468999888]
514+
- phase: Ferrite
515+
v: 0.4
516+
O: [0.8664338002923555, 0.04448357787828491, -0.4945927532088464, 0.05188149461403649]
517+
homogenization: Taylor
518+
- constituents:
519+
- phase: Austenite
520+
v: 0.2
521+
O: [0.5621873738314133, 0.0028841916095125584, -0.817023371343172, -0.1281009321680984]
522+
- phase: Austenite
523+
v: 0.2
524+
O: [0.1566777437467901, -0.8117282158019414, 0.5096142534839398, 0.23841707348975383]
525+
- phase: Austenite
526+
v: 0.2
527+
O: [0.3559036203819333, 0.1946923701552408, 0.058744995087853975, -0.9121274689178566]
528+
- phase: Ferrite
529+
v: 0.4
530+
O: [0.467387781713959, -0.35644325887489176, 0.8031986430613528, 0.09679258489963502]
531+
homogenization: Taylor
532+
- constituents:
533+
- phase: Austenite
534+
v: 0.2
535+
O: [0.4399087544327661, 0.12802483830067418, -0.8257167208737983, 0.32906203886337354]
536+
- phase: Austenite
537+
v: 0.2
538+
O: [0.12410381094181624, -0.5125024631828828, -0.8493860709598213, 0.021972068647108236]
539+
- phase: Austenite
540+
v: 0.2
541+
O: [0.03909373022192218, 0.4596226773046959, 0.42809626138739537, 0.7771436583738773]
542+
- phase: Ferrite
543+
v: 0.4
544+
O: [0.737821660605232, 0.38809925187040367, -0.012129167758963711, 0.5521331824196455]
545+
homogenization: Taylor
546+
- constituents:
547+
- phase: Austenite
548+
v: 0.2
549+
O: [0.4924738838478857, -0.0534798919571679, -0.6570981342247908, 0.5681825559468784]
550+
- phase: Austenite
551+
v: 0.2
552+
O: [0.13073521303792138, 0.2534173177988532, -0.9582490914178947, -0.021133998872519554]
553+
- phase: Austenite
554+
v: 0.2
555+
O: [0.1633346595899539, 0.6775968809652247, -0.07127256805012916, -0.71351557581203]
556+
- phase: Ferrite
557+
v: 0.4
558+
O: [0.7658044627436773, -0.5327872540278646, 0.1102330397070761, 0.34282640467772235]
559+
homogenization: Taylor
560+
- constituents:
561+
- phase: Austenite
562+
v: 0.2
563+
O: [0.25814496892598815, -0.6159961898524933, -0.5080223627084379, 0.543896265930874]
564+
- phase: Austenite
565+
v: 0.2
566+
O: [0.8497433829153472, 0.4264182767672584, 0.05570674517418605, -0.3049596612218108]
567+
- phase: Austenite
568+
v: 0.2
569+
O: [0.5146112784760113, 0.529467219604771, 0.661078636611197, 0.13347183839881469]
570+
- phase: Ferrite
571+
v: 0.4
572+
O: [0.18430893147208752, 0.012407731059331692, -0.5551804816056372, -0.8109567798802285]
573+
homogenization: Taylor
534574
535575
"""
536576
dim = {'O':(4,),'V_e':(3,3,)}

python/damask/_geomgrid.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ def load_Neper(fname: Union[str, Path]) -> 'GeomGrid':
377377
>>> N_grains = 20
378378
>>> cells = (32,32,32)
379379
>>> damask.util.run(f'neper -T -n {N_grains} -tesrsize {cells[0]}:{cells[1]}:{cells[2]} -periodicity all -format vtk')
380+
running 'neper -T -n 20 -tesrsize 32:32:32 -periodicity all -format vtk' ...
380381
>>> damask.GeomGrid.load_Neper(f'n{N_grains}-id1.vtk').renumber()
381382
cells: 32 × 32 × 32
382383
size: 1.0 × 1.0 × 1.0 m³
@@ -736,8 +737,8 @@ def from_minimal_surface(cells: IntSequence,
736737
>>> import numpy as np
737738
>>> import damask
738739
>>> damask.GeomGrid.from_minimal_surface([64]*3,np.ones(3)*1.e-4,'Gyroid')
739-
cells : 64 × 64 × 64
740-
size : 0.0001 × 0.0001 × 0.0001 m³
740+
cells: 64 × 64 × 64
741+
size: 0.0001 × 0.0001 × 0.0001 m³
741742
origin: 0.0 0.0 0.0 m
742743
# materials: 2
743744
@@ -747,8 +748,8 @@ def from_minimal_surface(cells: IntSequence,
747748
>>> import damask
748749
>>> damask.GeomGrid.from_minimal_surface([80]*3,np.ones(3)*5.e-4,
749750
... 'Neovius',materials=(1,5))
750-
cells : 80 × 80 × 80
751-
size : 0.0005 × 0.0005 × 0.0005 m³
751+
cells: 80 × 80 × 80
752+
size: 0.0005 × 0.0005 × 0.0005 m³
752753
origin: 0.0 0.0 0.0 m
753754
# materials: 2 (min: 1, max: 5)
754755
@@ -1087,8 +1088,8 @@ def scale(self,
10871088
origin: 0.0 0.0 0.0 m
10881089
# materials: 1
10891090
>>> g.scale(g.cells*2)
1090-
cells : 64 × 64 × 64
1091-
size : 0.0001 × 0.0001 × 0.0001 m³
1091+
cells: 64 × 64 × 64
1092+
size: 0.0001 × 0.0001 × 0.0001 m³
10921093
origin: 0.0 0.0 0.0 m
10931094
# materials: 1
10941095
@@ -1328,8 +1329,8 @@ def add_primitive(self,
13281329
>>> import damask
13291330
>>> g = damask.GeomGrid(np.zeros([64]*3,int), np.ones(3)*1e-4)
13301331
>>> g.add_primitive(np.ones(3)*5e-5,np.ones(3)*5e-5,1)
1331-
cells : 64 × 64 × 64
1332-
size : 0.0001 × 0.0001 × 0.0001 m³
1332+
cells: 64 × 64 × 64
1333+
size: 0.0001 × 0.0001 × 0.0001 m³
13331334
origin: 0.0 0.0 0.0 m
13341335
# materials: 2
13351336
@@ -1339,8 +1340,8 @@ def add_primitive(self,
13391340
>>> import damask
13401341
>>> g = damask.GeomGrid(np.zeros([64]*3,int), np.ones(3)*1e-4)
13411342
>>> g.add_primitive(np.ones(3,int)*32,np.zeros(3),np.inf)
1342-
cells : 64 × 64 × 64
1343-
size : 0.0001 × 0.0001 × 0.0001 m³
1343+
cells: 64 × 64 × 64
1344+
size: 0.0001 × 0.0001 × 0.0001 m³
13441345
origin: 0.0 0.0 0.0 m
13451346
# materials: 2
13461347

0 commit comments

Comments
 (0)