allen_cahn_2D module#
Solving 2D Allen-Cahn eqations in 2D with homogenous boundary conditions
- Consturct V_n := span { phi_{n}}, where phi_{n} is n-th order Polynomial such that phi_{n} = 0 at the boundaries 
- Consturct phi_{n} = L_{n+2} - L_{n} , where L_{n} is n-th order Legendre Polynomial 
- The Quad can be computed as difference of two quad, using linearity as, - Consider ( f , phi_{j} ) = ( f , L_{j+2} ) - ( f , L_{j} ) 
- For mass matrix : in the above quad rule plug : f = L_{k+2} - L_{k} 
- For 2D Quad, constrct : phi_{ij} = phi_i o phi_j - Consider, (f (x, y ), phi_{ij} ) = ( f (x) o f(y) , phi_{ij} ) = ( f(x) , phi_{i}) o ( f(y) , phi_{j}) 
Created on Sat Sep 2 15:24:54 2023
@author: Pavan Pranjivan Mehta
- allen_cahn_2D.eval_A(epi, M, K, dt)#
- Computes A = M + dt * episilon * episilon * K - Parameters#- Nint
- max degree of the polynomial 
- Knumpy araray
- 2D Stiffness matrix of dim = (N^2 x N^2) 
- Mnumpy araray
- 2D Mass matrix of dim = (N^2 x N^2) 
- dtfloat
- time step 
- epifloat
- diffusion constant, episilon 
 - Returns#- A = M + dt * episilon * episilon * K - A: numpy array float, dim = (N^2 x N^2)
- A = M + dt * episilon * episilon * K 
 
- allen_cahn_2D.eval_b(coeff_old, N, M, dt)#
- Computes b = M [ eta_coeff - f_prime (eta_coeff) ] - Parameters#- Nint
- max degree of the polynomial 
- coeff_oldnumpy araray
- coeffecients of eta at time-step k obtained as reuslt of L2 Projection 
- Mnumpy araray
- Mass matrix of dim = (N^2 x N^2) 
- dtfloat
- time step 
 - Returns#- b = M [ eta_coeff - f_prime (eta_coeff) ] - b: numpy array float, dim = (N^2)
- b = M [ eta_coeff - f_prime (eta_coeff) ] 
 - Notes#- f = eta**2 ( eta - 1 )**2 f_prime = 4 eta**3 - 6 eta**2 + 2 eta 
- allen_cahn_2D.initial_valueX(x)#
- Computes Initial value in 1D - Parameters#- xfloat or numpy array
- spatial points in [-1, 1] in “x” or “y” direction 
 - Returns#- Initial value: numpy array - Notes#- Available functions: random, sin (x * pi) and runge in [0, 1] 
- allen_cahn_2D.initial_value(x, y)#
- Computes Initial value in 2D - Parameters#- xfloat or numpy array
- spatial points in [0, 1] in “x” direction 
- y: float or numpy array
- spatial points in [0, 1] in “y” direction 
 - Returns#- Initial value: numpy array
- Coputes 2D intial value from of 1D valuues 
 
- allen_cahn_2D.function_projection_2d(degree, M)#
- Computes Coeffcients from L2 projection of Initial value - Parameters#- degreeint
- max degree of the polynomial 
- Mnumpy araray
- Mass matrix of dim = (N^2 x N^2) 
 - Returns#- Coeffcients: numpy array
- Coeffcients from L2 projection of initial value basis = homogenous basis using legendre polynomials 
 
- allen_cahn_2D.construct_sol(coeff, x, y, N, M)#
- Constructs function value, f(x) as; - f(x) = coeff_0 * P_0 + coeff_1 * P_1 + coeff_3 * P_2 + … - where, P_n is basis function of n-th degree - Parameters#- Nint
- max degreo of the polynomial 
- M2D numpy array
- 2D mass matrix of dim = N^2 x N^2 
- coeffnumpy araray
- coeffecients of eta obtained as reuslt of L2 Projection 
- xfloat or numpy array
- spatial points in [-1, 1] in “x” direction 
- yfloat or numpy array
- spatial points in [-1, 1] in “y” direction 
 - Returns#- f(x): numpy array
- function value upon expansion over basis basis = homogenous basis using legendre polynomials