# Interesting result, not obvious earlier,

**URL:** <https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286>\
**Category:** General Discussion\
**Created:** [February 17, 2023, 9:28am UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286 "2023-02-17T09:28:17Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [February 17, 2023, 9:28am UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/1 "2023-02-17T09:28:17Z")

</div>

As part of learning FreeFEN, I tried to model a system of several species ( called f1,f1a,f2,f2a,  
fgn, and fb ). The species f1,f2, and fgn are present at some uniform concentration in a liquid  
while f1a, f2a, and fb are created at some reaction that occurs in the right i in th e attached  
images. Reactions transform f1 → f1a , f2-\> f2a, and fgn → fb. The first reaction requires  
interaction with a fixed substance on the right, the second requires f1a, and the thrid requires f2a.  
The images below show [fgn] being depleted where it can form fb but also with a maxima in a surprising location.  
The species diffuse but with a diffusivity that depends on concentration of other species.  
It does appear that it is possible for high concntration regions to further concentrate  
species due to the diffusivity gradient. Curious if anyone has looked at problems  
like this. It does appear that sorting out artifacts from real effects or numerical and math  
issues can be quite a challenge 🙂

 ![fgn1](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/68b6d2bd6bb5a6153b1871ac37de0a8de8311c18.jpeg)  
 ![fgn2](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/7/7ce202d95dd39852712add4df77bf0450d967183.jpeg)

---

<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:** [February 19, 2023, 3:56pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/2 "2023-02-19T15:56:50Z")

</div>

I sorry, you question a too esoteric, without model, equation, it impossible to say something raisonable.

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [February 19, 2023, 4:10pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/3 "2023-02-19T16:10:56Z")

</div>

Thanks. It was just more of an observation than a question. I hesistate to post the  
code right now as it is in bad shape and part of the result may be due to bugs.  
However, I guess that was my point Seeing an extreme value, in this  
case a maximum, in a source free region I though was suggetive or  
a math or coding mistake. However, I had a diffusivity dependent on concentration  
of other species making some effects like this possible. It is just Fick’s  
Law with variable “D” . There exist concentration gradients in two directions  
as the reactant fgn is concerted to fb on the right side.  
Just curious though if there are similar well studied real systems  
that are similar or maybe an example. In the real system the species form  
a gel and ultimately a solid that stops diffusion.  
My immediate interest is blood coagulation- I have seen some models published  
but never looked at the details of hose they did it.

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [February 19, 2023, 4:28pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/4 "2023-02-19T16:28:17Z")

</div>

Well, I am not shocked in principle by some density overshoot somewhere.  
Without knowing the details, it is hard to say, but naively I would say that it might be a consequence of the boundary conditions: from the pictures I make the following observations

- it looks like outside your _droplet_ there are Dirichlet conditions
- I see some gradients through your interface

Could this overshoot be a consequence of you BC, and some conservation laws playing together?

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [February 19, 2023, 4:49pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/5 "2023-02-19T16:49:57Z")

</div>

Thanks. Maybe I’ll set the parameters back to reproduce this and post the code  
if there is that much interest. In essence the right side is a wall with a patch  
that converts f1 to f1a enzymatically at a non saturating first order rate ( df1a/dt= c\* f1 ) .  
The other three sides are bulk fluid with constant concentrations of reactants f1,f2, and  
fgn with zero f1a,f2a, and fb ( Dirichlet ). The fixed enzyme patch that converts f1 to f1a  
I guess has an interface but basically everything is supposed to be continuous  
except to the extent the diffusivity approaches zero and creates a solid or gel 🙂

I looked at the results in R briefly and the diffusivity gradient was there but total  
change was very small only about 2 percent IIRC. I did not numerically check  
to see if grad(D) \dot grad(n) compared to D\*laplacian(n) 🙂

---

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [February 19, 2023, 5:16pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/6 "2023-02-19T17:16:04Z")

</div>

Complete speculation here, but I find your explanation reminiscent of thermal-diffusive instability in flames at non-unity Lewis numbers. Preferential diffusion has some interesting consequences including superadiabatic flame temperature. Such phenomena may be related to what you’re describing.

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [February 19, 2023, 6:04pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/7 "2023-02-19T18:04:54Z")

</div>

Thanks, assuming this ref captures the issues you raise,

[https://link.springer.com/article/10.1007/s10494-020-00173-7](https://link.springer.com/article/10.1007/s10494-020-00173-7)

( and I’m surprised this would ever approach unity lol ),

then there may be similar factors here as I guess diffusivity tends to be theramaly  
activated and T gradients to the extent you can define a local temperature,  
would produce similar results. I guess doing a microscopic simulation may  
be important but right now I’m just looking for math  
and coding mistakes 🙂

---

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [February 19, 2023, 7:06pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/8 "2023-02-19T19:06:35Z")

</div>

Of course things are more intricate at the microscopic level but you can understand the basic physics using only the kuramoto-sivashinsky equation.

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [February 19, 2023, 8:18pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/9 "2023-02-19T20:18:41Z")

</div>

Are these 4th deivatives solvable in FreeFEM?

[https://en.wikipedia.org/wiki/Kuramoto%E2%80%93Sivashinsky\_equation](https://en.wikipedia.org/wiki/Kuramoto%E2%80%93Sivashinsky_equation)

and fwiw, I guess a line ratio is a temperature lol.

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [February 20, 2023, 1:35pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/10 "2023-02-20T13:35:37Z")

</div>

yes, for bilaplacian use (doc is here)

> load “Morley”

for time integration, probably Crank-Nicolson, and forward Richardson extrapolation to treat the nonlinearity…

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [February 21, 2023, 12:08am UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/11 "2023-02-21T00:08:10Z")

</div>

I guess rather than upload the entire system, I just extracted the part  
of interest. This considers the case of diffusion with a non-uniform diffusivity  
and diffusivities that produce extreme values in the concentrations in a source  
free region. The unknown here is called “f1” and steady state distributions  
solved with constant concentration of 100 on each side of a square 2D area.,  
This iterates through some diffusivities curves producing varying amounts  
of concentration peaks. The first few are kind of “controls” then the  
effect is seen more clearly in the latter ones, see the code for details.  
fwiw, not sure this is all that profound but I was curious. Maybe someone  
can relate it to a well studied issue. I just needed the practice lol.

[singd.edp](https://community.freefem.org/uploads/short-url/nIM1GS8zXKsvhQxBq4MNz4nNM17.edp) (7.9 KB)

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [February 24, 2023, 9:09pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/12 "2023-02-24T21:09:02Z")

</div>

I decided that the easiest way to explore this is just time stepping the equation for  
dn/dt but I’m not sure that FreeFem is the fastest way to do that. So, I wrote my own  
FD code and got much faster iterations. I changed the geometry slightly and now  
have an enzymatic square in the middle of the grid that converts f1 to f1a which  
converts f2 to f2a which converts fgn to the gel component fb. I’m not sure how close  
this is to steady state but I did get s singificant concentration peak. I want to use the FD results in FreeFEm as initial conidtions but could not find an obvious command to import them. I wrote  
a loop ( see the attached edp file ) that sort of reads the txt file and produces the attached  
display. However, this is not quite right as the plots from “R” show the square in the center along with the diffusivity plot and concentration of the glue fb. Probably once I get going I will want to have at least two or three methods for sanity check and an FD approach may be one of those  
so I expect to do this a bit. What is the best way to load data in this format into a mesh?

[fd.edp](https://community.freefem.org/uploads/short-url/uLmYrrLapXffqz3hcOu0xi6vwam.edp) (368 Bytes)  
[fddump.zip](https://community.freefem.org/uploads/short-url/91c6s9mbxx36wVaGHs47DsvACPT.zip) (545.7 KB)

 ![fddump50](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/697bf7687bfef35629212f1e2ceb1f56cdfdc446.jpeg)  
 ![fdfbglug](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/1/1a14d7a2b7211f6a577f93a497856c83f6ddf011.jpeg)  
 ![fddiff](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/6a1f384f12abf7b0205c920f73b7b137f9d1ada0.jpeg)

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [February 25, 2023, 12:22pm UTC](https://community.freefem.org/t/interesting-result-not-obvious-earlier/2286/13 "2023-02-25T12:22:47Z")

</div>

It looks like triangulate was the way to go here although if you are  
looking for features adding column locations for X/y would be nice 🙂  
The attached medit shot seems to reflect the text file. fwiw, this is a few  
thousand time steps of glue or gel deposition around an activating  
square. This is a complicated region including a source so its difficult  
to say much. This “goo” is used to reduce the diffusivity and it does look  
like the FD simulation is a good sanity check on any FEM work. This  
wall of “castle” does indeed seem to deplete the precursor inside and prevent  
diffusion of the activating enzyme to the outside and just by eye it looks like the  
quantities are reasonably conserved- the amount of goo us probably near the amount  
of precursor consumed ( transport from the boundaries is probably low ). I initially  
forgot the grad(D)grad(N) term and it falls out of the variational form  
but seems to be important to getting this result. D only varies may 10 percent or  
so but has a steep gradient.

 ![fdtri](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/8/8ba71cb4cab78eda1b3a5ddb294ed6098da86acd.jpeg)

```auto
cat fd.edp 
load "medit"
// best example I can find I guess, 
// https://doc.freefem.org/documentation/mesh-generation.html#the-keyword-%E2%80%9Ctriangulate%E2%80%9D
mesh Th =triangulate("fd2.txt"); // square(sz,sz);
fespace Vh(Th,P1) ;
Vh data;
real[int] mdata(20000);
ifstream ifs("fddump.txt");
//ifs>> data[][0];
data[]=mdata;
real x; 
for (int i=0; i<10000; ++i)
{

for (int j=0; j<11; ++j)
{ if (j==8) ifs>> mdata[i];
else ifs>> x; 
}

} // i 

data[]=mdata;
//cout<<data<<endl;
//plot(data,fill=1,wait=1);
medit("asdf",Th,data);

```
