-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparticlesplitting.f90
73 lines (62 loc) · 1.62 KB
/
particlesplitting.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
!!------------------------------------------------------------------------!!
!! Particle splitting module (VERY EXPERIMENTAL)
!!------------------------------------------------------------------------!!
module particlesplit
implicit none
contains
subroutine particle_splitting(nsplit)
use dimen_mhd
use debug
use loguns
use options, only:rhocrit
use part, only:npart,ntotal,rho,pmass
implicit none
integer, intent(out) :: nsplit
integer :: npartnew,i
real, parameter :: pmassinit = 1./5000.
!
!--allow for tracing flow
!
!
!--initialise quantities
!
npartnew = npart
do i=1,npart
if (rho(i).gt.rhocrit .and. pmass(i).ge.pmassinit) then
print*,'splitting ',i,'rho, rhocrit = ',rho(i),rhocrit
call splitpart(i,npartnew)
endif
enddo
npart = npartnew
ntotal = npart
nsplit = npartnew - npart
return
end subroutine particle_splitting
subroutine splitpart(i,npartnew)
use part
use mem_allocation, only:alloc
use random, only:ran1
implicit none
integer, intent(in) :: i
integer, intent(inout) :: npartnew
integer :: j,npartold
integer, parameter :: nmake = 5
real :: pmassnew
integer :: iseed = -123
save iseed
npartold = npartnew
npartnew = npartold + nmake
!print*,'iseed = ',iseed
pmassnew = pmass(i)/real(nmake)
!--create new particle(s)
if (npartnew.gt.size(x(1,:))) call alloc(npart+100*nmake)
do j=npartold+1,npartnew
call copy_particle(j,i)
x(:,j) = x(:,i)*(1. + 0.001*hh(i)*(ran1(iseed)-0.5))
!print*,j,' xnew = ',x(:,j),' xold = ',x(:,j)
vel(:,j) = vel(:,i)
pmass(j) = pmassnew
enddo
pmass(i) = pmassnew
end subroutine splitpart
end module particlesplit