Statistics
| Revision:

root / src / step.cpp

History | View | Annotate | Download (1.7 kB)

1 1 akiss
#include "step.h"
2 1 akiss
#include <stdio.h>
3 1 akiss
#include <math.h>
4 1 akiss
#include "minimize_BFGS.h"
5 1 akiss
#include "growth_and_chemistry.h"
6 1 akiss
#include <gsl/gsl_odeiv2.h>
7 1 akiss
#include <gsl/gsl_errno.h>
8 1 akiss
#include "compute_energy_and_forces.h"
9 1 akiss
#include "save_data.h"
10 1 akiss
#include <cstdlib>
11 1 akiss
#include "constants.h"
12 1 akiss
#include <algorithm>
13 1 akiss
#include "compute_lengths.h"
14 1 akiss
15 1 akiss
16 1 akiss
/* this function performs a time step (growth and chemistry then mechanics) */
17 1 akiss
18 1 akiss
void step(double *vertices, int vertex_number, int edge_number, int *edges_vertices, double *lengths, double *rest_lengths, double *edges_width, int *periodizer, double *width, double *height){
19 1 akiss
20 1 akiss
/* minimization of energy: move the vertices in order to make the energy as small as possible, i.e. in order to make cells
21 1 akiss
   as close as possible of their targets */
22 1 akiss
minimize_BFGS(vertex_number, vertices, edge_number, edges_vertices, lengths, rest_lengths, edges_width, periodizer, width, height);
23 1 akiss
24 1 akiss
25 1 akiss
compute_lengths(vertices, edges_vertices, edge_number, lengths, periodizer, width[0], height[0]);
26 1 akiss
27 1 akiss
struct parameters_list2 {int edge_number; double *lengths; double *edges_width;};
28 1 akiss
29 1 akiss
struct parameters_list2 parameters2;
30 1 akiss
parameters2.edge_number=edge_number;
31 1 akiss
parameters2.lengths=lengths;
32 1 akiss
parameters2.edges_width=edges_width;
33 1 akiss
void *pparameters2=&parameters2;
34 1 akiss
int system_size=edge_number;
35 1 akiss
36 1 akiss
double x[system_size];
37 1 akiss
for (int i=0;i<edge_number;i++){ x[i]=rest_lengths[i];}
38 1 akiss
39 1 akiss
gsl_odeiv2_system sys={growth_and_chemistry, NULL, system_size, pparameters2};
40 1 akiss
gsl_odeiv2_driver *d=gsl_odeiv2_driver_alloc_y_new (&sys, gsl_odeiv2_step_rk2, 1.e-8, 1.e-8, 0.);
41 1 akiss
int s; double t=0.0;
42 1 akiss
s=gsl_odeiv2_driver_apply(d, &t, 1.e-7, x);
43 1 akiss
for (int i=0;i<edge_number;i++){ rest_lengths[i]=x[i];}
44 1 akiss
gsl_odeiv2_driver_free(d);
45 1 akiss
46 1 akiss
}
47 1 akiss
48 1 akiss
49 1 akiss
50 1 akiss