コード例 #1
0
ファイル: testEsSolve.py プロジェクト: ericangle/esPic
    def test2D(potential, field):
        potAccept2D = np.zeros((NX_2D + 1, NY_2D + 1))
        fieldAccept2D = np.zeros((NX_2D + 1, NY_2D + 1, 2))
        for i, j in np.ndindex(potAccept2D.shape):
            potAccept2D[i, j] = potential(X0_2D + DX_2D * i, Y0_2D + DY_2D * j)
            fieldAccept2D[i, j] = field(X0_2D + DX_2D * i, Y0_2D + DY_2D * j)

        # Boundary conditions
        V0x_2D = dirBC(potAccept2D[0, :])
        VNx_2D = dirBC(potAccept2D[NX_2D, :])
        V0y_2D = dirBC(potAccept2D[:, 0])
        VNy_2D = dirBC(potAccept2D[:, NY_2D])

        E0x_2D = neuBC(fieldAccept2D[0, :, 0])
        ENx_2D = neuBC(fieldAccept2D[NX_2D, :, 0])
        E0y_2D = neuBC(fieldAccept2D[:, 0, 1])
        ENy_2D = neuBC(fieldAccept2D[:, NY_2D, 1])

        for BC0x_2D in [V0x_2D, E0x_2D]:
            for BCNx_2D in [VNx_2D, ENx_2D]:
                for BC0y_2D in [V0y_2D, E0y_2D]:
                    for BCNy_2D in [VNy_2D]:  #,ENy_2D]:
                        for testType in ["direct", "jacobi", "gaussSeidel"]:
                            for cythonType in [True, False]:
                                if testType == "direct":
                                    potCalculated2D = esSolve.laplace2D(NX_2D,DX_2D,BC0x_2D,BCNx_2D, \
                                                                        NY_2D,DY_2D,BC0y_2D,BCNy_2D, \
                                                                        testType,cythonType)
                                else:
                                    potCalculated2D = esSolve.laplace2D(NX_2D,DX_2D,BC0x_2D,BCNx_2D, \
                                                                        NY_2D,DY_2D,BC0y_2D,BCNy_2D, \
                                                                        testType,relTol,absTol,cythonType)

                                test(potCalculated2D, potAccept2D)
コード例 #2
0
ファイル: testEsSolve.py プロジェクト: ericangle/esPic
    def test1D(potential, field):
        potAccept1D = np.zeros(NX_1D + 1)
        fieldAccept1D = np.zeros((NX_1D + 1, 1))
        for i in range(NX_1D + 1):
            potAccept1D[i] = potential(X0_1D + DX_1D * i)
            fieldAccept1D[i] = field(X0_1D + DX_1D * i)

        # Boundary conditions
        V0_1D = dirBC(potAccept1D[0])
        VN_1D = dirBC(potAccept1D[NX_1D])

        E0_1D = neuBC(fieldAccept1D[0])
        EN_1D = neuBC(fieldAccept1D[NX_1D])

        for BC0_1D in [V0_1D, E0_1D]:
            for BCN_1D in [VN_1D]:  #,EN_1D]:
                for testType in ["direct", "jacobi", "gaussSeidel"]:
                    for cythonType in [True, False]:
                        if testType == "direct":
                            potCalculated1D = esSolve.laplace1D(NX_1D,DX_1D,BC0_1D,BCN_1D, \
                                                                testType,cythonType)
                        else:
                            potCalculated1D = esSolve.laplace1D(NX_1D,DX_1D,BC0_1D,BCN_1D, \
                                                                testType,relTol,absTol,cythonType)

                        test(potCalculated1D, potAccept1D)
