def setupPDE_vector_calculus(gridSize, equation): pde = PDE(gridSize, gridSize) pde.setEquationExpression(PDEExpressionType.VECTOR_CALCULUS, equation) pde.setVectorVariable("r", dimension=2) pde.configureGrid() return pde
def setupPDE_vector_calculus(): # 3. Equation as vector calculus without aux function eps pde = PDE(64.0, 64.0) pde.setEquationExpression(PDEExpressionType.VECTOR_CALCULUS, "div(grad( u(r) ))") pde.setVectorVariable("r", dimension=2) pde.configureGrid() return pde
def setupPDE_vector_calculus_with_eps(): # 4. Equation as vector calculus with aux function eps pde = PDE(64.0, 64.0) pde.setEquationExpression(PDEExpressionType.VECTOR_CALCULUS, "div(eps(r) * grad( u(r) ))") pde.setVectorVariable("r", dimension=2) pde.setAuxiliaryFunctions({'eps': eps}) pde.configureGrid() return pde
def setupPDE_finite_differences_with_eps(): # 2. Finite Differences with aux function eps pde = PDE(64.0, 64.0) pde.setEquationExpression(PDEExpressionType.FINITE_DIFFERENCES, 'eps(i+1/2,j)*(u(i+1,j)-u(i,j)) - eps(i-1/2,j)*(u(i,j)-u(i-1,j)) + ' + \ 'eps(i,j+1/2)*(u(i,j+1)-u(i,j)) - eps(i,j-1/2)*(u(i,j)-u(i,j-1))') pde.setAuxiliaryFunctions({'eps': eps}) pde.configureGrid() return pde
def setupPDE_finite_differences(): # 1. Finite Differences without aux function eps pde = PDE(64.0, 64.0) pde.setEquationExpression( PDEExpressionType.FINITE_DIFFERENCES, '(u(i+1,j)-u(i,j)) - (u(i,j)-u(i-1,j)) + (u(i,j+1)-u(i,j)) - (u(i,j)-u(i,j-1))' ) pde.configureGrid() return pde