Time integration

 

Example: we want to integrate du_p/dt = \lambda u_p on the particles using the 4th order Runge-Kutta of the ODE suite. We'll assume that we have np particles with positions xp and values up already allocated and initialized.

Local variables:

REAL(mk), DIMENSION(:,:),  POINTER :: dup     ! du/dt on particles
REAL(mk), DIMENSION(:,:),  POINTER :: bfr     ! storage space for the stages
REAL(mk), DIMENSION(4)             :: time    ! time things
INTEGER                            :: istage  ! stage counter
INTEGER                            :: nstages ! number of stages
INTEGER                            :: bfrsz   ! size of the buffer "bfr"
INTEGER                            :: scheme  ! which scheme to use
INTEGER                            :: odeid   ! handle on the solver
LOGICAL                            :: adapt   ! use adaptive time step
INTEGER                            :: lda     ! leading dimension of our mode
INTEGER, EXTERNAL                  :: MyRHS   ! your implementation of the RHS

 

Initialize the ODE suite:

!-------------------------------------------------------------
!  Initialize the Ode solver
!-------------------------------------------------------------
CALL ppm_ode_init (info)

 

Create Mode:

scheme = PPM_PARAM_ODE_SCHEME_RK4  ! we want the 4th order RK scheme
odeid  = -1 ! let the PPM choose an ID for us
adapt  = .FALSE.! don't need adaptive time stepping
lda    = 2
!-------------------------------------------------------------
!  Create the mode
!-------------------------------------------------------------
CALL ppm_ode_create_ode(odeid, bfrsz, nstages, scheme, scheme, adapt, info)

 

Allocate space for the stages:

ALLOCATE(bfr(bfrsz*lda,np))

 

Set the time:

dt      = 0.1
time(1) = 0.0  ! set the start time
time(2) = 1.0  ! set the end time
time(3) = 0.0  ! set the current time
time(4) = dt   ! set the time step size

 

Start the ODE solver:

CALL ppm_ode_start(info)

 

Start the time integration:

DO WHILE(.NOT.ppm_ode_alldone(info))
 
DO istage=1,nstages
 
CALL ppm_ode_step(odeid, xp, up, dup, lda, np, &
&            bfr, istage, time, MyRHS, info=info)
 
!-- say particles move, then we need to map after each stage
maptype = ppm_param_map_partial
CALL ppm_map_part(xp,3,np,mpart,topo_id,maptype,info)
maptype = ppm_param_map_push
CALL ppm_map_part(up,lda,np,mpart,topo_id,maptype,info)
CALL ppm_map_part(dup,lda,np,mpart,topo_id,maptype,info)
!-- now have the ode suite map the stages
CALL ppm_ode_map_push(odeid,bfr,lda,np,mpart,info)
!-- send
maptype = ppm_param_map_send
CALL ppm_map_part(dup,lda,np,mpart,topo_id,maptype,info)
!-- pop in the reverse order
CALL ppm_ode_map_pop(odeid,bfr,lda,np,mpart,info)
maptype = ppm_param_map_pop
CALL ppm_map_part(dup,lda,np,mpart,topo_id,maptype,info)
CALL ppm_map_part(up,lda,np,mpart,topo_id,maptype,info)
CALL ppm_map_part(xp,3,np,mpart,topo_id,maptype,info)
 
END DO
 
END DO
 
CALL ppm_ode_finalize(info)

 

A possible implementation for the right-hand side function:

FUNCTION MyRHS(vxp, vup, vdup, vdime, vnp, rpack, ipack, lpack, info)
USE myGlobalData
 
!-- Arguments
INTEGER, INTENT(in)               :: vdime, vnp
REAL(mk),DIMENSION(:,:),POINTER     :: vxp, vup, vdup
REAL(MK),DIMENSION(:,:), POINTER,OPTIONAL  :: rpack
INTEGER, DIMENSION(:,:), POINTER,OPTIONAL  :: ipack
LOGICAL, DIMENSION(:,:), POINTER,OPTIONAL  :: lpack
INTEGER, INTENT(inout)            :: info
 
INTEGER :: MyRHS
 
!-- Local variables
INTEGER :: p
 
