程序代码如下: module global
implicit none
integer dim
parameter ( dim = 1)
integer maxn,max_interaction
parameter(maxn=12000,
& max_interaction = 100 * maxn)
double precision x_maxgeom,x_mingeom,y_maxgeom,y_mingeom,
& z_maxgeom , z_mingeom
parameter ( x_maxgeom = 10.e0,
& x_mingeom = -10.e0,
& y_maxgeom =10.e0 ,
& y_mingeom = -10.e0,
& z_maxgeom = 10.e0 ,
& z_mingeom = -10.e0 )
integer pa_sph
parameter(pa_sph = 2)
integer nnps
parameter(nnps = 1 )
integer sle
parameter(sle = 0)
integer skf
parameter(skf = 1)
logical summation_density, average_velocity, config_input,
& virtual_part, vp_input, visc, ex_force, heat_artificial,
& visc_artificial, self_gravity, nor_density
parameter ( summation_density = .true. )
parameter ( average_velocity = .false. )
parameter ( config_input = .false. )
parameter ( virtual_part = .false. )
parameter ( vp_input = .false. )
parameter ( visc = .false. )
parameter ( ex_force = .false.)
parameter ( visc_artificial = .true. )
parameter ( heat_artificial = .false. )
parameter ( self_gravity = .false. )
parameter ( nor_density = .false. )
integer nsym
parameter ( nsym = 0)
logical int_stat
parameter ( int_stat = .true. )
integer print_step, save_step, moni_particle
parameter ( print_step = 100 ,
& save_step = 500,
& moni_particle = 1600 )
double precision pi
parameter ( pi = 3.14159265358979323846 )
logical shocktube, shearcavity
parameter ( shocktube = .true. )
parameter ( shearcavity = .false. )
end module
program SPH
use global
implicit none
integer ntotal, itype(maxn), maxtimestep, d, m, i, yesorno
double precision x(3,maxn), vx(3, maxn), mass(maxn),rho(maxn),
& p(maxn), u(maxn), c(maxn), s(maxn), e(maxn), hsml(maxn), dt
double precision s1, s2
if (shocktube) dt = 0.005
call input(x, vx, mass, rho, p, u, itype, hsml, ntotal)
end
subroutine input(x, vx, mass, rho, p, u, itype, hsml, ntotal)
c----------------------------------------------------------------------
c Subroutine for loading or generating initial particle information
c x-- coordinates of particles [out]
c vx-- velocities of particles [out]
c mass-- mass of particles [out]
c rho-- dnesities of particles [out]
c p-- pressure of particles [out]
c u-- internal energy of particles [out]
c itype-- types of particles [out]
c hsml-- smoothing lengths of particles [out]
c ntotal-- total particle number [out]
use global
implicit none
integer itype(maxn), ntotal
double precision x(3, maxn), vx(3, maxn), mass(maxn),
& p(maxn), u(maxn), hsml(maxn), rho(maxn)
integer i, d
open(1,file="data\ini_xv.txt"
& )
open(2,file="data\ini_state.txt"
& )
open(3,file="data\ini_other.txt"
& )
if (shocktube) call shock_tube(x, vx, mass, rho, p, u,
& itype, hsml, ntotal)
if (shearcavity) call shear_cavity(x, vx, mass, rho, p, u,
& itype, hsml, ntotal)
do i = 1, ntotal
write(1,1001) i, (x(d, i),d = 1, dim), (vx(d, i),d = 1, dim)
write(2,1002) i, mass(i), rho(i), p(i), u(i)
write(3,1003) i, itype(i), hsml(i)
enddo
1001 format(1x, I5, 6(2x, e15.8))
1002 format(1x, I5, 7(2x, e15.8))
1003 format(1x, I5, 2x, I2, 2x, e15.8)
write(*,*)' **************************************************'
write(*,*)' Initial particle configuration generated '
write(*,*)' Total number of particles ', ntotal
write(*,*)' **************************************************'
close(1)
close(2)
close(3)
end
subroutine shock_tube(x, vx, mass, rho, p, u,
& itype, hsml, ntotal)
use global
implicit none
integer itype(maxn), ntotal
double precision x(3, maxn), vx(3, maxn), mass(maxn),
& rho(maxn), p(maxn), u(maxn), hsml(maxn)
integer i, d
double precision space_x
ntotal=400
space_x=0.6/80.
do i=1,ntotal
mass(i)=0.75/400.
hsml(i)=0.015
itype(i)=1
do d = 1, dim
x(d,i) = 0.
vx(d,i) = 0.
enddo
enddo
do i=1,320
x(1,i)=-0.6+space_x/4.*(i-1)
enddo
do i=320+1,ntotal
x(1,i)=0.+space_x*(i-320)
enddo
do i=1,ntotal
if (x(1,i).le.1.e-8) then
u(i)=2.5
rho(i)=1.
p(i)=1.
endif
if (x(1,i).gt.1.e-8) then
u(i)=1.795
rho(i)=0.25
p(i)=0.1795
endif
enddo
end
调试时出点的断点为绿色箭头所指执行结果是第二张图
![调试时在打开一个新文件时总是说出现断点]()
%HY(GB(USLL{6`1TCKEX7XP.jpg
![调试时在打开一个新文件时总是说出现断点-1]()
HSHX56(]K[0P_}%WX8[GRGE.jpg |