AMReX-Microelectronics / FerroX

FerroX is a massively parallel, 3D phase-field simulation framework for modeling ferroelectric materials based scalable logic devices.
Other
9 stars 9 forks source link

Added derivative kernels #14

Closed jackieyao0114 closed 1 year ago

jackieyao0114 commented 2 years ago

Added one new header file DerivativeAlgorithm.H which includes the derivative kernels to calculate dP/dz, d2P/dz2 and dphi/dz. This will simplify the functions CalculateTDGL_RHS and ComputePoissonRHS by just calling the appropriate kernel functions. This will also get us prepared to add more terms of TDGL energy.

The following input file is used to evaluate the difference between the output multifabs before and after this PR. Here's the result for ./ComparePlotfiles3d.gnu.ex infile1 = plt_new/plt00000004/ reffile = plt_old/plt00000004/

AMReX (22.05-179-g944edbd481cd-dirty) initialized
ncomp = 9
nodality (0,0,0)
npts in coarse domain = 262144
npts in fine   domain = 262144
ref_ratio = 1
(comp,L0,L1,L2) 0 2.168404345e-19 1.675980305e-22 3.197993014e-21 
(comp,L0,L1,L2) 1 1.734723476e-18 1.897273434e-21 3.652956936e-20 
(comp,L0,L1,L2) 2 2.328306437e-10 3.31243894e-13 4.516396542e-12 
(comp,L0,L1,L2) 3 1.746229827e-09 3.744506238e-12 5.160466717e-11 
(comp,L0,L1,L2) 4 1.746229827e-09 3.751565946e-12 5.165132967e-11 
(comp,L0,L1,L2) 5 2.793967724e-09 3.810947543e-12 5.293449314e-11 
(comp,L0,L1,L2) 6 0 0 0 
(comp,L0,L1,L2) 7 0 0 0 
(comp,L0,L1,L2) 8 0 0 0 
AMReX (22.05-179-g944edbd481cd-dirty) finalized

The variables are listed below: "P","Phi","PoissonRHS","Ex","Ey","Ez","holes","electrons","charge"

It should be noted that:

  1. The DoubleDPDz and DPDz functions still remain the previous 1st order one-sided derivative for P_BC_flag_hi == 1. As I have noticed well-above machine precision discrepancy with the 2nd order one-sided derivative compared to the current development branch.
  2. In ComputeEfromPhi function, the calculation of Ex, Ey and Ez is still hard coded. We should update them with the new kernels in DerivativeAlgorithm.H.
ajnonaka commented 2 years ago

These diffs look ok to me. The E field is 10^-9 because it's scaled by 1/dx compared to phi.