Statistics
| Revision:

root / src / step.cpp

History | View | Annotate | Download (1.7 kB)

1
#include "step.h"
2
#include <stdio.h>
3
#include <math.h>
4
#include "minimize_BFGS.h"
5
#include "growth_and_chemistry.h"
6
#include <gsl/gsl_odeiv2.h>
7
#include <gsl/gsl_errno.h>
8
#include "compute_energy_and_forces.h"
9
#include "save_data.h"
10
#include <cstdlib>
11
#include "constants.h"
12
#include <algorithm>
13
#include "compute_lengths.h"
14

    
15

    
16
/* this function performs a time step (growth and chemistry then mechanics) */
17

    
18
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

    
20
/* minimization of energy: move the vertices in order to make the energy as small as possible, i.e. in order to make cells
21
   as close as possible of their targets */
22
minimize_BFGS(vertex_number, vertices, edge_number, edges_vertices, lengths, rest_lengths, edges_width, periodizer, width, height);
23

    
24

    
25
compute_lengths(vertices, edges_vertices, edge_number, lengths, periodizer, width[0], height[0]);
26

    
27
struct parameters_list2 {int edge_number; double *lengths; double *edges_width;};
28

    
29
struct parameters_list2 parameters2;
30
parameters2.edge_number=edge_number;
31
parameters2.lengths=lengths;
32
parameters2.edges_width=edges_width;
33
void *pparameters2=&parameters2;
34
int system_size=edge_number;
35

    
36
double x[system_size];
37
for (int i=0;i<edge_number;i++){ x[i]=rest_lengths[i];}
38

    
39
gsl_odeiv2_system sys={growth_and_chemistry, NULL, system_size, pparameters2};
40
gsl_odeiv2_driver *d=gsl_odeiv2_driver_alloc_y_new (&sys, gsl_odeiv2_step_rk2, 1.e-8, 1.e-8, 0.);
41
int s; double t=0.0;
42
s=gsl_odeiv2_driver_apply(d, &t, 1.e-7, x);
43
for (int i=0;i<edge_number;i++){ rest_lengths[i]=x[i];}
44
gsl_odeiv2_driver_free(d);
45

    
46
}
47

    
48

    
49

    
50

    
51