示例#1
0
def test_1():
    bg = 0  # background
    val = 2  # values

    space = 10
    thick = 1

    NWorldFine = np.array([128, 128])

    CoefClass = buildcoef2d.Coefficient2d(NWorldFine,
                                          bg=bg,
                                          val=val,
                                          length=1,
                                          thick=thick,
                                          space=space,
                                          probfactor=1,
                                          right=1,
                                          down=0,
                                          diagr1=0,
                                          diagr2=0,
                                          diagl1=0,
                                          diagl2=0,
                                          LenSwitch=None,
                                          thickSwitch=None,
                                          equidistant=True,
                                          ChannelHorizontal=None,
                                          ChannelVertical=True,
                                          BoundarySpace=True)

    A = CoefClass.BuildCoefficient().flatten()

    plt.figure("Coefficient_test_1")
    drawCoefficient(NWorldFine, A)
示例#2
0
def test_2():
    bg = 0  # background
    val = 2  # values

    space = 10
    thick = 1
    fine = 64
    NWorldFine = np.array([fine, fine])

    ChoosingShapes = np.array([
        # shape , len, thick, space
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [4, fine - 2, 1, 5],
        [4, fine - 2, 1, 5],
        [4, fine - 2, 1, 5]
    ])

    CoefClass = buildcoef2d.Coefficient2d(NWorldFine,
                                          bg=bg,
                                          val=val,
                                          right=1,
                                          LenSwitch=None,
                                          thickSwitch=None,
                                          equidistant=True,
                                          ChannelHorizontal=None,
                                          ChannelVertical=None,
                                          BoundarySpace=True,
                                          probfactor=1,
                                          ChoosingShapes=ChoosingShapes)

    A = CoefClass.BuildCoefficient().flatten()
    Correct = CoefClass.SpecificVanish(Number=[10, 11])
    plt.figure("Coefficient_test_1")
    drawCoefficient(NWorldFine, Correct.flatten())

    Number = [10, 11]
    random.seed(32)
    lis = np.zeros(80)
    lis[0] = 1
    for i in range(np.shape(CoefClass.ShapeRemember)[0]):
        Number.append(i * random.sample(list(lis), 1)[0])
    plt.figure("Perturbation")
    Perturbed = CoefClass.SpecificVanish(Number=Number,
                                         Original=True).flatten()
    drawCoefficient(NWorldFine, Perturbed)
示例#3
0
world = World(NWorldCoarse, NCoarseElement, boundaryConditions)

#righthandside
f = np.ones(NpCoarse)

#coefficient
CoefClass = buildcoef2d.Coefficient2d(NWorldFine, 
                                    bg                  = 0.05, 
                                    val                 = 1, 
                                    length              = 8, 
                                    thick               = 8, 
                                    space               = 8, 
                                    probfactor          = 1, 
                                    right               = 1, 
                                    down                = 0, 
                                    diagr1              = 0, 
                                    diagr2              = 0, 
                                    diagl1              = 0, 
                                    diagl2              = 0, 
                                    LenSwitch           = None, 
                                    thickSwitch         = None, 
                                    equidistant         = True, 
                                    ChannelHorizontal   = None, 
                                    ChannelVertical     = None,
                                    BoundarySpace       = True)

A = CoefClass.BuildCoefficient()
ABase = A.flatten()

plt.figure("OriginalCoefficient")
drawCoefficient(NWorldFine, ABase)
示例#4
0
val = 1  #values

NWorldFine = np.array([11, 11])
NWorldFine2 = np.array([38, 42])

########################
# Print all shapes
#######################

CoefClass = buildcoef2d.Coefficient2d(NWorldFine,
                                      bg=0.05,
                                      val=1,
                                      length=7,
                                      thick=1,
                                      space=2,
                                      probfactor=1,
                                      right=1,
                                      down=0,
                                      diagr1=0,
                                      diagr2=0,
                                      diagl1=0,
                                      diagl2=0,
                                      BoundarySpace=True)

