New shapes function for constructing arbitrary diffusion coefficients

The coefficients that can be constructed with the 'buildcoef2d' can exceed the 6 main shapes. This script visualized the utilization of the newShape function and shows two examples.


In [1]:
import os
import sys
import numpy as np

%matplotlib notebook
import matplotlib.pyplot as plt
from visualize import drawCoefficient, AllshapesSixdrawCoefficient

import buildcoef2d

In [2]:
bg = 0.05   #background
val = 1     #values
        
NWorldFine = np.array([11, 11])

New Shape


In [3]:
CoefClassNew = buildcoef2d.Coefficient2d(NWorldFine,
                                         bg = bg, 
                                         val = val, 
                                         space = 2, 
                                         probfactor=1, 
                                         BoundarySpace = True)
                                         
newshape = np.array([[1,6,1,1,1,6,0], 
                     [4,6,1, 1,1,6,0], 
                     [1,6,1,-1,1,6,0],
                     [4,6,1,-1,0,0,0]])

CoefClassNew.NewShape(newshape)
New = CoefClassNew.BuildCoefficient()

N = New.flatten()

plt.figure("newShape")
drawCoefficient(NWorldFine, N)

plt.show()



In [4]:
CoefClassNew1 = buildcoef2d.Coefficient2d(NWorldFine,
                                         bg = bg, 
                                         val = val, 
                                         space = 2, 
                                         probfactor=1, 
                                         BoundarySpace = True)
                                         
newshape = np.array([[1,6,1,1,2,6,0,0,1], 
                     [4,6,1,1,1,6,0,0,0], 
                     [4,6,1,1,0,0,0,0,0],
                     [1,6,1,-1,0,0,0,0,0]])

CoefClassNew1.NewShape(newshape)
New = CoefClassNew1.BuildCoefficient()

N = New.flatten()

plt.figure("newShape1")
drawCoefficient(NWorldFine, N)

plt.show()


Shape 6


In [5]:
CoefClassShape6 = buildcoef2d.Coefficient2d(NWorldFine,
                                         bg = bg, 
                                         val = val, 
                                         space = 2, 
                                         probfactor=1, 
                                         BoundarySpace = True)
                                         
shape6 = np.array([[1,2,1,1,1,0,1],
                      [1,2,1,-1,1,1,-1],
                      [1,2,1,-1,1,1,-1],
                      [1,2,1,-1,1,1,-1],
                      [1,2,1,-1,1,1,-1],
                      [1,2,1,-1,0,0,0]])

CoefClassShape6.NewShape(shape6)
Shape6 = CoefClassShape6.BuildCoefficient()

S6 = Shape6.flatten()

plt.figure("Shape 6")
drawCoefficient(NWorldFine, S6)

plt.show()