# Logarithm Error in system of PDEs

**URL:** <https://community.freefem.org/t/logarithm-error-in-system-of-pdes/3027>\
**Category:** General Discussion\
**Created:** [March 10, 2024, 12:05pm UTC](https://community.freefem.org/t/logarithm-error-in-system-of-pdes/3027 "2024-03-10T12:05:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wilkinsonad01](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@Wilkinsonad01](https://community.freefem.org/u/Wilkinsonad01)\
**Post date:** [March 10, 2024, 12:05pm UTC](https://community.freefem.org/t/logarithm-error-in-system-of-pdes/3027/1 "2024-03-10T12:05:11Z")

</div>

Hi,  
I am very new to FreeFEM so I am probably making a few simple mistakes but would really appreciate your help.

I am trying to solve a system of 6 PDEs to model cancer growth. This is my code so far:

real L = 1.0;  
real D = 10.0;  
real b = 1.0;  
real P = 1.2;  
int meshSize = 50;

int wall = 1;  
int inlet = 2;  
int outlet = 3;

mesh Mesh;  
border b1(t =0.,1.){x=L_t; y = 0.; label=wall;};  
border b2(t=0.,1.){x=L; y=L_t; label=outlet;};  
border b3(t=0.,1.){x=L-L_t; y=L; label =wall;};  
border b4(t=0.,1.){x=0.;y=L-L_t; label=inlet;};

Mesh = buildmesh(b1(meshSize) + b2(meshSize) + b3(meshSize) + b4(meshSize));  
plot(Mesh, wait =1);

real t = 0.0;  
real dt = 0.2;  
real Kc = 1.0;  
real Kn = 1.0;  
real epsilon = 0.001;  
real Pan = 1.0;  
real Pac = 1.0;  
real Pbn = 1.0;  
real Pbc = 1.0;  
real Q = 1.0;  
real deltaA = 1.0;  
real deltaB = 1.0;  
real deltaE = 1.0;

real dC = 1.0;  
real dN = 1.0;  
real dA = 1.0;  
real dB = 1.0;  
real dX = 1.0;  
real dE = 1.0;

real DA = 1.0;  
real DB = 1.0;  
real DX = 1.0;  
real DE = 1.0;

real G = 1.0;

fespace Space(Mesh, P1);  
Space C, Ncell, A, B, X, E, v;

problem Cequation(C, v) =  
int2d(Mesh)( dC \* C \* v / dt + -C \* log((C/Kc)+ epsilon) \* v)  
+ on(1, C = 1);

problem Nequation(Ncell, v) =  
int2d(Mesh)( dN \* Ncell \* v / dt + -C \* log(Ncell / Kn + epsilon) \* v)  
+ on(1, Ncell = 1);

problem Aequation(A, v) =  
int2d(Mesh)( dA \* A \* v / dt + DA \* dx(A) \* dx(v)+ Pan \* Ncell \* v+ Pac \* C \* v - deltaA \* A \* v)  
+ on(1, A = 1);

problem Bequation(B, v) =  
int2d(Mesh)( dB \* B \* v / dt + DB \* dx(B) \* dx(v)+ Pbn \* Ncell \* v+ Pbc \* C \* v - deltaB \* B \* v)  
+ on(1, B = 1);

problem Xequation(X,v) =  
int2d(Mesh)(dX\* X \* v / dt + DX \* dx(X) \* dx(v) + Q \* (1 - X) \* E \* v - C \* X - Ncell \* X )  
+ on(1, X = 1);

problem Eequation(E,v) =  
int2d(Mesh)(dE \* E \* v / dt + DE \* dx(E) \* dx(v) + G \* E \* v - deltaE \* E \* v)  
+ on(1, X = 1);

In my first and second equation, I use a log function : log((C/Kc)+epsilon). When I run the code I am getting the error \<10LinearCombI7MGauche4C\_F0E\>, . I think it has something to do with having C in the log function - maybe causing negative numbers in the log.

Does anyone know how to fix this issue? Also any other recommendations on how I should solve this system would be great. Thanks

---

<div class="post-metadata">

**Author:** ![Wilkinsonad01](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@Wilkinsonad01](https://community.freefem.org/u/Wilkinsonad01)\
**Post date:** [March 10, 2024, 12:23pm UTC](https://community.freefem.org/t/logarithm-error-in-system-of-pdes/3027/2 "2024-03-10T12:23:28Z")

</div>

could you let me know if there are any good examples that are similar to this? thanks

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [March 10, 2024, 5:12pm UTC](https://community.freefem.org/t/logarithm-error-in-system-of-pdes/3027/3 "2024-03-10T17:12:31Z")

</div>

The following is Non linear, so you have to choose a algorithme to approximate.

```auto
problem Cequation(C, v) =
int2d(Mesh)( dC * C * v / dt + -C * log((C/Kc)+ epsilon) * v)
+ on(1, C = 1);

```

[/quote]

---

<div class="post-metadata">

**Author:** ![Wilkinsonad01](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@Wilkinsonad01](https://community.freefem.org/u/Wilkinsonad01)\
**Post date:** [March 10, 2024, 8:38pm UTC](https://community.freefem.org/t/logarithm-error-in-system-of-pdes/3027/4 "2024-03-10T20:38:55Z")

</div>

Thanks. What algorithm would you recommend?

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [March 11, 2024, 2:47pm UTC](https://community.freefem.org/t/logarithm-error-in-system-of-pdes/3027/5 "2024-03-11T14:47:30Z")

</div>

first I suppose the term is

```auto
-C * log((C/Kc)*v 

```

you can user a fixed point method

```auto
-C * log((Cp/Kc)*v 

```

where Cp is the previous value of C.  
and make a loop on p.

---

<div class="post-metadata">

**Author:** ![Wilkinsonad01](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@Wilkinsonad01](https://community.freefem.org/u/Wilkinsonad01)\
**Post date:** [March 12, 2024, 9:31pm UTC](https://community.freefem.org/t/logarithm-error-in-system-of-pdes/3027/6 "2024-03-12T21:31:59Z")

</div>

Thank you so much for the help.
