1
subroutine smd_vel_init_system()
10
character*32 sp_vel,sp_atom
11
character*32 tag,pname
14
pname = "smd_vel_init_system"
19
write(*,*) "in "//pname
22
call smd_system_get_component(sp_atom,tag,result)
25
> pname//'no component '//tag,0,0)
29
call smd_system_get_component(sp_vel,tag,result)
32
> pname//'no component '//tag,0,0)
34
call smd_vel_init(sp_vel)
39
subroutine smd_vel_init(sp_vel)
43
#include "mafdecls.fh"
52
character*255 filename
55
pname = "smd_vel_init"
57
c write(*,*) "in "//pname
59
c get total number of atoms
60
c -------------------------
61
call smd_atom_ntot(na)
64
> pname//'no atoms ',0, RTDB_ERR)
66
c create vel data structures
67
c ---------------------------
68
call smd_namespace_create(sp_vel)
69
call smd_data_create(sp_vel,"vel",3*na,MT_DBL)
71
call smd_velocfile_input(filename,result)
72
c call smd_rtdb_get_veloc_input(filename,result)
73
if((.not.result).or.(filename.eq."random")) then
74
call smd_vel_random_guess()
76
call smd_vel_read(filename)
82
subroutine smd_vel_random_guess()
86
#include "mafdecls.fh"
96
double precision targetke,ke
98
pname = "smd_type_init"
100
write(*,*) "in "//pname
106
call smd_get_ind_dim(tag,i_v,na,result)
109
> pname//'error getting index for'//tag,0, 0)
116
call smd_get_ind(tag,i_m,result)
119
> pname//'error getting index for'//tag,0, 0)
124
call smd_get_ind(tag,i_it,result)
127
> pname//'error getting index for'//tag,0, 0)
129
call smd_temper_get_ke_target(targetke)
130
if(targetke.eq.0.0d0)
131
> call smd_temper_ke_compute(298.15,targetke)
132
call smd_vel_random0(na,
138
call smd_vel_ke_compute(ke)
139
c write(*,*) "current ke compared",targetke,ke
143
subroutine smd_vel_write(filename)
145
#include "errquit.fh"
147
#include "mafdecls.fh"
150
character*(*) filename
154
character*72 sp_param
162
double precision targetke,ke
164
pname = "smd_type_init"
166
c write(*,*) "in "//pname
168
if(.not.util_get_io_unit(un))
169
> call errquit("cannot get file number",0,0)
171
open(unit=un,status="old",form="formatted",file=filename)
176
call smd_get_ind_dim(sp_vel,tag,i_v,na,result)
179
> pname//'error getting index for'//tag,0, 0)
182
call smd_vel_write0(un,
190
subroutine smd_vel_read(filename)
192
#include "errquit.fh"
194
#include "mafdecls.fh"
197
character*(*) filename
201
character*72 sp_param
210
pname = "smd_vel_read"
212
c write(*,*) "in "//pname
214
if(.not.util_get_io_unit(un))
215
> call errquit("cannot get file number",0,0)
217
open(unit=un,status="old",form="formatted",file=filename)
219
call smd_get_ind_dim("vel",i_v,na,result)
222
> pname//'error getting index for'//tag,0, 0)
224
call smd_vel_read0(un,
232
subroutine smd_vel_ke_compute(targetke)
234
#include "errquit.fh"
236
#include "mafdecls.fh"
246
double precision targetke
248
pname = "smd_type_init"
250
c write(*,*) "in "//pname
257
call smd_get_ind_dim(tag,i_v,na,result)
260
> pname//'error getting index for'//tag,0, 0)
267
call smd_get_ind(tag,i_m,result)
270
> pname//'error getting index for'//tag,0, 0)
275
call smd_get_ind(tag,i_it,result)
278
> pname//'error getting index for'//tag,0, 0)
286
call smd_energy_set_component("kinetic",targetke)
287
write(*,*) "current ke 1",targetke
291
SUBROUTINE smd_vel_random0(natms,targetke,vvv,typmass,atmtype)
296
double precision targetke
297
double precision vvv(natms,3)
298
double precision typmass(*)
304
double precision commass,comxvv,comyvv,comzvv
305
double precision instanke,xscale
316
call tool_randm(iseed,x)
317
vvv(i,1)=(x-0.5)/sqrt(typmass(iatm))
318
call tool_randm(iseed,x)
319
vvv(i,2)=(x-0.5)/sqrt(typmass(iatm))
320
call tool_randm(iseed,x)
321
vvv(i,3)=(x-0.5)/sqrt(typmass(iatm))
323
comxvv=comxvv+vvv(i,1)*typmass(iatm)
324
comyvv=comyvv+vvv(i,2)*typmass(iatm)
325
comzvv=comzvv+vvv(i,3)*typmass(iatm)
326
commass=commass+typmass(iatm)
330
comxvv=comxvv/commass
331
comyvv=comyvv/commass
332
comzvv=comzvv/commass
336
vvv(i,1)=vvv(i,1)-comxvv
337
vvv(i,2)=vvv(i,2)-comyvv
338
vvv(i,3)=vvv(i,3)-comzvv
348
$ +typmass(iatm)*((vvv(i,1)**2+vvv(i,2)**2+vvv(i,3)**2))
352
instanke=0.5*instanke
354
xscale=sqrt(targetke/instanke)
358
vvv(i,1)=xscale*vvv(i,1)
359
vvv(i,2)=xscale*vvv(i,2)
360
vvv(i,3)=xscale*vvv(i,3)
370
$ +typmass(iatm)*((vvv(i,1)**2+vvv(i,2)**2+vvv(i,3)**2))
374
instanke=0.5*instanke
376
c write(*,*) "current ke comp1",targetke,instanke
382
SUBROUTINE smd_vel_read0(un,natms,vvv)
387
double precision vvv(natms,3)
393
read(un,*) vvv(i,1),vvv(i,2),vvv(i,3)
401
SUBROUTINE smd_vel_write0(un,natms,vvv)
406
double precision vvv(natms,3)
412
write(un,*) vvv(i,1),vvv(i,2),vvv(i,3)
420
SUBROUTINE smd_vel_ke0(natms,ke,vvv,typmass,atmtype)
425
double precision targetke
426
double precision vvv(natms,3)
427
double precision typmass(*)
440
$ +typmass(iatm)*((vvv(i,1)**2+vvv(i,2)**2+vvv(i,3)**2))
446
write(*,*) "kinetic energy",ke
451
subroutine smd_velocfile_input(filename,result)
454
#include "smd_rtdb_data.fh"
455
#include "mafdecls.fh"
459
character*(*) filename
464
pname = "smd_velocfile_input"
467
call smd_rtdb_get_string("smd:veloc:input",1,