Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

dyn_ev.C

Go to the documentation of this file.
00001 
00002 // dyn_ev.C
00003 // member functions for the dyn class that are related to orbit integration.
00004 //
00005 
00006 #include "dyn.h"
00007 
00008 local void  accumulate_acceleration(dyn * bj,    // n-body system pointer
00009                                     dyn * bi,    // the particle to calculate
00010                                                  // force on
00011                                     real eps_squared)  // softening length
00012                                                        //squared
00013 {
00014     if(bj->get_oldest_daughter() != NULL){
00015         for(dyn * bb = bj->get_oldest_daughter(); bb != NULL;
00016             bb = bb->get_younger_sister()){
00017             accumulate_acceleration(bb, bi, eps_squared);
00018         }
00019     }else{
00020         if(bi != bj){
00021             vector d_pos = bi->get_pos() - bj->get_pos();
00022             real soft_d_pos_squared = d_pos * d_pos + eps_squared;
00023             real inverse_d_pos_cubed =
00024             1 / ( soft_d_pos_squared * sqrt( soft_d_pos_squared ));      
00025             
00026             bi->inc_acc(-inverse_d_pos_cubed * bj->get_mass() * d_pos);
00027         }
00028     }
00029 }
00030 
00031 void dyn::calculate_acceleration(dyn * b,
00032                                  real eps_squared)  // softening length squared
00033 {
00034 
00035     if (get_oldest_daughter() != NULL) {
00036         for_all_daughters(dyn, b, bb) 
00037             bb->calculate_acceleration(b, eps_squared);
00038     } else {
00039         clear_acc();
00040         accumulate_acceleration(b, this, eps_squared);
00041     }
00042 }

Generated at Sun Feb 24 09:56:59 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001