• Main Page
  • Data Structures
  • Files
  • File List
  • Globals

ne_dyn_edge_ode_lib.c

00001 /*===========================================================================
00002  NetEvo Foundation Library
00003  Copyright (C) 2009, 2010 Thomas E. Gorochowski <tgorochowski@me.com>
00004  Bristol Centre for Complexity Sciences, University of Bristol, Bristol, UK
00005  ---------------------------------------------------------------------------- 
00006  NetEvo is a computing framework designed to allow researchers to investigate 
00007  evolutionary aspects of dynamical complex networks. By providing tools to 
00008  easily integrate each of these factors in a coherent way, it is hoped a 
00009  greater understanding can be gained of key attributes and features displayed 
00010  by complex systems.
00011  
00012  NetEvo is open-source software released under the Open Source Initiative 
00013  (OSI) approved Non-Profit Open Software License ("Non-Profit OSL") 3.0. 
00014  Detailed information about this licence can be found in the COPYING file 
00015  included as part of the source distribution.
00016  
00017  This library is distributed in the hope that it will be useful, but
00018  WITHOUT ANY WARRANTY; without even the implied warranty of
00019  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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    /* Define the dynamics structure */
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    /* Define the dynamics structure */
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    /* Find the node states and couple on them all */
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 }

Generated on Thu Aug 26 2010 11:04:24 for NetEvo by  doxygen 1.7.1