00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "ne_dyn_edge_ode_lib.h"
00024
00025
00026 ne_dyn_edge_t * ne_dyn_ode_e_none_alloc (void)
00027 {
00028 ne_dyn_edge_t *edgeDyn;
00029
00030 if ((edgeDyn = (ne_dyn_edge_t *)malloc(sizeof(ne_dyn_edge_t))) == NULL) {
00031 ne_error("ne_dyn_ode_e_none_alloc: Could not allocate memory.");
00032 return NULL;
00033 }
00034
00035
00036 edgeDyn->name = "ODE_E_NONE";
00037 edgeDyn->states = 0;
00038 edgeDyn->fn = &ne_dyn_ode_e_none_fn;
00039 return edgeDyn;
00040 }
00041
00042
00043 ne_err_code_t ne_dyn_ode_e_none_fn (int eid, int i, int j, void *sys, double t, const double *y,
00044 double *dydt, double *params)
00045 {
00046 return NE_SUCCESS;
00047 }
00048
00049
00050 ne_dyn_edge_t * ne_dyn_ode_e_diffuse_alloc (void)
00051 {
00052 ne_dyn_edge_t *edgeDyn;
00053
00054 if ((edgeDyn = (ne_dyn_edge_t *)malloc(sizeof(ne_dyn_edge_t))) == NULL) {
00055 ne_error("ne_dyn_ode_e_diffuse_alloc: Could not allocate memory.");
00056 return NULL;
00057 }
00058
00059
00060 edgeDyn->name = "ODE_E_DIFFUSE";
00061 edgeDyn->states = 0;
00062 edgeDyn->fn = &ne_dyn_ode_e_diffuse_fn;
00063 return edgeDyn;
00064 }
00065
00066
00067 ne_err_code_t ne_dyn_ode_e_diffuse_fn (int eid, int i, int j, void *sys, double t, const double *y,
00068 double *dydt, double *params)
00069 {
00070 int s, states;
00071 ne_bool_t directed;
00072 states = ne_sys_node_states((ne_sys_t *)sys);
00073 directed = ne_sys_directed(sys);
00074
00075
00076 for (s=0; s<states; s++) {
00077 dydt[(i*states)+s] += params[0] * (y[(j*states)+s] - y[(i*states)+s]);
00078 }
00079
00080 return NE_SUCCESS;
00081 }