コード例 #1
0
def GetAz(Bx, By, Jz, Nc, dl):

    mesh = Grid2D(dx=dl[0], dy=dl[1], nx=Nc[0], ny=Nc[1])

    _Az = CellVariable(mesh=mesh, value=0.0)

    _Bx = CellVariable(mesh=mesh)
    _Bx.value = np.reshape(Bx, Nc[0] * Nc[1], order='F')

    _By = CellVariable(mesh=mesh)
    _By.value = np.reshape(By, Nc[0] * Nc[1], order='F')

    _Jz = CellVariable(mesh=mesh)
    _Jz.value = np.reshape(Jz, Nc[0] * Nc[1], order='F')

    _Az.equation = (DiffusionTerm(coeff=1.0) + _Jz == 0)

    # beware of the sign of the flux : always consider outward direction
    BCs = [
        FixedFlux(value=_By.getFaceValue(), faces=mesh.getFacesLeft()),
        FixedFlux(value=-_By.getFaceValue(), faces=mesh.getFacesRight()),
        FixedFlux(value=-_Bx.getFaceValue(), faces=mesh.getFacesBottom()),
        FixedFlux(value=_Bx.getFaceValue(), faces=mesh.getFacesTop())
    ]

    _Az.equation.solve(var=_Az, boundaryConditions=BCs)

    Az = np.reshape(_Az.value, Nc, order='F')

    return Az