21INTEGER (KIND=c_int) FUNCTION add_cells (NP, NPS, sizec) bind (C,NAME='add_cells_')
27INTEGER (KIND=c_int),
INTENT(IN) :: np, nps
28INTEGER (KIND=c_int),
INTENT(IN),
DIMENSION(3) :: sizec
29INTEGER :: pia, pib, pic, pid, pie, pif
30DOUBLE PRECISION,
DIMENSION(3) :: lshift
31INTEGER,
DIMENSION(:),
ALLOCATABLE :: newlot
32DOUBLE PRECISION,
DIMENSION(:,:,:),
ALLOCATABLE :: newpos
35 INTEGER FUNCTION send_pos(NPA, NPS, NLOT, POSTAB)
36 INTEGER,
INTENT(IN) :: npa, nps
37 INTEGER,
DIMENSION(:),
INTENT(IN) :: nlot
38 DOUBLE PRECISION,
DIMENSION(:,:,:),
INTENT(IN) :: postab
42pia = (sizec(1)+1)*(sizec(2)+1)*(sizec(3)+1)
45if (
allocated(newpos))
deallocate(newpos)
46allocate(newpos(pib,3,nps), stat=
err)
48 call show_error (
"Impossible to allocate memory"//char(0), &
49 "Function: add_cells"//char(0),
"Table: NEWPOS"//char(0))
53if (
allocated(newlot))
deallocate(newlot)
54allocate(newlot(pib), stat=
err)
56 call show_error (
"Impossible to allocate memory"//char(0), &
57 "Function: add_cells"//char(0),
"Table: NEWLOT"//char(0))
67 lshift(1)=(pid-1)*
the_box(1)%lvect(1,1) + (pie-1)*
the_box(1)%lvect(2,1) + (pif-1)*
the_box(1)%lvect(3,1)
68 lshift(2)=(pid-1)*
the_box(1)%lvect(1,2) + (pie-1)*
the_box(1)%lvect(2,2) + (pif-1)*
the_box(1)%lvect(3,2)
69 lshift(3)=(pid-1)*
the_box(1)%lvect(1,3) + (pie-1)*
the_box(1)%lvect(2,3) + (pif-1)*
the_box(1)%lvect(3,3)
72 newpos(pib,:,pia) =
fullpos(pic,:,pia) + lshift(:)
73 newlot(pib) =
lot(pic)
81call init_data (pib,
nsp, nps, 0)
85if (
allocated(newpos))
deallocate(newpos)
86if (
allocated(newlot))
deallocate(newlot)
90INTEGER (KIND=c_int) FUNCTION shift_box_center (NP, NPS, cshift, REF) bind (C,NAME='shift_box_center_')
96INTEGER (KIND=c_int),
INTENT(IN) :: np, nps, ref
97real(kind=c_double),
INTENT(IN),
DIMENSION(3) :: cshift
98INTEGER :: pib, pic, pid
99DOUBLE PRECISION,
DIMENSION(3,3) :: h_mat
100DOUBLE PRECISION,
DIMENSION(3) :: tpo
103 INTEGER FUNCTION send_pos(NPA, NPS, NLOT, POSTAB)
104 INTEGER,
INTENT(IN) :: npa, nps
105 INTEGER,
DIMENSION(:),
INTENT(IN) :: nlot
106 DOUBLE PRECISION,
DIMENSION(:,:,:),
INTENT(IN) :: postab
110h_mat(:,1) =
the_box(1)%lvect(1,:)
111h_mat(:,2) =
the_box(1)%lvect(2,:)
112h_mat(:,3) =
the_box(1)%lvect(3,:)
120 tpo=tpo-nint(tpo/0.5)
121 fullpos(pib,:,pic) = matmul(h_mat,tpo)
138DOUBLE PRECISION,
DIMENSION(3),
INTENT(IN) :: a, b
150DOUBLE PRECISION,
DIMENSION(3),
INTENT(IN) :: a, b
151DOUBLE PRECISION,
DIMENSION(3),
INTENT(INOUT) :: c
155c(1) = a(2)*b(3) - a(3)*b(2)
156c(2) = a(3)*b(1) - a(1)*b(3)
157c(3) = a(1)*b(2) - a(2)*b(1)
161INTEGER (KIND=c_int) FUNCTION lattice (totl, lid, vectors, vmod, angles, lat, cfrac, apbc) bind (C,NAME='lattice_')
174real(kind=c_double),
INTENT(IN),
DIMENSION(3,3) :: vectors
175real(kind=c_double),
INTENT(IN),
DIMENSION(3) :: vmod
176real(kind=c_double),
INTENT(INOUT),
DIMENSION(3) :: angles
177INTEGER (KIND=c_int),
INTENT(IN) :: totl, lid, lat, cfrac, apbc
179DOUBLE PRECISION :: alpha, beta, gama
180DOUBLE PRECISION :: calpha, salpha, cbeta, sbeta, cgama, sgama
181DOUBLE PRECISION,
DIMENSION(3) :: tmpla
185 DOUBLE PRECISION,
DIMENSION(3),
INTENT(IN) :: a, b
188 DOUBLE PRECISION,
DIMENSION(3),
INTENT(IN) :: a, b
189 DOUBLE PRECISION,
DIMENSION(3),
INTENT(INOUT) :: c
200 call show_error (
"Impossible to allocate memory"//char(0), &
201 "Function: lattice_"//char(0),
"Type: THE_BOX"//char(0))
220 nbox%modv(1) = vmod(1)
221 nbox%modv(2) = vmod(2)
222 nbox%modv(3) = vmod(3)
229 if (alpha.eq.90.0 .and. beta.eq.90.0 .and. gama.eq.90.0)
then
234 if (alpha.eq.90.0)
then
239 alpha = alpha*
pi/180.0d0
243 if (beta.eq.90.0)
then
248 beta = beta*
pi/180.0d0
252 if (gama.eq.90.0)
then
257 gama = gama*
pi/180.0d0
263 nbox%lvect(1,2) = 0.0d0
264 nbox%lvect(1,3) = 0.0d0
265 nbox%lvect(2,1) =
nbox%modv(2)*cgama
266 nbox%lvect(2,2) =
nbox%modv(2)*sgama
267 nbox%lvect(2,3) = 0.d0
268 nbox%lvect(3,1) =
nbox%modv(3)*cbeta
269 ltemp = (calpha - cbeta*cgama)/sgama
279 alpha= (
nbox%lvect(3,1)*
nbox%lvect(2,1)+ &
282 beta = (
nbox%lvect(1,1)*
nbox%lvect(3,1)+ &
285 gama = (
nbox%lvect(1,1)*
nbox%lvect(2,1)+ &
289 if (alpha.eq.0.0d0 .and. beta.eq.0.0d0 .and. gama.eq.0.0d0)
then
294 if (alpha.eq.0.0d0)
then
301 angles(1) = alpha*180.0d0/
pi
305 if (beta.eq.0.0d0)
then
312 angles(2) = beta*180.0d0/
pi
316 if (gama.eq.0.0d0)
then
323 angles(3) = gama*180.0d0/
pi
330 if (alpha.eq.0.0d0 .and. beta.eq.0.0d0 .and. gama.eq.0.0d0)
then
332 call show_error (
"Problem with the simulation box parameters"//char(0), &
333 "Computed angles are equal to 0.0d0"//char(0),
"Function: lattice"//char(0))
377 z=sqrt(abs(1 - calpha*calpha &
380 + 2*calpha*cbeta*cgama))
383 if (cfrac > 0)
i = cfrac - 1
385 nbox%fractocart(1,1)=
nbox%modv(1)/(2.0**(
i))
386 nbox%fractocart(1,2)=0.0d0
387 nbox%fractocart(1,3)=0.0d0
388 nbox%fractocart(2,1)=
nbox%modv(2)*cgama/(2.0**(
i))
389 nbox%fractocart(2,2)=
nbox%modv(2)*sgama/(2.0**(
i))
390 nbox%fractocart(2,3)=0.0d0
391 nbox%fractocart(3,1)=
nbox%modv(3)*cbeta/(2.0**(
i))
392 nbox%fractocart(3,2)=
nbox%modv(3)*((calpha-cbeta*cgama)/sgama)/(2.0**(
i))
393 nbox%fractocart(3,3)=
nbox%modv(3)*
z/(2.0**(
i))
403 nbox%carttofrac(1,1)=1.0d0/
nbox%fractocart(1,1)
404 nbox%carttofrac(1,2)=0.0d0
405 nbox%carttofrac(1,3)=0.0d0
406 nbox%carttofrac(2,1)=-cgama/(sgama*(
nbox%modv(1)/(2.0**(
i))))
407 nbox%carttofrac(2,2)=1.0d0/
nbox%fractocart(2,2)
408 nbox%carttofrac(2,3)=0.0d0
409 nbox%carttofrac(3,1)=((
nbox%modv(2)/(2.0**(
i)))*(
nbox%modv(3)/(2.0**(
i))))/
nbox%VOLUME
410 nbox%carttofrac(3,1)=
nbox%carttofrac(3,1) * (calpha*cgama - cbeta)/salpha
411 nbox%carttofrac(3,2)=((
nbox%modv(1)/(2.0**(
i)))*(
nbox%modv(3)/(2.0**(
i))))/
nbox%VOLUME
412 nbox%carttofrac(3,2)=
nbox%carttofrac(3,2) * (cbeta*cgama - calpha)/sgama
413 nbox%carttofrac(3,3)=1.0d0/
nbox%fractocart(3,3)
415 if (apbc .eq. 1)
then
429 nbox%lvect(:,:)=0.0d0
430 nbox%lrecp(:,:)=0.0d0
431 nbox%fractocart(:,:)=0.0d0
440if (
nbox%VOLUME.ne.0.0)
then
455if (lid .eq. totl-1)
then
void show_error(char *error, int val, GtkWidget *win)
show error message
integer(kind=c_int) function lattice(totl, lid, vectors, vmod, angles, lat, cfrac, apbc)
integer(kind=c_int) function shift_box_center(np, nps, cshift, ref)
double precision function f_dot_product(a, b)
integer(kind=c_int) function add_cells(np, nps, sizec)
subroutine f_cross_product(a, b, c)
double precision, dimension(:,:,:), allocatable fullpos
double precision total_density
double precision, parameter avogadro
double precision, dimension(:), allocatable mass
double precision real_density
integer, dimension(:), allocatable nbspbs
type(lattice), pointer nbox
type(lattice), dimension(:), allocatable, target the_box
integer, dimension(:), allocatable lot
double precision, parameter pi
integer function send_pos(npa, nps, nlot, postab)