-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_brush.f90
668 lines (597 loc) · 29.5 KB
/
gen_brush.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
subroutine gen_brush(mode)
use commons ;use util
use ziggurat, only: rnor,uni
implicit none
integer, intent(in) :: mode
integer :: err_ov, i_ov, j_chain,ini_chain,i_col,i_row, n_col,n_row!, j_part!Add by Kevo to avoid overlap between grafting points
real :: dis_ov_2, min_dis_2, a_br,a_br_2!sigma(1,1)**2 !Add by Kevo to avoid overlap between grafting points
real (kind=8) :: fi=0., alpha_ini=.52 !0.78
!a_br = lattice parameter for brush grafting points
min_dis_2 = sigma(1,1)**2 ! Sets overlap radius
!--- Specify position of first monomer in chain
#include "control_simulation.h"
select case (mode)
case(1) ! ------ Brush in top and bottom walls: CHANNEL
! NOTE: This works with brushes only. Free polymers must be generated in another
! context
do i_chain = 1,n_chain !loop over all the chains
i_part = 1 + (i_chain-1)*n_mon
call r250(mz,random,n_part,n_dim,kptr)
do i_dim = 1,n_dim
if(i_dim.eq.n_dim) then ! z coor of polymer head
if(i_chain.le.n_chain/2) then !top wall
r0(i_dim,i_part) = z_space_wall-z_head !ori2.**(1./6.)
end if
if(i_chain.gt.n_chain/2) then !bottom wall
r0(i_dim,i_part) = z_head !ori2.**(1./6.)
end if
end if
if(i_dim.ne.n_dim) then ! x y coordinates of heads: at random in the plane
r0(i_dim,i_part) = random(i_dim)*boundary(i_dim)
end if
end do
!---- generate random walk for next monomers on chain
do i_mon = 1,n_mon-1
i_part = i_part + 1
500 continue
call r250(mz,random,n_part,n_dim,kptr)
do i_dim = 1,n_dim
if(i_dim.lt.n_dim) then ! for x and y coordinates, random
r0(i_dim,i_part) = r0(i_dim,i_part-1) + (2*random(i_dim)-1.)*r_chain/sqrt3
! PBC in the plane
if(r0(i_dim,i_part).ge.boundary(i_dim)) then
r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
else if(r0(i_dim,i_part).le.0.) then
r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
end if
end if !end if x or y
if(i_dim.eq.n_dim) then ! if z coor
if(i_chain.le.n_chain/2) then ! top wall
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) - 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) - 0.5
# endif
end if ! end z_coor
if(i_chain.gt.n_chain/2) then !bottom wall
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.5
# endif
!OBSOLETE if(solv_flag.eq.0) then
!OBSOLETE r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
!OBSOLETE else
!OBSOLETE r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.4
!OBSOLETE end if
end if
end if !end z coor
! end if !ad_flag
!! if(ad_flag.eq.0) then !if adsorbed
!! r0(i_dim,i_part) = r0(i_dim,i_part-1) + &
!! & (2*random(i_dim)-1.)*r_chain/sqrt3
!! if(r0(i_dim,i_part).gt.boundary(i_dim)) then
!! r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
!! else if(r0(i_dim,i_part).lt.0) then
!! r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
!! end if
!! end if !end adsorbed
end do
i_dummy = 0
! check whether new z coordinates is allright
if((r0(n_dim,i_part).le.0.).or.(r0(n_dim,i_part).ge.boundary(n_dim))) i_dummy = 1
if(i_dummy.eq.1) then
write(*,*) " New setup attempt for monomer (z-pos)", i_part,r0(n_dim,i_part)
goto 500
end if
end do
end do ! ends loop over chains
!debug call write_conf(1,r0(:,1:n_chain*n_mon),10) ; stop
case(2) ! ------ Brush ONLY in bottom wall: DROPLET
do i_chain = 1,n_chain !loop over all the chains
i_part = 1 + (i_chain-1)*n_mon
call r250(mz,random,n_part,n_dim,kptr)
do i_dim = 1,n_dim
if(i_dim.eq.n_dim) then ! z coor of polymer head
!
! DROPLET: only the bottom wall is populated
!
r0(i_dim,i_part) = z_head !ori2.**(1./6.)
end if
if(i_dim.ne.n_dim) then ! x y coordinates of heads: at random in the plane
r0(i_dim,i_part) = random(i_dim)*boundary(i_dim)
end if
end do
!---- generate random walk for next monomers on chain
do i_mon = 1,n_mon-1
i_part = i_part + 1
501 continue
call r250(mz,random,n_part,n_dim,kptr)
do i_dim = 1,n_dim
if(i_dim.lt.n_dim) then ! for x and y coordinates, random
r0(i_dim,i_part) = r0(i_dim,i_part-1) + (2*random(i_dim)-1.)*r_chain/sqrt3
! PBC in the plane
if(r0(i_dim,i_part).ge.boundary(i_dim)) then
r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
else if(r0(i_dim,i_part).le.0.) then
r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
end if
end if !emd if x or y
if(i_dim.eq.n_dim) then ! if z coor
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.5
# endif
end if
!not in drop end if !end z coor
! end if
!!obs if(ad_flag.eq.0) then !if adsorbed
!!obs r0(i_dim,i_part) = r0(i_dim,i_part-1) + (2*random(i_dim)-1.)*r_chain/sqrt3
!!obs if(r0(i_dim,i_part).gt.boundary(i_dim)) then
!!obs r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
!!obs else if(r0(i_dim,i_part).lt.0) then
!!obs r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
!!obs end if
!!obs end if !end adsorbed
end do
i_dummy = 0
! check whether new z coordinates is allright
if((r0(n_dim,i_part).le.0.).or.(r0(n_dim,i_part).ge.boundary(n_dim))) i_dummy = 1
if(i_dummy.eq.1) then
write(*,*) "new setup attempt for monomer (z-pos)", i_part,r0(n_dim,i_part)
goto 501
end if
end do
end do ! ends loop over chains
case(3) ! ------ Brush in top and bottom walls: CHANNEL
! NOTE: This works with brushes only. Free polymers must be generated in another
! context
!1987
do i_chain = 1,n_chain !loop over all the chains
i_part = 1 + (i_chain-1)*n_mon
call r250(mz,random,n_part,n_dim,kptr)
err_ov=1 !Add by Kevo to avoid overlap between grafting points
i_ov=0
do while(err_ov.gt.0) !Add by Kevo to avoid overlap between grafting points
err_ov = 0 !Add by Kevo to avoid overlap between grafting points
i_ov = i_ov + 1 !Add by Kevo to avoid overlap between grafting points
do i_dim = 1,n_dim
if(i_dim.eq.n_dim) then ! z coor of polymer head
if(i_chain.le.n_chain/2) then !top wall
r0(i_dim,i_part) = z_space_wall-z_head !ori2.**(1./6.)
ini_chain=1
end if
if(i_chain.gt.n_chain/2) then !bottom wall
r0(i_dim,i_part) = z_head !ori2.**(1./6.)
ini_chain = n_chain/2 + 1
end if
end if
if(i_dim.ne.n_dim) then ! x y coordinates of heads: at random in the plane
r0(i_dim,i_part) = uni()*boundary(i_dim)
end if
end do
! CHECK OVERLAP !Add by Kevo to avoid overlap between grafting
! points. CHECK ONLY OVERLAP IN SAME WALL!!!!!!
if(i_ov.ge.5000000) then
print*, "WARNING: PROGRAM STOPPED!"
print*, "Error: failed to introduce grafting point number ", i_chain, " after ", i_ov, " attempts"
stop
!go to 1987
end if
do j_chain = ini_chain,i_chain !loop over all the chains
j_part = 1 + (j_chain-1)*n_mon
dis_ov_2=(r0(1,i_part)-r0(1,j_part))**2+(r0(2,i_part)-r0(2,j_part))**2
if(dis_ov_2.le.min_dis_2.and.i_part.ne.j_part) then
!print*, "Overlap between grafting points detected"
err_ov = err_ov + 1
exit
end if
end do !END CHECK OVERLAP !Add by Kevo to avoid overlap between grafting points
end do !Add by Kevo to avoid overlap between grafting points
!---- generate random walk for next monomers on chain
do i_mon = 1,n_mon-1
i_part = i_part + 1
!500 continue ! OLD AND OBSOLETE
call r250(mz,random,n_part,n_dim,kptr)
do i_dim = 1,n_dim
if(i_dim.lt.n_dim) then ! for x and y coordinates, random
r0(i_dim,i_part) = r0(i_dim,i_part-1) + (2*random(i_dim)-1.)*r_chain/sqrt3
! PBC in the plane
if(r0(i_dim,i_part).ge.boundary(i_dim)) then
r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
else if(r0(i_dim,i_part).le.0.) then
r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
end if
end if !end if x or y
if(i_dim.eq.n_dim) then ! if z coor
if(i_chain.le.n_chain/2) then ! top wall
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) - 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) - 0.4
# endif
end if ! end z_coor
if(i_chain.gt.n_chain/2) then !bottom wall
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.4
# endif
!OBSOLETE if(solv_flag.eq.0) then
!OBSOLETE r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
!OBSOLETE else
!OBSOLETE r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.4
!OBSOLETE end if
end if
end if !end z coor
! end if !ad_flag
!! if(ad_flag.eq.0) then !if adsorbed
!! r0(i_dim,i_part) = r0(i_dim,i_part-1) + &
!! & (2*random(i_dim)-1.)*r_chain/sqrt3
!! if(r0(i_dim,i_part).gt.boundary(i_dim)) then
!! r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
!! else if(r0(i_dim,i_part).lt.0) then
!! r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
!! end if
!! end if !end adsorbed
end do
i_dummy = 0
! check whether new z coordinates is allright
if((r0(n_dim,i_part).le.0.).or.(r0(n_dim,i_part).ge.boundary(n_dim))) i_dummy = 1
if(i_dummy.eq.1) then
write(*,*) " New setup attempt for monomer (z-pos)", i_part,r0(n_dim,i_part)
! goto 500
end if
end do
end do ! ends loop over chains
case(4) ! ------ Brush ONLY in bottom wall: DROPLET
!1984
do i_chain = 1,n_chain !loop over all the chains
i_part = 1 + (i_chain-1)*n_mon
call r250(mz,random,n_part,n_dim,kptr)
err_ov=1
i_ov=0
do while(err_ov.gt.0)
err_ov = 0
i_ov = i_ov + 1
do i_dim = 1,n_dim
if(i_dim.eq.n_dim) then ! z coor of polymer head
!
! DROPLET: only the bottom wall is populated
!
r0(i_dim,i_part) = z_head !ori2.**(1./6.)
end if
if(i_dim.ne.n_dim) then ! x y coordinates of heads: at random in the plane
r0(i_dim,i_part) = uni()*boundary(i_dim)
end if
end do
! CHECK OVERLAP !Add by Kevo to avoid overlap between grafting
! points. CHECK ONLY OVERLAP IN SAME WALL!!!!!!
if(i_ov.ge.5000000) then
print*, "WARNING: PROGRAM STOPPED!"
print*, "Error: failed to introduce grafting point number ", i_chain, " after ", i_ov, " attempts"
stop
!go to 1984
end if
do j_chain = ini_chain,i_chain !loop over all the chains
j_part = 1 + (j_chain-1)*n_mon
dis_ov_2=(r0(1,i_part)-r0(1,j_part))**2+(r0(2,i_part)-r0(2,j_part))**2
if(dis_ov_2.le.min_dis_2.and.i_part.ne.j_part) then
!print*, "Overlap between grafting points detected"
err_ov = err_ov + 1
exit
end if
end do !END CHECK OVERLAP !Add by Kevo to avoid overlap between grafting points
end do !Add by Kevo to avoid overlap between grafting points
!---- generate random walk for next monomers on chain
do i_mon = 1,n_mon-1
i_part = i_part + 1
504 continue
call r250(mz,random,n_part,n_dim,kptr)
do i_dim = 1,n_dim
if(i_dim.lt.n_dim) then ! for x and y coordinates, random
r0(i_dim,i_part) = r0(i_dim,i_part-1) +(2*uni()-1.)*r_chain/sqrt3
!(2*random(i_dim)-1.)*r_chain/sqrt3
! PBC in the plane
if(r0(i_dim,i_part).ge.boundary(i_dim)) then
r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
else if(r0(i_dim,i_part).le.0.) then
r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
end if
end if !emd if x or y
if(i_dim.eq.n_dim) then ! if z coor
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.5
# endif
end if
end do
i_dummy = 0
! check whether new z coordinates is allright
if((r0(n_dim,i_part).le.0.).or.(r0(n_dim,i_part).ge.boundary(n_dim))) i_dummy = 1
if(i_dummy.eq.1) then
write(*,*) "new setup attempt for monomer (z-pos)", i_part,r0(n_dim,i_part)
goto 504
end if
end do
end do ! ends loop over chains
case(5) ! ------ Ordered Brush in bottom and top wall
!print*, "entro" !DEBUG
a_br = sqrt( 2 * boundary(1) * boundary(2) / n_chain ) !lattice parameter
a_br_2 = a_br / 2
!Check parameter compatibility for ordered brush
n_col = nint(boundary(1)/a_br)
if(mod(boundary(1),a_br).ne.0.) then
print*, "boundary(1), should be a multiple of the lattice parameter a_br"
print*, "boundary(1) = ",boundary(1),"a_br = ",a_br
print*,"boundary(1)/a_br = ", boundary(1)/a_br
end if
n_row = nint(boundary(2)/a_br)
if(mod(boundary(2),a_br).ne.0.) then
print*, "boundary(2), should be a multiple of the lattice parameter a_br"
print*, "boundary(2) = ",boundary(2),"a_br = ",a_br
print*,"boundary(2)/a_br = ", boundary(2)/a_br
end if
if(n_chain.ne.2*n_col*n_row) then
print*,"ERROR: n_chain should be equal to 2*n_col*n_row"
print*,"n_chain: ",n_chain
print*,"2*n_col*n_row= ","2*",n_col,"*",n_row," = ", 2*n_col*n_row
stop
end if
!Set head positions
do j_chain = 0, 1 !0 is top wall. 1 is for bottom wall
i_part = j_chain * n_mon * n_chain / 2 ! starting particle to set it's location
do i_col = 0, n_col-1 !loop for columns
do i_row = 0, n_row-1 !loop for rows
i_part = i_part + 1
r0(1,i_part) = a_br_2 + a_br*i_col !set head ubication of top grafting point
r0(2,i_part) = a_br_2 + a_br*i_row
if(i_part.le.n_mon*n_chain/2) then
r0(3,i_part) = z_space_wall-z_head
else if(i_part.gt.n_mon*n_chain/2) then
r0(3,i_part) = z_head
end if
! print*,i_part,r0(:,i_part) ! DEBUG
!Set the remaining monomers in chain
do i_mon=2,n_mon
i_part = i_part + 1
do i_dim=1,3
if(i_dim.lt.n_dim) then !x and y
r0(i_dim,i_part) = r0(i_dim,i_part-1) +(2*uni()-1.)*r_chain/sqrt3 !bottom
! PBC in the plane
if(r0(i_dim,i_part).ge.boundary(i_dim)) then
r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
else if(r0(i_dim,i_part).le.0.) then
r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
end if
!print*,"i_dim",i_dim,"n_dim",n_dim !DEBUG
else if(i_dim.eq.n_dim) then !z
!print*,"i_dim = ",n_dim ! DEBUG
if(i_part.le.n_mon*n_chain/2) then ! top wall
!print*,"TOP WALL" !DEBUG
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) - 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) - 0.5
# endif
else if (i_part.gt.n_mon*n_chain/2) then !bottom wall
!print*, "BOTTOM WALL" !DEBUG
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.5
# endif
end if ! end top or bottom
end if ! end x,y or z
end do ! end i_dim
! print*,i_part,r0(:,i_part) !DEBUG
end do ! end rest of the chain
end do !end i_row
end do ! end i_col
end do ! end j_chain bottom or top wall
!print*,"salio" !DEBUG
case(6) ! ------ Ordered Brush ONLY in bottom wall: DROPLET
a_br = sqrt( boundary(1)*boundary(2)/n_chain ) !lattice parameter
a_br_2 = a_br / 2
!Check parameter compatibility for ordered brush
if(mod(boundary(1),a_br).eq.0.) then
n_col = int(boundary(1)/a_br)
else
print*, "ERROR: number of chains incorrect. Stopping programm"
print*, "boundary(1), should be a multiple of the lattice parameter a_br"
print*, "boundary(1) = ",boundary(1),"a_br = ",a_br
print*,"boundary(1)/a_br = ", boundary(1)/a_br
stop
end if
if(mod(boundary(2),a_br).eq.0.) then
n_row = int(boundary(2)/a_br)
else
print*, "ERROR: number of chains incorrect. Stopping programm"
print*, "boundary(2), should be a multiple of the lattice parameter a_br"
print*, "boundary(2) = ",boundary(2),"a_br = ",a_br
print*,"boundary(2)/a_br = ", boundary(2)/a_br
stop
end if
q_part=1! grafted particle
do i_col = 0, n_col-1 !loop for columns
do i_row = 0, n_row-1 !loop for rows
i_part = q_part ! i_part reference to build the rest of the chain
r0(1,i_part) = a_br_2 + a_br*i_col !set head ubication
r0(2,i_part) = a_br_2 + a_br*i_row
q_part = q_part + n_mon !next head
r0(3,i_part) = z_head
do i_mon = 1,n_mon-1
i_part = i_part + 1
509 continue
call r250(mz,random,n_part,n_dim,kptr)
do i_dim = 1,n_dim
if(i_dim.lt.n_dim) then ! for x and y coordinates, random
r0(i_dim,i_part) = r0(i_dim,i_part-1) + (2*random(i_dim)-1.)*r_chain/sqrt3
! PBC in the plane
if(r0(i_dim,i_part).ge.boundary(i_dim)) then
r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
else if(r0(i_dim,i_part).le.0.) then
r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
end if
end if !emd if x or y
if(i_dim.eq.n_dim) then ! if z coor
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.5
# endif
end if
end do
i_dummy = 0
! check whether new z coordinates is allright
if((r0(n_dim,i_part).le.0.).or.(r0(n_dim,i_part).ge.boundary(n_dim))) i_dummy = 1
if(i_dummy.eq.1) then
write(*,*) "new setup attempt for monomer (z-pos)", i_part,r0(n_dim,i_part)
goto 509
end if
end do
end do
end do
case(7) ! ------ Ordered Brush in bottom and top wall, starting with initial orientation
! defined by 'alpha_ini' (angle between two consecutive beads and the top/bot wall) and
! 'fi' (angle between the projection of two consecutive beads over top/bot wall and the x axis)
!print*, "entro" !DEBUG
a_br = sqrt( 2 * boundary(1) * boundary(2) / n_chain ) !lattice parameter
a_br_2 = a_br / 2
!Check parameter compatibility for ordered brush
n_col = nint(boundary(1)/a_br)
if(mod(boundary(1),a_br).ne.0.) then
print*, "boundary(1), should be a multiple of the lattice parameter a_br"
print*, "boundary(1) = ",boundary(1),"a_br = ",a_br
print*,"boundary(1)/a_br = ", boundary(1)/a_br
end if
n_row = nint(boundary(2)/a_br)
if(mod(boundary(2),a_br).ne.0.) then
print*, "boundary(2), should be a multiple of the lattice parameter a_br"
print*, "boundary(2) = ",boundary(2),"a_br = ",a_br
print*,"boundary(2)/a_br = ", boundary(2)/a_br
end if
if(n_chain.ne.2*n_col*n_row) then
print*,"ERROR: n_chain should be equal to 2*n_col*n_row"
print*,"n_chain: ",n_chain
print*,"2*n_col*n_row= ","2*",n_col,"*",n_row," = ", 2*n_col*n_row
stop
end if
!Set head positions
do j_chain = 0, 1 !0 is top wall. 1 is for bottom wall
i_part = j_chain * n_mon * n_chain / 2 ! starting particle to set it's location
do i_col = 0, n_col-1 !loop for columns
do i_row = 0, n_row-1 !loop for rows
i_part = i_part + 1
r0(1,i_part) = a_br_2 + a_br*i_col !set head ubication of top grafting point
r0(2,i_part) = a_br_2 + a_br*i_row
if(i_part.le.n_mon*n_chain/2) then
r0(3,i_part) = z_space_wall-z_head
else if(i_part.gt.n_mon*n_chain/2) then
r0(3,i_part) = z_head
end if
! print*,i_part,r0(:,i_part) ! DEBUG
!Set the remaining monomers in chain
do i_mon=2,n_mon
i_part = i_part + 1
do i_dim=1,3
if(i_dim.lt.n_dim) then !x and y
if(i_dim.eq.1) then ! x
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.96*COS(fi)*COS(alpha_ini) !bottom
else ! y
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.96*SIN(fi)*COS(alpha_ini) !bottom
end if
! PBC in the plane
if(r0(i_dim,i_part).ge.boundary(i_dim)) then
r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
else if(r0(i_dim,i_part).le.0.) then
r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
end if
!print*,"i_dim",i_dim,"n_dim",n_dim !DEBUG
else if(i_dim.eq.n_dim) then !z
!print*,"i_dim = ",n_dim ! DEBUG
if(i_part.le.n_mon*n_chain/2) then ! top wall
!print*,"TOP WALL" !DEBUG
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) - 0.96*SIN(alpha_ini)
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) - 0.96*SIN(alpha_ini)
# endif
else if (i_part.gt.n_mon*n_chain/2) then !bottom wall
!print*, "BOTTOM WALL" !DEBUG
# if SOLVENT == 1 || SOLVENT == 2
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.96*SIN(alpha_ini)
# elif SOLVENT == 0 || SOLVENT == 3
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.96*SIN(alpha_ini)
# endif
end if ! end top or bottom
end if ! end x,y or z
end do ! end i_dim
! print*,i_part,r0(:,i_part) !DEBUG
end do ! end rest of the chain
end do !end i_row
end do ! end i_col
end do ! end j_chain bottom or top wall
case(8) ! ------ Ordered Brush ONLY in bottom wall: DROPLET
a_br = sqrt( boundary(1)*boundary(2)/n_chain ) !lattice parameter
a_br_2 = a_br / 2
!Check parameter compatibility for ordered brush
if(mod(boundary(1),a_br).eq.0.) then
n_col = int(boundary(1)/a_br)
else
print*, "ERROR: number of chains incorrect. Stopping programm"
print*, "boundary(1), should be a multiple of the lattice parameter a_br"
print*, "boundary(1) = ",boundary(1),"a_br = ",a_br
print*,"boundary(1)/a_br = ", boundary(1)/a_br
stop
end if
if(mod(boundary(2),a_br).eq.0.) then
n_row = int(boundary(2)/a_br)
else
print*, "ERROR: number of chains incorrect. Stopping programm"
print*, "boundary(2), should be a multiple of the lattice parameter a_br"
print*, "boundary(2) = ",boundary(2),"a_br = ",a_br
print*,"boundary(2)/a_br = ", boundary(2)/a_br
stop
end if
q_part=1! grafted particle
do i_col = 0, n_col-1 !loop for columns
do i_row = 0, n_row-1 !loop for rows
i_part = q_part ! i_part reference to build the rest of the chain
r0(1,i_part) = a_br_2 + a_br*i_col !set head ubication
r0(2,i_part) = a_br_2 + a_br*i_row
q_part = q_part + n_mon !next head
r0(3,i_part) = z_head
do i_mon = 1,n_mon-1
i_part = i_part + 1
do i_dim = 1,n_dim
if(i_dim.eq.1) then ! for x and y coordinates, random
!r0(i_dim,i_part) = r0(i_dim,i_part-1) + (2*random(i_dim)-1.)*r_chain/sqrt3
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.96*COS(fi)*COS(alpha_ini) !bottomi
else
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.96*SIN(fi)*COS(alpha_ini) !bottomi
! PBC in the plane
if(r0(i_dim,i_part).ge.boundary(i_dim)) then
r0(i_dim,i_part) = r0(i_dim,i_part) - boundary(i_dim)
else if(r0(i_dim,i_part).le.0.) then
r0(i_dim,i_part) = r0(i_dim,i_part) + boundary(i_dim)
end if
end if !emd if x or y
if(i_dim.eq.n_dim) then ! if z coor
# if SOLVENT == 1 || SOLVENT == 2
! r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.2
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.96*SIN(alpha_ini)
# elif SOLVENT == 0 || SOLVENT == 3
! r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.5
r0(i_dim,i_part) = r0(i_dim,i_part-1) + 0.96*SIN(alpha_ini)
# endif
end if
end do
end do
end do
end do
!print*,"salio" !DEBUG
end select
end subroutine gen_brush