“This is my FreeFem code, and I’m encountering an error in the macro definitions of EXR1 and EXR2. The primary section of the code begins with ‘////////////////////////////////////////////////Second Order scheme() ,’ followed by the problem definition > problem PHITMUMUN(phiT, muphibar, n, munbar, phiTb, muphib, nb, munb) .
Prior to this section, I have defined the finite element spaces required for solving the main problem and have also computed two initial values necessary for the primary scheme. Subsequently, I implement the problem-solving process using a for loop for each time step. I would greatly appreciate any assistance with this issue.”
//initials
int n1=8;
load "lapack";
//border
border b (t =-1,1) { x =t ; y =-1 ; label =2;}
border c (t =-1 ,1) { x =1 ; y =t ; label =3;}
border d1 (t =1,-1) { x =t ; y =1; label =4;}
border e1(t =1,-1) { x =-1;y =t ; label =5;}
mesh Th100 = buildmesh(b(n1)+c(n1)+d1(n1)+e1(n1));
//plot ( Th100 , ps=" wholedomainphi.eps ",cmm="square",value = true,wait = true);
//savemesh(Th100,"Th110.msh"); // Save the Mesh
//mphi = M*phi^2, Mn = M
real p0=300,epsil=0.02,error = 0.001,dt = 0.00001,T =0.0001,delta = 0.01,Gamma = 0.25,chi0=0.05,M=10,threshold = 0.000001,X0=0.25;
real numadapt = 0,c0 = 0.25,alfa = 3;
fespace Vh100(Th100,P2);
Vh100 h=hTriangle;
macro df(u) 4*Gamma*u^3-6*Gamma*u^2+2*Gamma*u //
macro f(u) Gamma*u^2*(1-u)^2 // //
macro P(s) p0*s*delta*(s>=0)+0*(s<0) //
macro MM(u) M*u^2 //
macro chi(u,v) -X0*u*v //
macro chiu(u,v) -X0*v//
macro chiv(u,v) -X0*u//
macro E1(u,v) int2d(Th100)(Gamma*u^2*(1-u)^2+chi(u,v))//
macro be1(u,v) (df(u)+chiu(u,v))/sqrt(E1(u,v)+c0) //
macro be2(u,v) ( chiv(u,v) )/sqrt(E1(u,v)+c0) //
macro EXR1(u,v,z) int2d(Th100)((be1(u,v))*z)//
macro EXR2(u,v,z) int2d(Th100)((be2(u,v))*z)//
Vh100 phiTp,phiT,phiTb,muphi,muphipp,muphib,muphip,muphibar,n,np,npp=1,nb,mun,munp,munpp,munbar,munb,phitilda,ntilda,muphitilda,muntilda,Ptilda,MMtilda;
Vh100 rp,rtildap;
Vh100 phiTpp =tanh((0.15-sqrt(x^2+y^2))/(sqrt(2)*epsil));
Vh100 rpp = sqrt(E1(phiTpp,npp)+c0);
plot(Th100,phiTpp,wait = true,ps ="phiTpp.eps",cmm = "phiTpp",fill = true,value = true);
plot(Th100,npp,wait = true,ps ="npp.eps",cmm = "npp",fill = true,value = true);
//muphipp
problem MUphiPP(muphipp,muphib)=int2d(Th100)(muphipp*muphib)
-int2d(Th100)((df(phiTpp))*muphib)-int2d(Th100)((chiu(phiTpp,npp))*muphib)
-int2d(Th100)(epsil^2* (dx(phiTpp)*dx(muphib)+dy(phiTpp)*dy(muphib)));
//
//munpp
problem MUnPP(munpp,munb)=int2d(Th100)(munpp*munb)-int2d(Th100)(chiv(phiTpp,npp)*munb)
-int2d(Th100)((1/delta)*npp*munb);
MUphiPP;
MUnPP;
plot(Th100,muphipp,wait = true,ps ="muphipp.eps",cmm = "muphipp",fill = true,value = true);
plot(Th100,munpp,wait = true,ps ="munpp.eps",cmm = "munpp",fill = true,value = true);
//find the second initial of the system(The one which is according to the final system);
//I used perturbation for the second initial means purturb the first initial very small and take the result as a second initial but I will replace it with an appropriate method later on
phiTp = phiTpp + 0.00001;
muphip = muphipp + 0.00001;
np = npp+0.00001;
munp = munpp+0.00001;;
////////////////////////////////////////////////Second Order scheme
problem PHITMUMUN(phiT,muphibar,n,munbar,phiTb,muphib,nb,munb) =
//phiT which is volume fraction of tumor cells equation
int2d(Th100)(phiT*phiTb)
-int2d(Th100)(phiTp*phiTb)
+int2d(Th100)(dt*MMtilda*(dx(muphibar)*dx(phiTb)+dy(muphibar)*dy(phiTb)))
-int2d(Th100)(dt*Ptilda*munbar*phiTb)
+int2d(Th100)(dt*Ptilda*muphibar*phiTb)
//muphi equation
+int2d(Th100)(muphibar*muphib)
-int2d(Th100)(0.25*epsil^2*(dx(phiTpp)*dx(muphib)+dy(phiTpp)*dy(muphib)))
-int2d(Th100)(0.75*epsil^2*(dx(phiT)*dx(muphib)+dy(phiT)*dy(muphib)))
-int2d(Th100)(rp*(be1(phitilda,ntilda))*muphib)
-int2d(Th100)(0.25*(EXR1(phitilda,ntilda,phiT))*(be1(phitilda,ntilda))*muphib)
+int2d(Th100)(0.25*(EXR1(phitilda,ntilda,phiTp))*(be1(phitilda,ntilda))*muphib)
-int2d(Th100)(0.25*(EXR2(phitilda,ntilda,n))*(be1(phitilda,ntilda))*muphib)
+int2d(Th100)(0.25*(EXR2(phitilda,ntilda,np))*(be1(phitilda,ntilda))*muphib)
//nutrition rich watter equation
+int2d(Th100)(n*nb)
-int2d(Th100)(np*nb)
+int2d(Th100)(M*dt*(dx(munbar)*dx(nb)+dy(munbar)*dy(nb)))
+int2d(Th100)(dt*Ptilda*munbar*nb)
-int2d(Th100)(dt*Ptilda*muphibar*nb)
//mun
+int2d(Th100)(munbar*munb)
-int2d(Th100)(rp*(be2(phitilda,ntilda))*munb)
-int2d(Th100)(0.25*(EXR1(phitilda,ntilda,phiT))*(be2(phitilda,ntilda))*munb)
+int2d(Th100)(0.25*(EXR1(phitilda,ntilda,phiTp))*(be2(phitilda,ntilda))*munb)
-int2d(Th100)(0.25*(EXR2(phitilda,ntilda,n))*(be2(phitilda,ntilda))*munb)
+int2d(Th100)(0.25*(EXR2(phitilda,ntilda,np))*(be2(phitilda,ntilda))*munb);
for(int i=0;i<=T/dt;i+=1){
phitilda = 1.5*phiTp-0.5*phiTpp;
Ptilda = 1.5*(P(phiTp))-0.5*(P(phiTpp));
MMtilda = 1.5*(MM(phiTp))-0.5*(MM(phiTpp));
rp = sqrt(E1(phiTp,np)+c0);
rtildap = sqrt(E1(phitilda,ntilda)+c0);
PHITMUMUN;
real AA = dx(phiT)^2+dy(phiT)^2+alfa*dx(n)^2+alfa*dy(n)^2;
if(AA>threshold){
numadapt=numadapt+1;
Th100 = adaptmesh(Th100,AA);
phitilda = 1.5*phiTp-0.5*phiTpp;
ntilda = 1.5*np - 0.5*npp;
Ptilda = 1.5*(P(phiTp))-0.5*(P(phiTpp));
MMtilda = 1.5*(MM(phiTp))-0.5*(MM(phiTpp));
rp = sqrt(E1(phiTp,np)+c0);
PHITMUMUN
;};
muphi[] = 2*muphibar[]-muphip[];
mun[] = 2*munbar[]-munp[];
phiTpp[]= phiTp[];
phiTp[] = phiT[];
muphipp[] = muphip[];
muphip[] = muphi[];
npp[] = np[];
np[] =n[];
munpp[] = munp[];
munp[] = mun[];
cout<<"number of iteration="<<i<<endl;
cout<<"Metric="<<AA<<endl;
//***if(i==10 | i==50 | i==100 | i == 500){
plot(Th100,phiTp,wait = true,ps ="phiTp.eps",cmm = "phiTp",fill = true,value = true);
//plot(phiDp,wait = true,ps ="phiDp.eps",cmm = "phiDp",fill = true,value = true);
//plot(mup,wait = true,ps ="mup.eps",cmm = "mup",fill = true,value = true);
//plot(Th100,pp, wait=true,ps="pp.ps",cmm="pp",fill = true,value = true);
//plot(Th100,np, wait=true,ps="np.ps",cmm="np",fill = true,value = true);
////////****cout<<"phip="<<phip[]<<endl;
//plot(mup,wait = true,ps ="mup.eps",cmm = "mup",fill = true,value = true);
/////***cout<<"mup="<<mup[]<<endl;
//plot(pp, wait=true,ps="pp.ps",cmm="pp",fill = true,value = true);
///////***cout<<"pp="<<pp[]<<endl;
//};
};
plot(Th100,phiTp,wait = true,ps ="phiT.eps",cmm = "phiT",fill = true,value = true);
cout<<"phiT="<<phiTp[]<<endl;
plot(Th100,muphi,wait = true,ps ="muphi.eps",cmm = "muphi",fill = true,value = true);
cout<<"muphip="<<muphip[]<<endl;
plot(Th100,np, wait=true,ps="n.ps",cmm="n",fill = true,value = true);
cout<<"np="<<np[]<<endl;
plot(Th100,munp, wait=true,ps="mun.ps",cmm="mun",fill = true,value = true);
cout<<"munp="<<munp[]<<endl;
cout<<"size of mesh =" <<h[].max<<endl;
cout<<"number of adaptation="<<numadapt<<endl;
ofstream file("phiT40.txt");
file << phiT[];