16 procedure:: courant_time
18 real(8),
save:: courant=0.5
25 SUBROUTINE init (self, name)
27 character(len=*),
optional:: name
28 logical,
save:: first_time=.true.
29 namelist /kdk_params/ courant
31 call self%particle_list_t%init
37 read (io_unit%input, kdk_params)
38 write (io_unit%output, kdk_params)
47 SUBROUTINE update (self, p)
53 new = 1 + mod(p%it,self%nt)
54 associate(v=>p%v(:,new), r=>p%r(:,new))
55 dt = self%courant_time (p)
56 a = self%force(p)/p%mass
59 a = self%force(p)/p%mass
66 p%iit(1:nt-1) = p%iit(2:nt)
76 FUNCTION courant_time (self, p)
RESULT (dt)
78 class(particle_t),
pointer:: p
81 real(8):: a(3), ac, vc, dt1, dt2
84 new = 1 + mod(p%it,self%nt)
87 associate(v=>p%v(:,i1))
88 a = (p%v(:,i1)-p%v(:,i0))/(p%t(i1)-p%t(i0))
89 ac = 1.0/sqrt(sum(a**2)+tiny(1.0_8))
90 vc = 1.0/sqrt(sum(v**2)+tiny(1.0_8))
94 a = self%force(p)/p%mass
95 ac = 1.0/sqrt(sum(a**2)+tiny(1.0_8))
96 dt2 = p%ds*ac/vc*courant
100 END FUNCTION courant_time
Particle data type, extends a dll_node data type, so it can become part of a particle_list_t data typ...
Doubly linked list (DLL), carrying anything, as simply as possible.
Kick-Drift-Kick (KDK) N-body solver.
Particle list, extending a doubly-linked list. Each particle maintains arrays with previous positions...