コード例 #3
0
ファイル: testEsSolve.py プロジェクト: ericangle/esPic
  def test2D(potential,field):
    potAccept2D   = np.zeros((NX_2D+1,NY_2D+1))
    fieldAccept2D = np.zeros((NX_2D+1,NY_2D+1,2))
    for i,j in np.ndindex(potAccept2D.shape):
      potAccept2D[i,j]   = potential(X0_2D+DX_2D*i,Y0_2D+DY_2D*j)
      fieldAccept2D[i,j] = field(    X0_2D+DX_2D*i,Y0_2D+DY_2D*j)

    # Boundary conditions
    V0x_2D = dirBC(potAccept2D[0,    :    ])
    VNx_2D = dirBC(potAccept2D[NX_2D,:    ])
    V0y_2D = dirBC(potAccept2D[:,    0    ])
    VNy_2D = dirBC(potAccept2D[:,    NY_2D])

    E0x_2D = neuBC(fieldAccept2D[0,    :,    0])
    ENx_2D = neuBC(fieldAccept2D[NX_2D,:,    0])
    E0y_2D = neuBC(fieldAccept2D[:,    0,    1])
    ENy_2D = neuBC(fieldAccept2D[:,    NY_2D,1])

    for BC0x_2D in [V0x_2D,E0x_2D]:
      for BCNx_2D in [VNx_2D,ENx_2D]:
        for BC0y_2D in [V0y_2D,E0y_2D]:
          for BCNy_2D in [VNy_2D]:#,ENy_2D]:
            for testType in ["direct","jacobi","gaussSeidel"]:
              for cythonType in [True,False]:
                if testType == "direct":
                  potCalculated2D = esSolve.laplace2D(NX_2D,DX_2D,BC0x_2D,BCNx_2D, \
                                                      NY_2D,DY_2D,BC0y_2D,BCNy_2D, \
                                                      testType,cythonType)
                else:
                  potCalculated2D = esSolve.laplace2D(NX_2D,DX_2D,BC0x_2D,BCNx_2D, \
                                                      NY_2D,DY_2D,BC0y_2D,BCNy_2D, \
                                                      testType,relTol,absTol,cythonType)

                test(potCalculated2D,potAccept2D)
コード例 #4
0
ファイル: testEsSolve.py プロジェクト: ericangle/esPic
  def test1D(potential,field):
    potAccept1D   = np.zeros(NX_1D+1)
    fieldAccept1D = np.zeros((NX_1D+1,1))
    for i in range(NX_1D+1):
      potAccept1D[i]   = potential(X0_1D+DX_1D*i)
      fieldAccept1D[i] = field(    X0_1D+DX_1D*i)

    # Boundary conditions
    V0_1D = dirBC(potAccept1D[0    ])
    VN_1D = dirBC(potAccept1D[NX_1D])

    E0_1D = neuBC(fieldAccept1D[0    ])
    EN_1D = neuBC(fieldAccept1D[NX_1D])

    for BC0_1D in [V0_1D,E0_1D]:
      for BCN_1D in [VN_1D]:#,EN_1D]:
        for testType in ["direct","jacobi","gaussSeidel"]:
          for cythonType in [True,False]:
            if testType == "direct":
              potCalculated1D = esSolve.laplace1D(NX_1D,DX_1D,BC0_1D,BCN_1D, \
                                                  testType,cythonType)
            else:
              potCalculated1D = esSolve.laplace1D(NX_1D,DX_1D,BC0_1D,BCN_1D, \
                                                  testType,relTol,absTol,cythonType)

            test(potCalculated1D,potAccept1D)
コード例 #5
0
ファイル: testEsSolve.py プロジェクト: ericangle/esPic
    def test3D(potential, field):
        potAccept3D = np.zeros((NX_3D + 1, NY_3D + 1, NZ_3D + 1))
        fieldAccept3D = np.zeros((NX_3D + 1, NY_3D + 1, NZ_3D + 1, 3))
        for i, j, k in np.ndindex(potAccept3D.shape):
            # consider using np.fromfunction here
            potAccept3D[i, j,
                        k] = potential(X0_3D + DX_3D * i, Y0_3D + DY_3D * j,
                                       Z0_3D + DZ_3D * k)
            fieldAccept3D[i, j,
                          k] = field(X0_3D + DX_3D * i, Y0_3D + DY_3D * j,
                                     Z0_3D + DZ_3D * k)

        # Boundary conditions
        V0x_3D = dirBC(potAccept3D[0, :, :])
        VNx_3D = dirBC(potAccept3D[NX_3D, :, :])
        V0y_3D = dirBC(potAccept3D[:, 0, :])
        VNy_3D = dirBC(potAccept3D[:, NY_3D, :])
        V0z_3D = dirBC(potAccept3D[:, :, 0])
        VNz_3D = dirBC(potAccept3D[:, :, NZ_3D])

        E0x_3D = neuBC(fieldAccept3D[0, :, :, 0])
        ENx_3D = neuBC(fieldAccept3D[NX_3D, :, :, 0])
        E0y_3D = neuBC(fieldAccept3D[:, 0, :, 1])
        ENy_3D = neuBC(fieldAccept3D[:, NY_3D, :, 1])
        E0z_3D = neuBC(fieldAccept3D[:, :, 0, 2])
        ENz_3D = neuBC(fieldAccept3D[:, :, NZ_3D, 2])

        for BC0x_3D in [V0x_3D, E0x_3D]:
            for BCNx_3D in [VNx_3D, ENx_3D]:
                for BC0y_3D in [V0y_3D, E0y_3D]:
                    for BCNy_3D in [VNy_3D, ENy_3D]:
                        for BC0z_3D in [V0z_3D, E0z_3D]:
                            for BCNz_3D in [VNz_3D]:  #,ENz_3D]:
                                for testType in [
                                        "direct", "jacobi", "gaussSeidel"
                                ]:
                                    for cythonType in [True, False]:
                                        if testType == "direct":
                                            potCalculated3D = esSolve.laplace3D(NX_3D,DX_3D,BC0x_3D,BCNx_3D, \
                                                                                NY_3D,DY_3D,BC0y_3D,BCNy_3D, \
                                                                                NZ_3D,DZ_3D,BC0z_3D,BCNz_3D, \
                                                                                testType,cythonType)
                                        else:
                                            potCalculated3D = esSolve.laplace3D(NX_3D,DX_3D,BC0x_3D,BCNx_3D, \
                                                                                NY_3D,DY_3D,BC0y_3D,BCNy_3D, \
                                                                                NZ_3D,DZ_3D,BC0z_3D,BCNz_3D, \
                                                                                testType,relTol,absTol,cythonType)

                                        test(potCalculated3D, potAccept3D)