!-- Compute the right-hand side
!   assuming the parameter REAL(mk), DIMENSION(2) :: lambda
!   is specified in the module myGlobalData
DO p=1,vnp
dup(1,p) = -lambda(1) * up(1,p)
dup(2,p) = -lambda(2) * up(2,p)
END DO
 
!-- bogus return value
MyRHS = 123456
RETURN
END FUNCTION MyRHS

 

 

Profile Information

Application afterLoad: 0.000 seconds, 0.28 MB
Application afterInitialise: 0.011 seconds, 0.93 MB
Application afterRoute: 0.014 seconds, 1.23 MB
Application afterDispatch: 0.024 seconds, 1.87 MB
Application afterRender: 0.033 seconds, 2.04 MB

Memory Usage

2167640

12 queries logged

  1. SELECT *
      FROM jos_session
      WHERE session_id = 'ckuurluplkt3b4475uapmlmku4'
  2. DELETE
      FROM jos_session
      WHERE ( time < '1638033683' )
  3. SELECT *
      FROM jos_session
      WHERE session_id = 'ckuurluplkt3b4475uapmlmku4'
  4. INSERT INTO `jos_session` ( `session_id`,`time`,`username`,`gid`,`guest`,`client_id` )
      VALUES ( 'ckuurluplkt3b4475uapmlmku4','1638034583','','0','1','0' )
  5. SELECT *
      FROM jos_components
      WHERE parent = 0
  6. SELECT folder AS type, element AS name, params
      FROM jos_plugins
      WHERE published >= 1
      AND access <= 0
      ORDER BY ordering
  7. SELECT m.*, c.`option` AS component
      FROM jos_menu AS m
      LEFT JOIN jos_components AS c
      ON m.componentid = c.id
      WHERE m.published = 1
      ORDER BY m.sublevel, m.parent, m.ordering
  8. SELECT template
      FROM jos_templates_menu
      WHERE client_id = 0
      AND (menuid = 0 OR menuid = 65)
      ORDER BY menuid DESC
      LIMIT 0, 1
  9. SELECT a.*, u.name AS author, u.usertype, cc.title AS category, s.title AS section, CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END AS slug, CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END AS catslug, g.name AS groups, s.published AS sec_pub, cc.published AS cat_pub, s.access AS sec_access, cc.access AS cat_access 
      FROM jos_content AS a
      LEFT JOIN jos_categories AS cc
      ON cc.id = a.catid
      LEFT JOIN jos_sections AS s
      ON s.id = cc.section
      AND s.scope = "content"
      LEFT JOIN jos_users AS u
      ON u.id = a.created_by
      LEFT JOIN jos_groups AS g
      ON a.access = g.id
      WHERE a.id = 55
      AND (  ( a.created_by = 0 )    OR  ( a.state = 1
      AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '2021-11-27 17:36:23' )
      AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '2021-11-27 17:36:23' )   )    OR  ( a.state = -1 )  )
  10. UPDATE jos_content
      SET hits = ( hits + 1 )
      WHERE id='55'
  11. SELECT id, title, module, position, content, showtitle, control, params
      FROM jos_modules AS m
      LEFT JOIN jos_modules_menu AS mm
      ON mm.moduleid = m.id
      WHERE m.published = 1
      AND m.access <= 0
      AND m.client_id = 0
      AND ( mm.menuid = 65 OR mm.menuid = 0 )
      ORDER BY position, ordering
  12. SELECT a.*, CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END AS slug, CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END AS catslug
      FROM jos_content AS a
      INNER JOIN jos_categories AS cc
      ON cc.id = a.catid
      INNER JOIN jos_sections AS s
      ON s.id = a.sectionid
      WHERE a.state = 1 
      AND a.access <= 0
      AND cc.access <= 0
      AND s.access <= 0
      AND (a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '2021-11-27 17:36:23' ) 
      AND (a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '2021-11-27 17:36:23' )
      AND cc.id = 1
      AND cc.section = s.id
      AND cc.published = 1
      AND s.published = 1
      ORDER BY a.ordering
      LIMIT 0, 4

Language Files Loaded

Untranslated Strings Diagnostic

None

Untranslated Strings Designer

None