Statistics
| Revision:

root / src / growth_and_chemistry.cpp

History | View | Annotate | Download (2.2 kB)

1 1 akiss
#include "constants.h"
2 1 akiss
#include "growth_and_chemistry.h"
3 1 akiss
#include <gsl/gsl_errno.h>
4 1 akiss
#include <math.h>
5 1 akiss
#include <algorithm>
6 1 akiss
7 1 akiss
8 1 akiss
/* this function computes the equations of chemistry and growth */
9 1 akiss
10 1 akiss
int growth_and_chemistry(double t, const double x[], double dx[], void *parameters){
11 1 akiss
12 1 akiss
struct parameters_list2 {int edge_number; double *lengths; double *edges_width;};
13 1 akiss
14 1 akiss
double tension[(((parameters_list2*)parameters)->edge_number)];
15 1 akiss
for (int i=0;i<(((parameters_list2*)parameters)->edge_number);i++){
16 1 akiss
    tension[i]=youngs_modulus*((((parameters_list2*)parameters)->edges_width)[i])*
17 1 akiss
    ((((parameters_list2*)parameters)->lengths)[i]/x[i]-1.);
18 1 akiss
}
19 1 akiss
20 1 akiss
/// linear relation between growth and tension (ie constant viscosity)
21 1 akiss
if (growth==0){
22 1 akiss
for (int i=0;i<(((parameters_list2*)parameters)->edge_number);i++){
23 1 akiss
    dx[i]=(x[i]/((((parameters_list2*)parameters)->edges_width)[i]))*tension[i];
24 1 akiss
}}
25 1 akiss
26 1 akiss
/// linear increase then saturation (ie viscosity = 1 + T)
27 1 akiss
if (growth==1){
28 1 akiss
for (int i=0;i<(((parameters_list2*)parameters)->edge_number);i++){
29 1 akiss
    dx[i]=(x[i]/((((parameters_list2*)parameters)->edges_width)[i]))*tension[i]/
30 1 akiss
            (1.+tension[i]/(((((parameters_list2*)parameters)->edges_width)[i])*growth_threshold));
31 1 akiss
}}
32 1 akiss
33 1 akiss
/// linear with threshold (ie viscosity infinite then constant)
34 1 akiss
if (growth==2){
35 1 akiss
for (int i=0;i<(((parameters_list2*)parameters)->edge_number);i++){
36 1 akiss
    dx[i]=(x[i]/((((parameters_list2*)parameters)->edges_width)[i]))*
37 1 akiss
          std::max(tension[i]-((((parameters_list2*)parameters)->edges_width)[i])*growth_threshold,0.);
38 1 akiss
}}
39 1 akiss
40 1 akiss
/// increase more than linear (viscosity = 1 / (1+T) )
41 1 akiss
if (growth==3){
42 1 akiss
for (int i=0;i<(((parameters_list2*)parameters)->edge_number);i++){
43 1 akiss
    dx[i]=(x[i]/((((parameters_list2*)parameters)->edges_width)[i]))*tension[i]*
44 1 akiss
            (1.+tension[i]/(((((parameters_list2*)parameters)->edges_width)[i])*growth_threshold));
45 1 akiss
}}
46 1 akiss
47 1 akiss
/// linear increase, maximum then decrease to 0. (ie viscosity = 1 + T²)
48 1 akiss
if (growth==4){
49 1 akiss
for (int i=0;i<(((parameters_list2*)parameters)->edge_number);i++){
50 1 akiss
    dx[i]=(x[i]/((((parameters_list2*)parameters)->edges_width)[i]))*tension[i]/
51 1 akiss
            (1.+pow(tension[i]/(((((parameters_list2*)parameters)->edges_width)[i])*growth_threshold),2.));
52 1 akiss
}}
53 1 akiss
54 1 akiss
return GSL_SUCCESS;
55 1 akiss
}