CoefClass1 = buildcoef2d.Coefficient2d(NWorldFine,
                                       bg=0.05,
                                       val=1,
                                       length=7,
                                       thick=1,
                                       space=2,
                                       probfactor=1,
                                       right=0,
world = World(NWorldCoarse, NCoarseElement, boundaryConditions)

#righthandside
f = np.ones(NpCoarse)

#Coefficient 4
CoefClass = buildcoef2d.Coefficient2d(NWorldFine,
                                      bg=bg,
                                      val=val,
                                      thick=1,
                                      space=0,
                                      probfactor=1,
                                      right=0,
                                      down=0,
                                      diagr1=1,
                                      diagr2=0,
                                      diagl1=1,
                                      diagl2=0,
                                      LenSwitch=[4, 5, 6, 7, 8],
                                      thickSwitch=None,
                                      equidistant=None,
                                      ChannelHorizontal=None,
                                      ChannelVertical=None,
                                      BoundarySpace=None)

A = CoefClass.BuildCoefficient()
ABase = A.flatten()

ROOT = '../../../test_data/Coef4/'

#safe NworldFine
示例#6
0
bg = 0.05 		#background
val = 1			#values

NWorldFine = np.array([256, 256])

#Coefficient 1
CoefClass1 = buildcoef2d.Coefficient2d(NWorldFine,
                        bg	    	        = bg,
                        val		            = val,
                        length              = 2,
                        thick               = 2,
                        space               = 2,
                        probfactor          = 1,
                        right               = 1,
                        down                = 0,
                        diagr1              = 0,
                        diagr2              = 0,
                        diagl1              = 0,
                        diagl2              = 0,
                        LenSwitch           = None,
                        thickSwitch         = None,
                        equidistant         = True,
                        ChannelHorizontal   = None,
                        ChannelVertical     = None,
                        BoundarySpace       = True)

#Coefficient 2
CoefClass2 = buildcoef2d.Coefficient2d(NWorldFine, 
                        bg                  = bg,
                        val                 = val,
                        length              = 1,
示例#7
0
bg = 0.05  #background
val = 1  #values

NWorldFine = np.array([42, 42])

CoefClass = buildcoef2d.Coefficient2d(
    NWorldFine,
    bg=bg,  # background
    val=val,  # values
    length=2,  # length
    thick=2,  # thickness
    space=2,  # space between values
    probfactor=1,  # probability of an value
    right=1,  # shape 1
    down=0,  # shape 2
    diagr1=0,  # shape 3
    diagr2=0,  # shape 4
    diagl1=0,  # shape 5
    diagl2=0,  # shape 6
    LenSwitch=None,  # various length
    thickSwitch=None,  # various thickness
    ChannelHorizontal=None,  # horizontal Channels
    ChannelVertical=None,  # vertical Channels
    BoundarySpace=True  # additional space on the boundary
)

A = CoefClass.BuildCoefficient()  # coefficient in a numpy array

numbers = [13, 20, 27, 44, 73]  #What entries will be changed

# Change in Value
示例#8
0
xtFine_pert = psi.evaluate(xtFine)
xtFine_ref = psi.inverse_evaluate(xtFine)

bg = 0.01  #background
val = 1  #values

CoefClass = buildcoef2d.Coefficient2d(NCoeff,
                                      bg=bg,
                                      val=val,
                                      length=4,
                                      thick=4,
                                      space=4,
                                      probfactor=1,
                                      right=1,
                                      down=0,
                                      diagr1=0,
                                      diagr2=0,
                                      diagl1=0,
                                      diagl2=0,
                                      LenSwitch=None,
                                      thickSwitch=None,
                                      equidistant=True,
                                      ChannelHorizontal=None,
                                      ChannelVertical=None,
                                      BoundarySpace=True)

# Set reference coefficient
aCoarse_ref_shaped = CoefClass.BuildCoefficient()
aCoarse_ref = aCoarse_ref_shaped.flatten()
aFine_ref = func.evaluateDQ0(NCoeff, aCoarse_ref, xtFine_ref)
示例#9
0
#righthandside
f = np.ones(NpCoarse)

#coefficient
WormsUltCoefClass = buildcoef2d.Coefficient2d(NWorldFine,
                                              bg=bg,
                                              val=val,
                                              length=1,
                                              thick=1,
                                              space=1,
                                              probfactor=1,
                                              right=1,
                                              down=1,
                                              diagr1=1,
                                              diagr2=1,
                                              diagl1=1,
                                              diagl2=1,
                                              LenSwitch=[1, 2, 3, 4, 5, 6],
                                              thickSwitch=[1, 2, 3],
                                              equidistant=None,
                                              ChannelHorizontal=None,
                                              ChannelVertical=None,
                                              BoundarySpace=True,
                                              Boxes2n=None,
                                              Channels2n=None)

A = WormsUltCoefClass.BuildCoefficient()
ABase = A.flatten()

plt.figure("OriginalCoefficient")
示例#10
0
NList = [fine, 2, 4, 8, 16, 32, 64, 128, 256, 512]

boundaryConditions = np.array([[0, 0], [0, 0]])

#coefficient
WormsUltCoefClass = buildcoef2d.Coefficient2d(NWorldFine,
                                              bg=bg,
                                              val=val,
                                              length=1,
                                              thick=65,
                                              space=65,
                                              probfactor=1,
                                              right=1,
                                              down=0,
                                              diagr1=0,
                                              diagr2=0,
                                              diagl1=0,
                                              diagl2=0,
                                              LenSwitch=None,
                                              thickSwitch=None,
                                              equidistant=True,
                                              ChannelHorizontal=None,
                                              ChannelVertical=True,
                                              BoundarySpace=None,
                                              Boxes2n=None,
                                              Channels2n=None,
                                              TestExample=True)

A = WormsUltCoefClass.BuildCoefficient()
ABase = A.flatten()
plt.figure("OriginalCoefficient")
drawCoefficient(NWorldFine, ABase)