コード例 #6
0
ファイル: testEsSolve.py プロジェクト: ericangle/esPic
  def test3D(potential,field):
    potAccept3D   = np.zeros((NX_3D+1,NY_3D+1,NZ_3D+1))
    fieldAccept3D = np.zeros((NX_3D+1,NY_3D+1,NZ_3D+1,3))
    for i,j,k in np.ndindex(potAccept3D.shape):
      # consider using np.fromfunction here
      potAccept3D[i,j,k]   = potential(X0_3D+DX_3D*i,Y0_3D+DY_3D*j,Z0_3D+DZ_3D*k)
      fieldAccept3D[i,j,k] = field(    X0_3D+DX_3D*i,Y0_3D+DY_3D*j,Z0_3D+DZ_3D*k)

    # Boundary conditions
    V0x_3D = dirBC(potAccept3D[0,    :,    :    ])
    VNx_3D = dirBC(potAccept3D[NX_3D,:,    :    ])
    V0y_3D = dirBC(potAccept3D[:,    0,    :    ])
    VNy_3D = dirBC(potAccept3D[:,    NY_3D,:    ])
    V0z_3D = dirBC(potAccept3D[:,    :,    0    ])
    VNz_3D = dirBC(potAccept3D[:,    :,    NZ_3D])

    E0x_3D = neuBC(fieldAccept3D[0,    :,    :,    0])
    ENx_3D = neuBC(fieldAccept3D[NX_3D,:,    :,    0])
    E0y_3D = neuBC(fieldAccept3D[:,    0,    :,    1])
    ENy_3D = neuBC(fieldAccept3D[:,    NY_3D,:,    1])
    E0z_3D = neuBC(fieldAccept3D[:,    :,    0,    2])
    ENz_3D = neuBC(fieldAccept3D[:,    :,    NZ_3D,2])

    for BC0x_3D in [V0x_3D,E0x_3D]:
      for BCNx_3D in [VNx_3D,ENx_3D]:
        for BC0y_3D in [V0y_3D,E0y_3D]:
          for BCNy_3D in [VNy_3D,ENy_3D]:
            for BC0z_3D in [V0z_3D,E0z_3D]:
              for BCNz_3D in [VNz_3D]:#,ENz_3D]:
                for testType in ["direct","jacobi","gaussSeidel"]:
                  for cythonType in [True,False]:
                    if testType == "direct":
                      potCalculated3D = esSolve.laplace3D(NX_3D,DX_3D,BC0x_3D,BCNx_3D, \
                                                          NY_3D,DY_3D,BC0y_3D,BCNy_3D, \
                                                          NZ_3D,DZ_3D,BC0z_3D,BCNz_3D, \
                                                          testType,cythonType)
                    else:
                      potCalculated3D = esSolve.laplace3D(NX_3D,DX_3D,BC0x_3D,BCNx_3D, \
                                                          NY_3D,DY_3D,BC0y_3D,BCNy_3D, \
                                                          NZ_3D,DZ_3D,BC0z_3D,BCNz_3D, \
                                                          testType,relTol,absTol,cythonType)

                    test(potCalculated3D,potAccept3D)