|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 | # -*- coding: utf-8 -*-
|
3 | 3 | """
|
4 |
| -Created on Thu Oct 15 13:15:07 2020 |
| 4 | +Script to create and visualize random binary inclusion structures: |
| 5 | + - simple inclusion structure |
| 6 | + - block inclusion structure |
| 7 | +Fields are by default in 2D for visualization. |
5 | 8 |
|
6 |
| -@author: zech0001 |
| 9 | +Structures in 3D and different block arrangement can be created by modifying |
| 10 | +setting parameters, particular dim and/or axis |
| 11 | +
|
| 12 | +@author: A. Zech |
| 13 | +Licence MIT, A.Zech, 2020 |
7 | 14 | """
|
8 | 15 |
|
9 | 16 | import numpy as np
|
|
12 | 19 |
|
13 | 20 | np.random.seed(20201101)
|
14 | 21 |
|
| 22 | +######################################### |
| 23 | +### Simple binary inclusion structure ### |
| 24 | +######################################### |
| 25 | + |
| 26 | +### initialize simple binary inclusion structure with specified settings |
| 27 | +### as instance of the class Simple_Binary_Inclusions |
15 | 28 | BI = bi.Simple_Binary_Inclusions(
|
16 |
| - dim=2, |
17 |
| - k_bulk=1e-5, # conductivity value of bulk |
18 |
| - k_incl=1e-3, # conductivity value of inclusions |
19 |
| - nx=4, # number of inclusions in x-direction |
20 |
| - lx=10, # inclusion length in x-direction |
21 |
| - nz=20, # number of inclusions in z-direction |
22 |
| - lz=0.5, # inclusion length in z-direction |
23 |
| - nz_incl=3, # number of inclusions with different K |
| 29 | + dim=2, # dimesionality of structure |
| 30 | + k_bulk=1e-5, # bulk conductivity value |
| 31 | + k_incl=1e-3, # conductivity value of inclusions |
| 32 | + nx=8, # number of units in x-direction |
| 33 | + lx=10, # unit length in x-direction |
| 34 | + nz=20, # number of unit in z-direction |
| 35 | + lz=0.5, # unit length in z-direction |
| 36 | + nz_incl=3, # number of inclusions (units with different K) |
24 | 37 | )
|
25 | 38 |
|
26 |
| -########################################### |
27 |
| -### Simple 2D binary inclusion structure |
| 39 | +### Generate random realization of simple binary inclusion structure ### |
28 | 40 | k1 = BI.structure()
|
29 | 41 | BI.structure2scale()
|
30 | 42 | xx, zz = np.meshgrid(BI.x, BI.z)
|
31 | 43 |
|
| 44 | +### Plot random realization of simple binary inclusion structure ### |
32 | 45 | fig = plt.figure(1)
|
33 |
| -ax = fig.add_subplot(1, 1, 1) |
| 46 | +im = plt.pcolor(xx, zz, k1.T, cmap=plt.get_cmap("binary_r")) |
| 47 | +plt.xlabel("$x$ [m]") |
| 48 | +plt.ylabel("$z$ [m]") |
| 49 | +plt.tight_layout() |
| 50 | +plt.savefig("../results/BI_Simple.png", dpi=300) |
| 51 | +print('Save figure of simple inclusion structure to ./results') |
34 | 52 |
|
35 |
| -im = ax.pcolor(xx, zz, k1.T, cmap=plt.get_cmap("binary_r")) |
36 |
| -ax.set_xlabel("$x$ [m]") |
37 |
| -ax.set_ylabel("$z$ [m]") |
38 |
| -plt.savefig("../results/Simple_BI.png", dpi=300) |
39 |
| - |
40 |
| -########################################### |
41 |
| -### Two stage 2D binary inclusion structure |
| 53 | +############################################ |
| 54 | +### Two block binary inclusion structure ### |
| 55 | +############################################ |
42 | 56 |
|
| 57 | +### initialize block binary inclusion structure with specified settings |
| 58 | +### as instance of the class Block_Binary_Inclusions |
43 | 59 | BIB = bi.Block_Binary_Inclusions(
|
44 |
| - dim=3, |
45 |
| - axis=2, |
46 |
| - k_bulk=[1e-5, 1e-3], # conductivity value of bulk |
47 |
| - k_incl=[1e-3, 1e-5], # conductivity value of inclusions |
48 |
| - nn=[4, 20], # number of inclusions-blocks in x-direction |
49 |
| - ll=[10, 10], # inclusion length in x-direction |
50 |
| - nx=10, # number of inclusions in z-direction |
51 |
| - lx=5, # inclusion length in z-direction |
52 |
| - nz=20, # number of inclusions in z-direction |
53 |
| - lz=0.5, # inclusion length in z-direction |
54 |
| - nn_incl=[3, 3], # number of inclusions within different K |
| 60 | + dim=2, # dimesionality of structure |
| 61 | + axis=0, # direction of multiple blocks (0=x, 1=z, 2=y) |
| 62 | + k_bulk=[1e-5, 1e-3], # bulk-conductivity value in each block |
| 63 | + k_incl=[1e-3, 1e-5], # conductivity values of inclusions in each block |
| 64 | + nn=[4, 18], # number of units within each block (now x-dir) |
| 65 | + ll=[10, 10], # unit lengths within blocks (now x-dir) |
| 66 | + nz=20, # number of units in z-direction |
| 67 | + lz=0.5, # unit length in z-direction |
| 68 | + nn_incl=[3, 3], # number of inclusions (units within different K) |
55 | 69 | )
|
56 | 70 |
|
| 71 | +### Generate random realization of simple binary inclusion structure ### |
57 | 72 | k2 = BIB.structure()
|
58 | 73 | BIB.structure2scale(x0=-20, z0=52)
|
59 |
| - |
60 | 74 | xx, zz = np.meshgrid(BIB.x, BIB.z)
|
61 | 75 |
|
62 |
| -fig = plt.figure(2, figsize=[6, 2]) |
63 |
| -ax = fig.add_subplot(1, 1, 1) |
64 |
| -im = ax.pcolor(k2[:, 0, :].T, cmap=plt.get_cmap("binary_r")) |
65 |
| -# im = ax.pcolor(xx,zz,kk.T,cmap=plt.get_cmap('binary_r')) |
66 |
| -ax.set_xlabel("$x$ [m]") |
67 |
| -ax.set_ylabel("$z$ [m]") |
68 |
| -plt.savefig("../results/Block_BI.png", dpi=300) |
| 76 | +### Plot random realization of simple binary inclusion structure ### |
| 77 | +fig = plt.figure(2, figsize=[10, 2.5]) |
| 78 | +plt.pcolor(xx,zz,k2.T,cmap=plt.get_cmap('binary_r')) |
| 79 | +plt.xlabel("$x$ [m]") |
| 80 | +plt.ylabel("$z$ [m]") |
| 81 | +plt.tight_layout() |
| 82 | +plt.savefig("../results/BI_Block.png", dpi=300) |
| 83 | +print('Save figure of block inclusion structure to ./results') |
0 commit comments