crystalcell 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +1 -0
- data/VERSION +1 -1
- data/crystalcell.gemspec +81 -0
- data/lib/crystalcell/atom.rb +118 -118
- data/lib/crystalcell/cell.rb +584 -584
- data/lib/crystalcell/element.rb +135 -135
- data/lib/crystalcell/latticeaxes.rb +194 -188
- data/lib/crystalcell/periodiccell.rb +244 -244
- data/test/test_atom.rb +198 -198
- data/test/test_cell.rb +1450 -1478
- data/test/test_element.rb +642 -642
- data/test/test_latticeaxes.rb +283 -278
- data/test/test_periodiccell.rb +948 -948
- metadata +4 -3
data/test/test_periodiccell.rb
CHANGED
|
@@ -5,7 +5,7 @@ require "helper"
|
|
|
5
5
|
require 'stringio'
|
|
6
6
|
|
|
7
7
|
class CrystalCell::PeriodicCell
|
|
8
|
-
|
|
8
|
+
public :reset_positions_inside
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
#pp Mageo.methods
|
|
@@ -14,956 +14,956 @@ end
|
|
|
14
14
|
#exit
|
|
15
15
|
|
|
16
16
|
class TC_PeriodicCell < Test::Unit::TestCase
|
|
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
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
17
|
+
#extend Mageo
|
|
18
|
+
#require "mageo"
|
|
19
|
+
$tolerance = 10 ** (-10)
|
|
20
|
+
|
|
21
|
+
V_000 = Mageo::Vector3DInternal[0.0, 0.0, 0.0]
|
|
22
|
+
V_666 = Mageo::Vector3DInternal[0.6, 0.6, 0.6]
|
|
23
|
+
V_111 = Mageo::Vector3DInternal[0.1, 0.1, 0.1]
|
|
24
|
+
V_119 = Mageo::Vector3DInternal[0.1, 0.1, 0.9]
|
|
25
|
+
V_191 = Mageo::Vector3DInternal[0.1, 0.9, 0.1]
|
|
26
|
+
V_199 = Mageo::Vector3DInternal[0.1, 0.9, 0.9]
|
|
27
|
+
V_911 = Mageo::Vector3DInternal[0.9, 0.1, 0.1]
|
|
28
|
+
V_919 = Mageo::Vector3DInternal[0.9, 0.1, 0.9]
|
|
29
|
+
V_991 = Mageo::Vector3DInternal[0.9, 0.9, 0.1]
|
|
30
|
+
V_999 = Mageo::Vector3DInternal[0.9, 0.9, 0.9]
|
|
31
|
+
|
|
32
|
+
def setup
|
|
33
|
+
#原子のないセル。
|
|
34
|
+
vectors00 = [ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ]
|
|
35
|
+
@c00 = CrystalCell::PeriodicCell.new(vectors00)
|
|
36
|
+
@c00.comment = 'c00'
|
|
37
|
+
|
|
38
|
+
#元素の識別子を数字にしたもの。
|
|
39
|
+
atoms = [
|
|
40
|
+
CrystalCell::Atom.new(0, [0.0, 0.0, 0.0]),
|
|
41
|
+
CrystalCell::Atom.new(1, [0.1, 0.2, 0.3]),
|
|
42
|
+
]
|
|
43
|
+
@c01 = CrystalCell::PeriodicCell.new(vectors00, atoms)
|
|
44
|
+
@c01.comment = 'c01'
|
|
45
|
+
|
|
46
|
+
#Li と O を1つずつ入れたセル。
|
|
47
|
+
atoms = [
|
|
48
|
+
CrystalCell::Atom.new('Li', [0.0, 0.0, 0.0]),
|
|
49
|
+
CrystalCell::Atom.new('O' , [0.2, 0.2, 0.2]),
|
|
50
|
+
]
|
|
51
|
+
@c02 = CrystalCell::PeriodicCell.new(vectors00, atoms)
|
|
52
|
+
@c02.comment = 'c02'
|
|
53
|
+
|
|
54
|
+
#原子を追加する順序を逆にしたもの。
|
|
55
|
+
atoms = [
|
|
56
|
+
CrystalCell::Atom.new('O' , [0.2, 0.2, 0.2]),
|
|
57
|
+
CrystalCell::Atom.new('Li', [0.0, 0.0, 0.0]),
|
|
58
|
+
]
|
|
59
|
+
@c03 = CrystalCell::PeriodicCell.new(vectors00, atoms)
|
|
60
|
+
@c03.comment = 'c03'
|
|
61
|
+
|
|
62
|
+
#原子を add したもの。
|
|
63
|
+
atoms = [
|
|
64
|
+
CrystalCell::Atom.new('Li', [0.0, 0.0, 0.0]),
|
|
65
|
+
CrystalCell::Atom.new('O' , [0.2, 0.2, 0.2]),
|
|
66
|
+
CrystalCell::Atom.new('Li', [0.1, 0.2, 0.3]),
|
|
67
|
+
]
|
|
68
|
+
@c04 = CrystalCell::PeriodicCell.new(vectors00, atoms)
|
|
69
|
+
@c04.comment = 'c04'
|
|
70
|
+
|
|
71
|
+
#原子を remove したもの。
|
|
72
|
+
atoms = [
|
|
73
|
+
CrystalCell::Atom.new('Li', [0.0, 0.0, 0.0])
|
|
74
|
+
]
|
|
75
|
+
@c05 = CrystalCell::PeriodicCell.new(vectors00, atoms)
|
|
76
|
+
@c05.comment = 'c05'
|
|
77
|
+
|
|
78
|
+
#Selective dynamics をいれたもの。
|
|
79
|
+
atoms = [
|
|
80
|
+
CrystalCell::Atom.new('Li', [0.0, 0.0, 0.0], nil, [true, false, false ]),
|
|
81
|
+
CrystalCell::Atom.new('O' , [0.2, 0.2, 0.2]),
|
|
82
|
+
]
|
|
83
|
+
@c06 = CrystalCell::PeriodicCell.new(vectors00, atoms)
|
|
84
|
+
@c06.comment = 'c06'
|
|
85
|
+
|
|
86
|
+
#元素の識別子を数字にしたもの。
|
|
87
|
+
atoms = [
|
|
88
|
+
CrystalCell::Atom.new(0, [0.0, 0.0, 0.0]),
|
|
89
|
+
CrystalCell::Atom.new(1, [0.2, 0.2, 0.2]),
|
|
90
|
+
]
|
|
91
|
+
@c07 = CrystalCell::PeriodicCell.new(vectors00, atoms)
|
|
92
|
+
@c07.comment = 'c01'
|
|
93
|
+
|
|
94
|
+
# セル外の座標の原子を追加。
|
|
95
|
+
atoms = [
|
|
96
|
+
CrystalCell::Atom.new('Li', [ 1.2, 3.4, 5.6], "atom0", [ false, false, true]),
|
|
97
|
+
CrystalCell::Atom.new('O', [-1.2, -3.4, -5.6]),
|
|
98
|
+
]
|
|
99
|
+
@c08 = CrystalCell::PeriodicCell.new(vectors00, atoms)
|
|
100
|
+
@c08.comment = 'c08'
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_directions_within_distance
|
|
104
|
+
#A点 (0.1, 0.1, 0.1)_internal
|
|
105
|
+
#cartesian で、
|
|
106
|
+
# 0.1(2, 2, 2)
|
|
107
|
+
#+ 0.1(0, 2, 2)
|
|
108
|
+
#+ 0.1(0, 0, 2)
|
|
109
|
+
#==============
|
|
110
|
+
# 0.1(2, 4, 6) = (0.2, 0.4, 0.6)_cartesian
|
|
111
|
+
#
|
|
112
|
+
#B点 (0.1, 0.1, 0.1)_internal
|
|
113
|
+
#cartesian で、
|
|
114
|
+
# 0.9(2, 2, 2)
|
|
115
|
+
#+ 0.9(0, 2, 2)
|
|
116
|
+
#+ 0.9(0, 0, 2)
|
|
117
|
+
#==============
|
|
118
|
+
# 0.9(2, 4, 6) = (1.8, 3.6, 5.4)_cartesian
|
|
119
|
+
#詳細は test/directions_within_distance.rb を参照。
|
|
120
|
+
#p distance([ (1.8 - 2.0), (3.6 - 4.0), (5.4 - 4.0) ], A) #[-1,-1, 0] 1.2
|
|
121
|
+
#p distance([ (1.8 - 2.0), (3.6 - 2.0), (5.4 - 4.0) ], A) #[-1, 0,-1] 1.49666295470958
|
|
122
|
+
#p distance([ (1.8 - 2.0), (3.6 - 4.0), (5.4 - 6.0) ], A) #[-1,-1,-1] 1.49666295470958
|
|
123
|
+
#p distance([ (1.8 - 0.0), (3.6 - 2.0), (5.4 - 4.0) ], A) #[ 0,-1,-1] 2.1540659228538
|
|
124
|
+
#p distance([ (1.8 - 2.0), (3.6 - 4.0), (5.4 - 2.0) ], A) #[-1,-1,+1] 2.93938769133981
|
|
125
|
+
#p distance([ (1.8 - 2.0), (3.6 - 2.0), (5.4 - 2.0) ], A) #[-1, 0, 0] 3.07245829914744
|
|
126
|
+
#p distance([ (1.8 - 0.0), (3.6 - 2.0), (5.4 - 2.0) ], A) #[ 0,-1, 0] 3.44093010681705
|
|
127
|
+
#p distance([ (1.8 - 2.0), (3.6 - 0.0), (5.4 - 2.0) ], A) #[-1,+1,-1] 4.27083130081252
|
|
128
|
+
#p distance([ (1.8 - 0.0), (3.6 - 0.0), (5.4 - 2.0) ], A) #[ 0, 0,-1] 4.54312667664022
|
|
129
|
+
#p distance([ (1.8 - 2.0), (3.6 - 2.0), (5.4 - 0.0) ], A) #[-1, 0,+1] 4.96386945839634
|
|
130
|
+
#p distance([ (1.8 - 0.0), (3.6 - 2.0), (5.4 + 0.0) ], A) #[ 0,-1,+1] 5.2
|
|
131
|
+
#p distance([ (1.8 + 2.0), (3.6 + 0.0), (5.4 - 2.0) ], A) #[+1,-1,-1] 5.57135531087365
|
|
132
|
+
#p distance([ (1.8 - 2.0), (3.6 - 0.0), (5.4 - 0.0) ], A) #[-1,+1, 0] 5.78273291792039
|
|
133
|
+
#p distance([ (1.8 - 0.0), (3.6 - 0.0), (5.4 + 0.0) ], A) #[ 0, 0, 0] 5.98665181883831
|
|
134
|
+
#p distance([ (1.8 + 2.0), (3.6 + 0.0), (5.4 + 0.0) ], A) #[+1,-1, 0] 6.8
|
|
135
|
+
#p distance([ (1.8 - 0.0), (3.6 + 2.0), (5.4 + 0.0) ], A) #[ 0,+1,-1] 7.25534285888682
|
|
136
|
+
#p distance([ (1.8 - 2.0), (3.6 - 0.0), (5.4 + 2.0) ], A) #[-1,+1,+1] 7.52595508889071
|
|
137
|
+
#p distance([ (1.8 - 0.0), (3.6 - 0.0), (5.4 + 2.0) ], A) #[ 0, 0,+1] 7.68374908491942
|
|
138
|
+
#p distance([ (1.8 + 2.0), (3.6 + 2.0), (5.4 + 0.0) ], A) #[+1, 0,-1] 7.93977329651168
|
|
139
|
+
#p distance([ (1.8 + 2.0), (3.6 + 0.0), (5.4 + 2.0) ], A) #[+1,-1,+1] 8.33306666239986
|
|
140
|
+
#p distance([ (1.8 - 0.0), (3.6 + 2.0), (5.4 + 2.0) ], A) #[ 0,+1, 0] 8.7086164228309
|
|
141
|
+
#p distance([ (1.8 + 2.0), (3.6 + 2.0), (5.4 + 2.0) ], A) #[+1, 0, 0] 9.28654941299512
|
|
142
|
+
#p distance([ (1.8 - 0.0), (3.6 + 2.0), (5.4 + 4.0) ], A) #[ 0,+1,+1] 10.3460137251021
|
|
143
|
+
#p distance([ (1.8 + 2.0), (3.6 + 4.0), (5.4 + 2.0) ], A) #[+1,+1,-1] 10.5375518978556
|
|
144
|
+
#p distance([ (1.8 + 2.0), (3.6 + 2.0), (5.4 + 4.0) ], A) #[+1, 0,+1] 10.8369737473153
|
|
145
|
+
#p distance([ (1.8 + 2.0), (3.6 + 4.0), (5.4 + 4.0) ], A) #[+1,+1, 0] 11.9264412127005
|
|
146
|
+
#p distance([ (1.8 + 2.0), (3.6 + 4.0), (5.4 + 6.0) ], A) #[+1,+1,+1] 13.4699665923862
|
|
147
|
+
|
|
148
|
+
assert_equal([], @c00.directions_within_distance(V_111, V_999, 1.19))
|
|
149
|
+
assert_equal([[-1,-1,0]], @c00.directions_within_distance(V_111, V_999, 1.21))
|
|
150
|
+
assert_equal([[-1,-1,0]], @c00.directions_within_distance(V_111, V_999, 1.49))
|
|
151
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,0,-1]], @c00.directions_within_distance(V_111, V_999, 1.50))
|
|
152
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,0,-1]], @c00.directions_within_distance(V_111, V_999, 2.15))
|
|
153
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,0,-1],[0,-1,-1]], @c00.directions_within_distance(V_111, V_999, 2.16))
|
|
154
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,0,-1],[0,-1,-1]], @c00.directions_within_distance(V_111, V_999, 2.93))
|
|
155
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,-1,+1],[-1,0,-1],[0,-1,-1]], @c00.directions_within_distance(V_111, V_999, 2.94))
|
|
156
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,-1,+1],[-1,0,-1],[0,-1,-1]], @c00.directions_within_distance(V_111, V_999, 3.07))
|
|
157
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,-1,+1],[-1,0,-1],[-1,0,0],[0,-1,-1]], @c00.directions_within_distance(V_111, V_999, 3.08))
|
|
158
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,-1,+1],[-1,0,-1],[-1,0,0],[0,-1,-1]], @c00.directions_within_distance(V_111, V_999, 3.44))
|
|
159
|
+
assert_equal([[-1,-1,-1],[-1,-1,0],[-1,-1,+1],[-1,0,-1],[-1,0,0],[0,-1,-1],[0,-1,0]], @c00.directions_within_distance(V_111, V_999, 3.45))
|
|
160
|
+
#あとは省略。
|
|
161
|
+
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def test_nearest_direction
|
|
165
|
+
assert_equal(
|
|
166
|
+
Mageo::Vector3DInternal[ 0, 0, 0],
|
|
167
|
+
@c00.nearest_direction(Mageo::Vector3DInternal[-0.9, -0.9, -0.9], V_111)
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
assert_equal(Mageo::Vector3DInternal[-1, -1, 0], @c00.nearest_direction(V_111, V_999))
|
|
171
|
+
assert_equal(Mageo::Vector3DInternal[-1, -1, 0], @c00.nearest_direction(V_119, V_999))
|
|
172
|
+
assert_equal(Mageo::Vector3DInternal[-1, 0, -1], @c00.nearest_direction(V_191, V_999))
|
|
173
|
+
assert_equal(Mageo::Vector3DInternal[-1, 0, 0], @c00.nearest_direction(V_199, V_999))
|
|
174
|
+
assert_equal(Mageo::Vector3DInternal[ 0, -1, -1], @c00.nearest_direction(V_911, V_999))
|
|
175
|
+
assert_equal(Mageo::Vector3DInternal[ 0, -1, 0], @c00.nearest_direction(V_919, V_999))
|
|
176
|
+
assert_equal(Mageo::Vector3DInternal[ 0, 0, -1], @c00.nearest_direction(V_991, V_999))
|
|
177
|
+
assert_equal(Mageo::Vector3DInternal[ 0, 0, 0], @c00.nearest_direction(V_999, V_999))
|
|
178
|
+
assert_equal(Mageo::Vector3DInternal[ 1, 1, 0], @c00.nearest_direction(V_999, V_111))
|
|
179
|
+
assert_equal(Mageo::Vector3DInternal[ 1, 1, 0], @c00.nearest_direction(V_999, V_119))
|
|
180
|
+
assert_equal(Mageo::Vector3DInternal[ 1, 0, 1], @c00.nearest_direction(V_999, V_191))
|
|
181
|
+
assert_equal(Mageo::Vector3DInternal[ 1, 0, 0], @c00.nearest_direction(V_999, V_199))
|
|
182
|
+
assert_equal(Mageo::Vector3DInternal[ 0, 1, 1], @c00.nearest_direction(V_999, V_911))
|
|
183
|
+
assert_equal(Mageo::Vector3DInternal[ 0, 1, 0], @c00.nearest_direction(V_999, V_919))
|
|
184
|
+
assert_equal(Mageo::Vector3DInternal[ 0, 0, 1], @c00.nearest_direction(V_999, V_991))
|
|
185
|
+
assert_equal(Mageo::Vector3DInternal[ 0, 0, 0], @c00.nearest_direction(V_999, V_999))
|
|
186
|
+
|
|
187
|
+
assert_equal(Mageo::Vector3DInternal[ 1, 0, 1], @c00.nearest_direction(V_666, V_000))
|
|
188
|
+
assert_equal(Mageo::Vector3DInternal[-1, 0, -1], @c00.nearest_direction(V_000, V_666))
|
|
189
|
+
|
|
190
|
+
assert_raise(CrystalCell::PeriodicCell::TypeError){
|
|
191
|
+
@c00.nearest_direction([ 0.1, 0.1, 0.1 ], [ 0.9, 0.9, 0.9 ])
|
|
192
|
+
}
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def test_nearest_distance
|
|
196
|
+
assert_in_delta(Math::sqrt(0.56), @c00.nearest_distance(V_000, Mageo::Vector3DInternal[0.1, 0.1, 0.1]), $tolerance)
|
|
197
|
+
assert_in_delta(Math::sqrt(0.88), @c00.nearest_distance(V_000, Mageo::Vector3DInternal[0.8, 0.9, 1.0]), $tolerance)
|
|
198
|
+
|
|
199
|
+
assert_raise(CrystalCell::PeriodicCell::TypeError){@c00.nearest_distance([0.0, 0.0, 0.0], [0.1, 0.1, 0.1])}
|
|
200
|
+
assert_raise(CrystalCell::PeriodicCell::TypeError){@c00.nearest_distance([0.0, 0.0, 0.0], [0.8, 0.9, 1.0])}
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def test_find_bonds
|
|
205
|
+
atoms = [
|
|
206
|
+
CrystalCell::Atom.new('Li', [ 0.1, 0.1, 0.1 ]),
|
|
207
|
+
CrystalCell::Atom.new('O', [ 0.9, 0.9, 0.9 ]),
|
|
208
|
+
]
|
|
209
|
+
pc00 = CrystalCell::PeriodicCell.new([ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ] , atoms)
|
|
210
|
+
|
|
211
|
+
assert_equal([],
|
|
212
|
+
pc00.find_bonds('Li', 'O' , 0.0, 0.00)
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
#境界を越えて見つけられる。
|
|
216
|
+
t = pc00.find_bonds('Li', 'O' , 0.0, 1.21)
|
|
217
|
+
assert_equal(2, t.size)
|
|
218
|
+
assert_in_delta(0.1, t[0][0][0], $tolerance)
|
|
219
|
+
assert_in_delta(0.1, t[0][0][1], $tolerance)
|
|
220
|
+
assert_in_delta(0.1, t[0][0][2], $tolerance)
|
|
221
|
+
assert_in_delta(-0.1, t[0][1][0], $tolerance)
|
|
222
|
+
assert_in_delta(-0.1, t[0][1][1], $tolerance)
|
|
223
|
+
assert_in_delta(0.9, t[0][1][2], $tolerance)
|
|
224
|
+
assert_in_delta(0.9, t[1][0][0], $tolerance)
|
|
225
|
+
assert_in_delta(0.9, t[1][0][1], $tolerance)
|
|
226
|
+
assert_in_delta(0.9, t[1][0][2], $tolerance)
|
|
227
|
+
assert_in_delta(1.1, t[1][1][0], $tolerance)
|
|
228
|
+
assert_in_delta(1.1, t[1][1][1], $tolerance)
|
|
229
|
+
assert_in_delta(0.1, t[1][1][2], $tolerance)
|
|
230
|
+
|
|
231
|
+
#元素の順序を変えても等価な結果が返る。
|
|
232
|
+
t = pc00.find_bonds('O' , 'Li', 0.0, 1.21)
|
|
233
|
+
assert_equal(2, t.size)
|
|
234
|
+
assert_in_delta(0.1, t[0][0][0], $tolerance)
|
|
235
|
+
assert_in_delta(0.1, t[0][0][1], $tolerance)
|
|
236
|
+
assert_in_delta(0.1, t[0][0][2], $tolerance)
|
|
237
|
+
assert_in_delta(-0.1, t[0][1][0], $tolerance)
|
|
238
|
+
assert_in_delta(-0.1, t[0][1][1], $tolerance)
|
|
239
|
+
assert_in_delta(0.9, t[0][1][2], $tolerance)
|
|
240
|
+
assert_in_delta(0.9, t[1][0][0], $tolerance)
|
|
241
|
+
assert_in_delta(0.9, t[1][0][1], $tolerance)
|
|
242
|
+
assert_in_delta(0.9, t[1][0][2], $tolerance)
|
|
243
|
+
assert_in_delta(1.1, t[1][1][0], $tolerance)
|
|
244
|
+
assert_in_delta(1.1, t[1][1][1], $tolerance)
|
|
245
|
+
assert_in_delta(0.1, t[1][1][2], $tolerance)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
pc01 = CrystalCell::PeriodicCell.new([ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ])
|
|
249
|
+
pc01.add_atom(CrystalCell::Atom.new('Li', [ 0.5, 0.5, 0.4 ]))
|
|
250
|
+
pc01.add_atom(CrystalCell::Atom.new('Li', [ 0.5, 0.5, 0.5 ]))
|
|
251
|
+
pc01.add_atom(CrystalCell::Atom.new('O', [ 0.5, 0.5, 0.6 ]))
|
|
252
|
+
pc01.add_atom(CrystalCell::Atom.new('O', [ 0.5, 0.5, 0.7 ]))
|
|
253
|
+
|
|
254
|
+
t = pc01.find_bonds('Li', 'Li' , 0.0, 0.10)
|
|
255
|
+
assert_equal([], t)
|
|
256
|
+
|
|
257
|
+
#Li-Li、元素の区別
|
|
258
|
+
t = pc01.find_bonds('Li', 'Li' , 0.0, 0.30)
|
|
259
|
+
assert_equal(
|
|
260
|
+
[ [Mageo::Vector3DInternal[0.5, 0.5, 0.4], Mageo::Vector3DInternal[0.5, 0.5, 0.5 ] ] ],
|
|
261
|
+
t
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
#O-O、元素の区別
|
|
265
|
+
t = pc01.find_bonds('O', 'O' , 0.0, 0.30)
|
|
266
|
+
assert_equal(
|
|
267
|
+
[ [ Mageo::Vector3DInternal[0.5, 0.5, 0.6], Mageo::Vector3DInternal[0.5, 0.5, 0.7]]],
|
|
268
|
+
t
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
#Li-O、元素の区別
|
|
272
|
+
t = pc01.find_bonds('Li', 'O' , 0.0, 0.30)
|
|
273
|
+
assert_equal(
|
|
274
|
+
[ [ Mageo::Vector3DInternal[0.5, 0.5, 0.5], Mageo::Vector3DInternal[0.5, 0.5, 0.6] ] ],
|
|
275
|
+
t
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
#O-Li, 逆順でも等価
|
|
279
|
+
t = pc01.find_bonds('O' , 'Li', 0.0, 0.30)
|
|
280
|
+
assert_equal(
|
|
281
|
+
[[ Mageo::Vector3DInternal[0.5, 0.5, 0.5], Mageo::Vector3DInternal[0.5, 0.5, 0.6]]],
|
|
282
|
+
t
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
#距離の下限
|
|
286
|
+
t = pc01.find_bonds('Li', 'O' , 0.5, 0.7)
|
|
287
|
+
assert_equal(
|
|
288
|
+
[ [ Mageo::Vector3DInternal[0.5, 0.5, 0.4], Mageo::Vector3DInternal[0.5, 0.5, 0.7]]],
|
|
289
|
+
t
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
#距離の上限は pc00 で。
|
|
293
|
+
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def test_pairs_within_distance
|
|
297
|
+
pc00 = CrystalCell::PeriodicCell.new([ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ])
|
|
298
|
+
pc00.add_atom(CrystalCell::Atom.new('Li', [ 0.1, 0.1, 0.1 ]))
|
|
299
|
+
pc00.add_atom(CrystalCell::Atom.new('O', [ 0.9, 0.9, 0.9 ]))
|
|
300
|
+
|
|
301
|
+
#0-1 間
|
|
302
|
+
# [-1,-1, 0] 1.2
|
|
303
|
+
# [-1, 0,-1] 1.49666295470958
|
|
304
|
+
# [-1,-1,-1] 1.49666295470958
|
|
305
|
+
# [ 0,-1,-1] 2.1540659228538
|
|
306
|
+
# [-1,-1,+1] 2.93938769133981
|
|
307
|
+
# [-1, 0, 0] 3.07245829914744
|
|
308
|
+
|
|
309
|
+
##0-0, 1-1
|
|
310
|
+
#[ 0, 0, 1] 2.0
|
|
311
|
+
#[ 0, 0,-1] 2.0
|
|
312
|
+
#[ 0,-1, 1] 2.0
|
|
313
|
+
#[ 0, 1,-1] 2.0
|
|
314
|
+
#[-1, 1, 0] 2.0
|
|
315
|
+
#[ 1,-1, 0] 2.0
|
|
316
|
+
|
|
317
|
+
assert_equal([], pc00.pairs_within_distance(0.0))
|
|
318
|
+
assert_equal([], pc00.pairs_within_distance(1.19))
|
|
319
|
+
assert_equal(
|
|
320
|
+
[ [0,1,[-1,-1, 0]], [1,0,[ 1, 1, 0]] ],
|
|
321
|
+
pc00.pairs_within_distance(1.21))
|
|
322
|
+
assert_equal(
|
|
323
|
+
[ [0,1,[-1,-1, 0]], [1,0,[ 1, 1, 0]] ],
|
|
324
|
+
pc00.pairs_within_distance(1.49))
|
|
325
|
+
assert_equal(
|
|
326
|
+
[
|
|
327
|
+
[0,1,[-1,-1,-1]],
|
|
328
|
+
[0,1,[-1,-1, 0]],
|
|
329
|
+
[0,1,[-1, 0,-1]],
|
|
330
|
+
[1,0,[ 1, 0, 1]],
|
|
331
|
+
[1,0,[ 1, 1, 0]],
|
|
332
|
+
[1,0,[ 1, 1, 1]]
|
|
333
|
+
], pc00.pairs_within_distance(1.50)
|
|
334
|
+
)
|
|
335
|
+
assert_equal(
|
|
336
|
+
[
|
|
337
|
+
[0,1,[-1,-1,-1]],
|
|
338
|
+
[0,1,[-1,-1, 0]],
|
|
339
|
+
[0,1,[-1, 0,-1]],
|
|
340
|
+
[1,0,[ 1, 0, 1]],
|
|
341
|
+
[1,0,[ 1, 1, 0]],
|
|
342
|
+
[1,0,[ 1, 1, 1]]
|
|
343
|
+
], pc00.pairs_within_distance(1.99)
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
t = pc00.pairs_within_distance(2.01)
|
|
347
|
+
assert_equal(18, t.size)
|
|
348
|
+
assert_equal([0,0,[-1, 1, 0]], t[ 0])
|
|
349
|
+
assert_equal([0,0,[ 0,-1, 1]], t[ 1])
|
|
350
|
+
assert_equal([0,0,[ 0, 0,-1]], t[ 2])
|
|
351
|
+
assert_equal([0,0,[ 0, 0, 1]], t[ 3])
|
|
352
|
+
assert_equal([0,0,[ 0, 1,-1]], t[ 4])
|
|
353
|
+
assert_equal([0,0,[ 1,-1, 0]], t[ 5])
|
|
354
|
+
assert_equal([0,1,[-1,-1,-1]], t[ 6])
|
|
355
|
+
assert_equal([0,1,[-1,-1, 0]], t[ 7])
|
|
356
|
+
assert_equal([0,1,[-1, 0,-1]], t[ 8])
|
|
357
|
+
assert_equal([1,0,[ 1, 0, 1]], t[ 9])
|
|
358
|
+
assert_equal([1,0,[ 1, 1, 0]], t[10])
|
|
359
|
+
assert_equal([1,0,[ 1, 1, 1]], t[11])
|
|
360
|
+
assert_equal([1,1,[-1, 1, 0]], t[12])
|
|
361
|
+
assert_equal([1,1,[ 0,-1, 1]], t[13])
|
|
362
|
+
assert_equal([1,1,[ 0, 0,-1]], t[14])
|
|
363
|
+
assert_equal([1,1,[ 0, 0, 1]], t[15])
|
|
364
|
+
assert_equal([1,1,[ 0, 1,-1]], t[16])
|
|
365
|
+
assert_equal([1,1,[ 1,-1, 0]], t[17])
|
|
366
|
+
|
|
367
|
+
t = pc00.pairs_within_distance(2.15)
|
|
368
|
+
assert_equal(18, t.size)
|
|
369
|
+
assert_equal([0,0,[-1, 1, 0]], t[ 0])
|
|
370
|
+
assert_equal([0,0,[ 0,-1, 1]], t[ 1])
|
|
371
|
+
assert_equal([0,0,[ 0, 0,-1]], t[ 2])
|
|
372
|
+
assert_equal([0,0,[ 0, 0, 1]], t[ 3])
|
|
373
|
+
assert_equal([0,0,[ 0, 1,-1]], t[ 4])
|
|
374
|
+
assert_equal([0,0,[ 1,-1, 0]], t[ 5])
|
|
375
|
+
assert_equal([0,1,[-1,-1,-1]], t[ 6])
|
|
376
|
+
assert_equal([0,1,[-1,-1, 0]], t[ 7])
|
|
377
|
+
assert_equal([0,1,[-1, 0,-1]], t[ 8])
|
|
378
|
+
assert_equal([1,0,[ 1, 0, 1]], t[ 9])
|
|
379
|
+
assert_equal([1,0,[ 1, 1, 0]], t[10])
|
|
380
|
+
assert_equal([1,0,[ 1, 1, 1]], t[11])
|
|
381
|
+
assert_equal([1,1,[-1, 1, 0]], t[12])
|
|
382
|
+
assert_equal([1,1,[ 0,-1, 1]], t[13])
|
|
383
|
+
assert_equal([1,1,[ 0, 0,-1]], t[14])
|
|
384
|
+
assert_equal([1,1,[ 0, 0, 1]], t[15])
|
|
385
|
+
assert_equal([1,1,[ 0, 1,-1]], t[16])
|
|
386
|
+
assert_equal([1,1,[ 1,-1, 0]], t[17])
|
|
387
|
+
|
|
388
|
+
t = pc00.pairs_within_distance(2.16)
|
|
389
|
+
assert_equal(20, t.size)
|
|
390
|
+
assert_equal([0,0,[-1, 1, 0]], t[ 0])
|
|
391
|
+
assert_equal([0,0,[ 0,-1, 1]], t[ 1])
|
|
392
|
+
assert_equal([0,0,[ 0, 0,-1]], t[ 2])
|
|
393
|
+
assert_equal([0,0,[ 0, 0, 1]], t[ 3])
|
|
394
|
+
assert_equal([0,0,[ 0, 1,-1]], t[ 4])
|
|
395
|
+
assert_equal([0,0,[ 1,-1, 0]], t[ 5])
|
|
396
|
+
assert_equal([0,1,[-1,-1,-1]], t[ 6])
|
|
397
|
+
assert_equal([0,1,[-1,-1, 0]], t[ 7])
|
|
398
|
+
assert_equal([0,1,[-1, 0,-1]], t[ 8])
|
|
399
|
+
assert_equal([0,1,[ 0,-1,-1]], t[ 9])
|
|
400
|
+
assert_equal([1,0,[ 0, 1, 1]], t[10])
|
|
401
|
+
assert_equal([1,0,[ 1, 0, 1]], t[11])
|
|
402
|
+
assert_equal([1,0,[ 1, 1, 0]], t[12])
|
|
403
|
+
assert_equal([1,0,[ 1, 1, 1]], t[13])
|
|
404
|
+
assert_equal([1,1,[-1, 1, 0]], t[14])
|
|
405
|
+
assert_equal([1,1,[ 0,-1, 1]], t[15])
|
|
406
|
+
assert_equal([1,1,[ 0, 0,-1]], t[16])
|
|
407
|
+
assert_equal([1,1,[ 0, 0, 1]], t[17])
|
|
408
|
+
assert_equal([1,1,[ 0, 1,-1]], t[18])
|
|
409
|
+
assert_equal([1,1,[ 1,-1, 0]], t[19])
|
|
410
|
+
|
|
411
|
+
t = pc00.pairs_within_distance(2.82)
|
|
412
|
+
assert_equal(20, t.size)
|
|
413
|
+
assert_equal([0,0,[-1, 1, 0]], t[ 0])
|
|
414
|
+
assert_equal([0,0,[ 0,-1, 1]], t[ 1])
|
|
415
|
+
assert_equal([0,0,[ 0, 0,-1]], t[ 2])
|
|
416
|
+
assert_equal([0,0,[ 0, 0, 1]], t[ 3])
|
|
417
|
+
assert_equal([0,0,[ 0, 1,-1]], t[ 4])
|
|
418
|
+
assert_equal([0,0,[ 1,-1, 0]], t[ 5])
|
|
419
|
+
assert_equal([0,1,[-1,-1,-1]], t[ 6])
|
|
420
|
+
assert_equal([0,1,[-1,-1, 0]], t[ 7])
|
|
421
|
+
assert_equal([0,1,[-1, 0,-1]], t[ 8])
|
|
422
|
+
assert_equal([0,1,[ 0,-1,-1]], t[ 9])
|
|
423
|
+
assert_equal([1,0,[ 0, 1, 1]], t[10])
|
|
424
|
+
assert_equal([1,0,[ 1, 0, 1]], t[11])
|
|
425
|
+
assert_equal([1,0,[ 1, 1, 0]], t[12])
|
|
426
|
+
assert_equal([1,0,[ 1, 1, 1]], t[13])
|
|
427
|
+
assert_equal([1,1,[-1, 1, 0]], t[14])
|
|
428
|
+
assert_equal([1,1,[ 0,-1, 1]], t[15])
|
|
429
|
+
assert_equal([1,1,[ 0, 0,-1]], t[16])
|
|
430
|
+
assert_equal([1,1,[ 0, 0, 1]], t[17])
|
|
431
|
+
assert_equal([1,1,[ 0, 1,-1]], t[18])
|
|
432
|
+
assert_equal([1,1,[ 1,-1, 0]], t[19])
|
|
433
|
+
|
|
434
|
+
t = pc00.pairs_within_distance(2.83)
|
|
435
|
+
assert_equal(36, t.size)
|
|
436
|
+
assert_equal([0,0,[-1, 0, 1]], t[ 0])
|
|
437
|
+
assert_equal([0,0,[-1, 1,-1]], t[ 1])
|
|
438
|
+
assert_equal([0,0,[-1, 1, 0]], t[ 2])
|
|
439
|
+
assert_equal([0,0,[-1, 1, 1]], t[ 3])
|
|
440
|
+
assert_equal([0,0,[ 0,-1, 0]], t[ 4])
|
|
441
|
+
assert_equal([0,0,[ 0,-1, 1]], t[ 5])
|
|
442
|
+
assert_equal([0,0,[ 0, 0,-1]], t[ 6])
|
|
443
|
+
assert_equal([0,0,[ 0, 0, 1]], t[ 7])
|
|
444
|
+
assert_equal([0,0,[ 0, 1,-1]], t[ 8])
|
|
445
|
+
assert_equal([0,0,[ 0, 1, 0]], t[ 9])
|
|
446
|
+
assert_equal([0,0,[ 1,-1,-1]], t[10])
|
|
447
|
+
assert_equal([0,0,[ 1,-1, 0]], t[11])
|
|
448
|
+
assert_equal([0,0,[ 1,-1, 1]], t[12])
|
|
449
|
+
assert_equal([0,0,[ 1, 0,-1]], t[13])
|
|
450
|
+
assert_equal([0,1,[-1,-1,-1]], t[14])
|
|
451
|
+
assert_equal([0,1,[-1,-1, 0]], t[15])
|
|
452
|
+
assert_equal([0,1,[-1, 0,-1]], t[16])
|
|
453
|
+
assert_equal([0,1,[ 0,-1,-1]], t[17])
|
|
454
|
+
assert_equal([1,0,[ 0, 1, 1]], t[18])
|
|
455
|
+
assert_equal([1,0,[ 1, 0, 1]], t[19])
|
|
456
|
+
assert_equal([1,0,[ 1, 1, 0]], t[20])
|
|
457
|
+
assert_equal([1,0,[ 1, 1, 1]], t[21])
|
|
458
|
+
assert_equal([1,1,[-1, 0, 1]], t[22])
|
|
459
|
+
assert_equal([1,1,[-1, 1,-1]], t[23])
|
|
460
|
+
assert_equal([1,1,[-1, 1, 0]], t[24])
|
|
461
|
+
assert_equal([1,1,[-1, 1, 1]], t[25])
|
|
462
|
+
assert_equal([1,1,[ 0,-1, 0]], t[26])
|
|
463
|
+
assert_equal([1,1,[ 0,-1, 1]], t[27])
|
|
464
|
+
assert_equal([1,1,[ 0, 0,-1]], t[28])
|
|
465
|
+
assert_equal([1,1,[ 0, 0, 1]], t[29])
|
|
466
|
+
assert_equal([1,1,[ 0, 1,-1]], t[30])
|
|
467
|
+
assert_equal([1,1,[ 0, 1, 0]], t[31])
|
|
468
|
+
assert_equal([1,1,[ 1,-1,-1]], t[32])
|
|
469
|
+
assert_equal([1,1,[ 1,-1, 0]], t[33])
|
|
470
|
+
assert_equal([1,1,[ 1,-1, 1]], t[34])
|
|
471
|
+
assert_equal([1,1,[ 1, 0,-1]], t[35])
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
def test_add_atom
|
|
475
|
+
tmp = Marshal.load(Marshal.dump(@c00))
|
|
476
|
+
tmp.add_atom(CrystalCell::Atom.new(0, [1.0, 2.3, -2.3]))
|
|
477
|
+
assert_equal(1, tmp.positions.size)
|
|
478
|
+
assert_equal(Mageo::Vector3DInternal, tmp.positions[0].class)
|
|
479
|
+
assert_in_delta(0.0, tmp.positions[0][0], $tolerance)
|
|
480
|
+
assert_in_delta(0.3, tmp.positions[0][1], $tolerance)
|
|
481
|
+
assert_in_delta(0.7, tmp.positions[0][2], $tolerance)
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def test_rotate
|
|
485
|
+
@c02.add_atom(CrystalCell::Atom.new('Li', [1.1, 1.2, 1.3]))
|
|
486
|
+
|
|
487
|
+
# Check new instance.
|
|
488
|
+
assert_equal(3, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions.size)
|
|
489
|
+
assert_equal(Mageo::Vector3DInternal, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[0].class)
|
|
490
|
+
assert_equal(Mageo::Vector3DInternal, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[1].class)
|
|
491
|
+
assert_equal(Mageo::Vector3DInternal, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[2].class)
|
|
492
|
+
assert_in_delta(0.0, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[0][0], $tolerance)
|
|
493
|
+
assert_in_delta(0.0, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[0][1], $tolerance)
|
|
494
|
+
assert_in_delta(0.0, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[0][2], $tolerance)
|
|
495
|
+
assert_in_delta(0.8, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[1][0], $tolerance)
|
|
496
|
+
assert_in_delta(0.8, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[1][1], $tolerance)
|
|
497
|
+
assert_in_delta(0.8, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[1][2], $tolerance)
|
|
498
|
+
assert_in_delta(0.9, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[2][0], $tolerance)
|
|
499
|
+
assert_in_delta(0.8, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[2][1], $tolerance)
|
|
500
|
+
assert_in_delta(0.7, @c02.rotate([[-1, 0, 0],[0, -1, 0],[0, 0, -1]]).positions[2][2], $tolerance)
|
|
501
|
+
|
|
502
|
+
# Check not destructed.
|
|
503
|
+
assert_equal(3, @c02.positions.size)
|
|
504
|
+
assert_equal(Mageo::Vector3DInternal, @c02.positions[0].class)
|
|
505
|
+
assert_equal(Mageo::Vector3DInternal, @c02.positions[1].class)
|
|
506
|
+
assert_equal(Mageo::Vector3DInternal, @c02.positions[2].class)
|
|
507
|
+
assert_in_delta(0.0 , @c02.positions[0][0], $tolerance)
|
|
508
|
+
assert_in_delta(0.0 , @c02.positions[0][1], $tolerance)
|
|
509
|
+
assert_in_delta(0.0 , @c02.positions[0][2], $tolerance)
|
|
510
|
+
assert_in_delta(0.2 , @c02.positions[1][0], $tolerance)
|
|
511
|
+
assert_in_delta(0.2 , @c02.positions[1][1], $tolerance)
|
|
512
|
+
assert_in_delta(0.2 , @c02.positions[1][2], $tolerance)
|
|
513
|
+
assert_in_delta(0.1 , @c02.positions[2][0], $tolerance)
|
|
514
|
+
assert_in_delta(0.2 , @c02.positions[2][1], $tolerance)
|
|
515
|
+
assert_in_delta(0.3 , @c02.positions[2][2], $tolerance)
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
def test_rotate!
|
|
519
|
+
@c02.add_atom(CrystalCell::Atom.new('Li', [0.1, 0.2, 0.3]))
|
|
520
|
+
@c02.rotate!([[-1, 0, 0],[0, -1, 0],[0, 0, -1]])
|
|
521
|
+
assert_equal(
|
|
522
|
+
[ Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ],
|
|
523
|
+
Mageo::Vector3DInternal[ 0.8, 0.8, 0.8 ],
|
|
524
|
+
Mageo::Vector3DInternal[ 0.9, 0.8, 0.7 ]
|
|
525
|
+
],
|
|
526
|
+
@c02.positions
|
|
527
|
+
)
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
def test_translate
|
|
531
|
+
poss = @c02.translate([1.1, 1.2, 1.3]).positions
|
|
532
|
+
assert_in_delta(0.1, poss[0][0], $tolerance)
|
|
533
|
+
assert_in_delta(0.2, poss[0][1], $tolerance)
|
|
534
|
+
assert_in_delta(0.3, poss[0][2], $tolerance)
|
|
535
|
+
assert_in_delta(0.3, poss[1][0], $tolerance)
|
|
536
|
+
assert_in_delta(0.4, poss[1][1], $tolerance)
|
|
537
|
+
assert_in_delta(0.5, poss[1][2], $tolerance)
|
|
538
|
+
|
|
539
|
+
poss = @c02.translate([-0.3,-0.3,-0.3]).positions
|
|
540
|
+
assert_in_delta( 0.7, poss[0][0], $tolerance)
|
|
541
|
+
assert_in_delta( 0.7, poss[0][1], $tolerance)
|
|
542
|
+
assert_in_delta( 0.7, poss[0][2], $tolerance)
|
|
543
|
+
assert_in_delta( 0.9, poss[1][0], $tolerance)
|
|
544
|
+
assert_in_delta( 0.9, poss[1][1], $tolerance)
|
|
545
|
+
assert_in_delta( 0.9, poss[1][2], $tolerance)
|
|
546
|
+
|
|
547
|
+
# Check not destructed.
|
|
548
|
+
assert_equal(
|
|
549
|
+
[ Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ],
|
|
550
|
+
Mageo::Vector3DInternal[ 0.2, 0.2, 0.2 ]
|
|
551
|
+
],
|
|
552
|
+
@c02.positions
|
|
553
|
+
)
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
def test_translate!
|
|
557
|
+
@c02.translate!([1.1, 1.2, 1.3])
|
|
558
|
+
poss = @c02.positions
|
|
559
|
+
|
|
560
|
+
assert_in_delta(0.1, poss[0][0], $tolerance)
|
|
561
|
+
assert_in_delta(0.2, poss[0][1], $tolerance)
|
|
562
|
+
assert_in_delta(0.3, poss[0][2], $tolerance)
|
|
563
|
+
assert_in_delta(0.3, poss[1][0], $tolerance)
|
|
564
|
+
assert_in_delta(0.4, poss[1][1], $tolerance)
|
|
565
|
+
assert_in_delta(0.5, poss[1][2], $tolerance)
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
def test_to_cell
|
|
569
|
+
t = @c01.to_cell
|
|
570
|
+
assert_equal(CrystalCell::Cell, t.class)
|
|
571
|
+
assert_equal(CrystalCell::LatticeAxes, t.axes.class)
|
|
572
|
+
assert_in_delta(2.0, t.axes[0][0], $tolerance)
|
|
573
|
+
assert_in_delta(2.0, t.axes[0][1], $tolerance)
|
|
574
|
+
assert_in_delta(2.0, t.axes[0][2], $tolerance)
|
|
575
|
+
assert_in_delta(0.0, t.axes[1][0], $tolerance)
|
|
576
|
+
assert_in_delta(2.0, t.axes[1][1], $tolerance)
|
|
577
|
+
assert_in_delta(2.0, t.axes[1][2], $tolerance)
|
|
578
|
+
assert_in_delta(0.0, t.axes[2][0], $tolerance)
|
|
579
|
+
assert_in_delta(0.0, t.axes[2][1], $tolerance)
|
|
580
|
+
assert_in_delta(2.0, t.axes[2][2], $tolerance)
|
|
581
|
+
|
|
582
|
+
assert_equal(2, t.atoms.size)
|
|
583
|
+
assert_equal(CrystalCell::Atom.new(0, [0.0, 0.0, 0.0]), t.atoms[0])
|
|
584
|
+
assert_equal(CrystalCell::Atom.new(1, [0.1, 0.2, 0.3]), t.atoms[1])
|
|
585
|
+
assert_equal("c01", t.comment)
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
def test_center_of_atoms
|
|
589
|
+
# No atoms
|
|
590
|
+
assert_raise(NoMethodError){ @c00.center_of_atoms }
|
|
591
|
+
|
|
592
|
+
# Including atoms
|
|
593
|
+
assert_raise(NoMethodError){ @c01.center_of_atoms }
|
|
594
|
+
end
|
|
595
|
+
|
|
596
|
+
def test_inverse_axis!
|
|
597
|
+
@c02.inverse_axis!(0)
|
|
598
|
+
t = @c02
|
|
599
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
600
|
+
assert_in_delta(t.axes[0][0],-2.0, $tolerance)
|
|
601
|
+
assert_in_delta(t.axes[0][1],-2.0, $tolerance)
|
|
602
|
+
assert_in_delta(t.axes[0][2],-2.0, $tolerance)
|
|
603
|
+
assert_in_delta(t.axes[1][0], 0.0, $tolerance)
|
|
604
|
+
assert_in_delta(t.axes[1][1], 2.0, $tolerance)
|
|
605
|
+
assert_in_delta(t.axes[1][2], 2.0, $tolerance)
|
|
606
|
+
assert_in_delta(t.axes[2][0], 0.0, $tolerance)
|
|
607
|
+
assert_in_delta(t.axes[2][1], 0.0, $tolerance)
|
|
608
|
+
assert_in_delta(t.axes[2][2], 2.0, $tolerance)
|
|
609
|
+
assert_equal(2, t.atoms.size)
|
|
610
|
+
# checking atom 0
|
|
611
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
612
|
+
assert_equal(Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
|
|
613
|
+
assert_equal(nil , t.atoms[0].name)
|
|
614
|
+
# checking atom 1
|
|
615
|
+
assert_equal('O' , t.atoms[1].element)
|
|
616
|
+
assert_equal(Mageo::Vector3DInternal[ 0.8, 0.2, 0.2], t.atoms[1].position)
|
|
617
|
+
assert_equal(nil , t.atoms[1].name)
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
def test_inverse_axis
|
|
622
|
+
# x 軸反転
|
|
623
|
+
t = @c02.inverse_axis(0)
|
|
624
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
625
|
+
assert_in_delta(t.axes[0][0],-2.0, $tolerance)
|
|
626
|
+
assert_in_delta(t.axes[0][1],-2.0, $tolerance)
|
|
627
|
+
assert_in_delta(t.axes[0][2],-2.0, $tolerance)
|
|
628
|
+
assert_in_delta(t.axes[1][0], 0.0, $tolerance)
|
|
629
|
+
assert_in_delta(t.axes[1][1], 2.0, $tolerance)
|
|
630
|
+
assert_in_delta(t.axes[1][2], 2.0, $tolerance)
|
|
631
|
+
assert_in_delta(t.axes[2][0], 0.0, $tolerance)
|
|
632
|
+
assert_in_delta(t.axes[2][1], 0.0, $tolerance)
|
|
633
|
+
assert_in_delta(t.axes[2][2], 2.0, $tolerance)
|
|
634
|
+
assert_equal(2, t.atoms.size)
|
|
635
|
+
# checking atom 0
|
|
636
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
637
|
+
assert_equal(Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
|
|
638
|
+
assert_equal(nil , t.atoms[0].name)
|
|
639
|
+
# checking atom 1
|
|
640
|
+
assert_equal('O' , t.atoms[1].element)
|
|
641
|
+
assert_equal(Mageo::Vector3DInternal[ 0.8, 0.2, 0.2], t.atoms[1].position)
|
|
642
|
+
assert_equal(nil , t.atoms[1].name)
|
|
643
|
+
|
|
644
|
+
# y 軸反転
|
|
645
|
+
# [ [ ax, ay, az], [ 0, by, bz], [ 0, 0, cz] ]
|
|
646
|
+
# ↓ y 軸反転
|
|
647
|
+
# [ [ ax, ay, az], [ 0,-by,-bz], [ 0, 0, cz] ]
|
|
648
|
+
# ↓ b vector の y 成分が正になるようにする。
|
|
649
|
+
# すなわち z 軸回りに半回転し、全ての x, y 成分が反転する。
|
|
650
|
+
# [ [-ax,-ay, az], [ 0, by,-bz], [ 0, 0, cz] ]
|
|
651
|
+
t = @c02.inverse_axis(1)
|
|
652
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
653
|
+
assert_in_delta(t.axes[0][0],-2.0, $tolerance)
|
|
654
|
+
assert_in_delta(t.axes[0][1],-2.0, $tolerance)
|
|
655
|
+
assert_in_delta(t.axes[0][2], 2.0, $tolerance)
|
|
656
|
+
assert_in_delta(t.axes[1][0], 0.0, $tolerance)
|
|
657
|
+
assert_in_delta(t.axes[1][1], 2.0, $tolerance)
|
|
658
|
+
assert_in_delta(t.axes[1][2],-2.0, $tolerance)
|
|
659
|
+
assert_in_delta(t.axes[2][0], 0.0, $tolerance)
|
|
660
|
+
assert_in_delta(t.axes[2][1], 0.0, $tolerance)
|
|
661
|
+
assert_in_delta(t.axes[2][2], 2.0, $tolerance)
|
|
662
|
+
assert_equal(2, t.atoms.size)
|
|
663
|
+
# checking atom 0
|
|
664
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
665
|
+
assert_equal(Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
|
|
666
|
+
assert_equal(nil , t.atoms[0].name)
|
|
667
|
+
# checking atom 1
|
|
668
|
+
assert_equal('O' , t.atoms[1].element)
|
|
669
|
+
assert_equal(Mageo::Vector3DInternal[ 0.2, 0.8, 0.2], t.atoms[1].position)
|
|
670
|
+
assert_equal(nil , t.atoms[1].name)
|
|
671
|
+
|
|
672
|
+
# z 軸反転
|
|
673
|
+
# [ [ ax, ay, az], [ 0, by, bz], [ 0, 0, cz] ]
|
|
674
|
+
# ↓ z 軸反転
|
|
675
|
+
# [ [ ax, ay, az], [ 0, by, bz], [ 0, 0,-cz] ]
|
|
676
|
+
# ↓ c vector の z 成分が正になるようにする。
|
|
677
|
+
# b vector の y 成分も正であることを保存する回転は、
|
|
678
|
+
# y 軸回りに半回転し、全ての x, z 成分が反転する。
|
|
679
|
+
# [ [-ax, ay,-az], [ 0, by,-bz], [ 0, 0, cz] ]
|
|
680
|
+
t = @c02.inverse_axis(2)
|
|
681
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
682
|
+
assert_in_delta(t.axes[0][0],-2.0, $tolerance)
|
|
683
|
+
assert_in_delta(t.axes[0][1], 2.0, $tolerance)
|
|
684
|
+
assert_in_delta(t.axes[0][2],-2.0, $tolerance)
|
|
685
|
+
assert_in_delta(t.axes[1][0], 0.0, $tolerance)
|
|
686
|
+
assert_in_delta(t.axes[1][1], 2.0, $tolerance)
|
|
687
|
+
assert_in_delta(t.axes[1][2],-2.0, $tolerance)
|
|
688
|
+
assert_in_delta(t.axes[2][0], 0.0, $tolerance)
|
|
689
|
+
assert_in_delta(t.axes[2][1], 0.0, $tolerance)
|
|
690
|
+
assert_in_delta(t.axes[2][2], 2.0, $tolerance)
|
|
691
|
+
assert_equal(2, t.atoms.size)
|
|
692
|
+
# checking atom 0
|
|
693
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
694
|
+
assert_equal(Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
|
|
695
|
+
assert_equal(nil , t.atoms[0].name)
|
|
696
|
+
# checking atom 1
|
|
697
|
+
assert_equal('O' , t.atoms[1].element)
|
|
698
|
+
assert_equal(Mageo::Vector3DInternal[ 0.2, 0.2, 0.8], t.atoms[1].position)
|
|
699
|
+
assert_equal(nil , t.atoms[1].name)
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
def test_exchange_axes!
|
|
703
|
+
# b, c の交換。
|
|
704
|
+
@c08.exchange_axes!([ 1, 2 ])
|
|
705
|
+
t = @c08
|
|
706
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
707
|
+
lc = t.axes.get_lattice_constants
|
|
708
|
+
assert_in_delta(2.0 * Math::sqrt(3.0) , lc[0], $tolerance)
|
|
709
|
+
assert_in_delta(2.0 , lc[1], $tolerance)
|
|
710
|
+
assert_in_delta(2.0 * Math::sqrt(2.0) , lc[2], $tolerance)
|
|
711
|
+
assert_in_delta(45.0000000000000, lc[3], $tolerance)
|
|
712
|
+
assert_in_delta(35.2643896827547, lc[4], $tolerance)
|
|
713
|
+
assert_in_delta(54.7356103172453, lc[5], $tolerance)
|
|
714
|
+
assert_equal(true, t.axes.lefthand?)
|
|
715
|
+
assert_equal(2, t.atoms.size)
|
|
716
|
+
# checking atom 0
|
|
717
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
718
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[0].position.class)
|
|
719
|
+
assert_in_delta(0.2, t.atoms[0].position[0], $tolerance)
|
|
720
|
+
assert_in_delta(0.6, t.atoms[0].position[1], $tolerance)
|
|
721
|
+
assert_in_delta(0.4, t.atoms[0].position[2], $tolerance)
|
|
722
|
+
assert_equal('atom0' , t.atoms[0].name)
|
|
723
|
+
assert_equal([ false, false, true] , t.atoms[0].movable_flags)
|
|
724
|
+
# checking atom 1
|
|
725
|
+
assert_equal('O' , t.atoms[1].element)
|
|
726
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[1].position.class)
|
|
727
|
+
assert_in_delta(0.8, t.atoms[1].position[0], $tolerance)
|
|
728
|
+
assert_in_delta(0.4, t.atoms[1].position[1], $tolerance)
|
|
729
|
+
assert_in_delta(0.6, t.atoms[1].position[2], $tolerance)
|
|
730
|
+
assert_equal(nil , t.atoms[1].name)
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
def test_exchange_axes
|
|
734
|
+
assert_raise(CrystalCell::Cell::ArgumentError){ @c02.exchange_axes([ 0 ]) }
|
|
735
|
+
assert_raise(CrystalCell::Cell::ArgumentError){ @c02.exchange_axes([ 0, 1, 2]) }
|
|
736
|
+
assert_raise(CrystalCell::Cell::AxesRangeError){ @c02.exchange_axes([0, 3]) }
|
|
737
|
+
assert_raise(CrystalCell::Cell::AxesRangeError){ @c02.exchange_axes([-1, 2]) }
|
|
738
|
+
assert_raise(CrystalCell::Cell::SameAxesError){ @c02.exchange_axes([ 1,1]) }
|
|
739
|
+
|
|
740
|
+
# b, c の交換。
|
|
741
|
+
t = @c08.exchange_axes([ 1, 2 ])
|
|
742
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
743
|
+
lc = t.axes.get_lattice_constants
|
|
744
|
+
assert_in_delta(2.0 * Math::sqrt(3.0) , lc[0], $tolerance)
|
|
745
|
+
assert_in_delta(2.0 , lc[1], $tolerance)
|
|
746
|
+
assert_in_delta(2.0 * Math::sqrt(2.0) , lc[2], $tolerance)
|
|
747
|
+
assert_in_delta(45.0000000000000, lc[3], $tolerance)
|
|
748
|
+
assert_in_delta(35.2643896827547, lc[4], $tolerance)
|
|
749
|
+
assert_in_delta(54.7356103172453, lc[5], $tolerance)
|
|
750
|
+
assert_equal(true, t.axes.lefthand?)
|
|
751
|
+
assert_equal(2, t.atoms.size)
|
|
752
|
+
# checking atom 0
|
|
753
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
754
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[0].position.class)
|
|
755
|
+
assert_in_delta(0.2, t.atoms[0].position[0], $tolerance)
|
|
756
|
+
assert_in_delta(0.6, t.atoms[0].position[1], $tolerance)
|
|
757
|
+
assert_in_delta(0.4, t.atoms[0].position[2], $tolerance)
|
|
758
|
+
assert_equal('atom0' , t.atoms[0].name)
|
|
759
|
+
# checking atom 1
|
|
760
|
+
assert_equal('O' , t.atoms[1].element)
|
|
761
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[1].position.class)
|
|
762
|
+
assert_in_delta(0.8, t.atoms[1].position[0], $tolerance)
|
|
763
|
+
assert_in_delta(0.4, t.atoms[1].position[1], $tolerance)
|
|
764
|
+
assert_in_delta(0.6, t.atoms[1].position[2], $tolerance)
|
|
765
|
+
assert_equal(nil , t.atoms[1].name)
|
|
766
|
+
|
|
767
|
+
# b, c の交換によって非破壊であることを確認。
|
|
768
|
+
t = @c08
|
|
769
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
770
|
+
lc = t.axes.get_lattice_constants
|
|
771
|
+
assert_in_delta(2.0 * Math::sqrt(3.0) , lc[0], $tolerance)
|
|
772
|
+
assert_in_delta(2.0 * Math::sqrt(2.0) , lc[1], $tolerance)
|
|
773
|
+
assert_in_delta(2.0 , lc[2], $tolerance)
|
|
774
|
+
assert_in_delta(45.0000000000000, lc[3], $tolerance)
|
|
775
|
+
assert_in_delta(54.7356103172453, lc[4], $tolerance)
|
|
776
|
+
assert_in_delta(35.2643896827547, lc[5], $tolerance)
|
|
777
|
+
assert_equal(false, t.axes.lefthand?)
|
|
778
|
+
assert_equal(2, t.atoms.size)
|
|
779
|
+
# checking atom 0
|
|
780
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
781
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[0].position.class)
|
|
782
|
+
assert_in_delta(0.2, t.atoms[0].position[0], $tolerance)
|
|
783
|
+
assert_in_delta(0.4, t.atoms[0].position[1], $tolerance)
|
|
784
|
+
assert_in_delta(0.6, t.atoms[0].position[2], $tolerance)
|
|
785
|
+
assert_equal('atom0' , t.atoms[0].name)
|
|
786
|
+
# checking atom 1
|
|
787
|
+
assert_equal('O' , t.atoms[1].element)
|
|
788
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[1].position.class)
|
|
789
|
+
assert_in_delta(0.8, t.atoms[1].position[0], $tolerance)
|
|
790
|
+
assert_in_delta(0.6, t.atoms[1].position[1], $tolerance)
|
|
791
|
+
assert_in_delta(0.4, t.atoms[1].position[2], $tolerance)
|
|
792
|
+
assert_equal(nil , t.atoms[1].name)
|
|
793
|
+
end
|
|
794
|
+
|
|
795
|
+
def test_reflect!
|
|
796
|
+
@c08.reflect!
|
|
797
|
+
t = @c08
|
|
798
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
799
|
+
lc = t.axes.get_lattice_constants
|
|
800
|
+
assert_in_delta(2.0 * Math::sqrt(3.0) , lc[0], $tolerance)
|
|
801
|
+
assert_in_delta(2.0 * Math::sqrt(2.0) , lc[1], $tolerance)
|
|
802
|
+
assert_in_delta(2.0 , lc[2], $tolerance)
|
|
803
|
+
assert_in_delta(45.0000000000000, lc[3], $tolerance)
|
|
804
|
+
assert_in_delta(54.7356103172453, lc[4], $tolerance)
|
|
805
|
+
assert_in_delta(35.2643896827547, lc[5], $tolerance)
|
|
806
|
+
assert_equal(true, t.axes.lefthand?)
|
|
807
|
+
assert_equal(2, t.atoms.size)
|
|
808
|
+
# checking atom 0
|
|
809
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
810
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[0].position.class)
|
|
811
|
+
assert_in_delta(0.2, t.atoms[0].position[0], $tolerance)
|
|
812
|
+
assert_in_delta(0.4, t.atoms[0].position[1], $tolerance)
|
|
813
|
+
assert_in_delta(0.6, t.atoms[0].position[2], $tolerance)
|
|
814
|
+
assert_equal('atom0' , t.atoms[0].name)
|
|
815
|
+
# checking atom 1
|
|
816
|
+
assert_equal('O' , t.atoms[1].element)
|
|
817
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[1].position.class)
|
|
818
|
+
assert_in_delta(0.8, t.atoms[1].position[0], $tolerance)
|
|
819
|
+
assert_in_delta(0.6, t.atoms[1].position[1], $tolerance)
|
|
820
|
+
assert_in_delta(0.4, t.atoms[1].position[2], $tolerance)
|
|
821
|
+
assert_equal(nil , t.atoms[1].name)
|
|
822
|
+
end
|
|
823
|
+
|
|
824
|
+
def test_reflect
|
|
825
|
+
t = @c08.reflect
|
|
826
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
827
|
+
lc = t.axes.get_lattice_constants
|
|
828
|
+
assert_in_delta(2.0 * Math::sqrt(3.0) , lc[0], $tolerance)
|
|
829
|
+
assert_in_delta(2.0 * Math::sqrt(2.0) , lc[1], $tolerance)
|
|
830
|
+
assert_in_delta(2.0 , lc[2], $tolerance)
|
|
831
|
+
assert_in_delta(45.0000000000000, lc[3], $tolerance)
|
|
832
|
+
assert_in_delta(54.7356103172453, lc[4], $tolerance)
|
|
833
|
+
assert_in_delta(35.2643896827547, lc[5], $tolerance)
|
|
834
|
+
assert_equal(true, t.axes.lefthand?)
|
|
835
|
+
assert_equal(2, t.atoms.size)
|
|
836
|
+
# checking atom 0
|
|
837
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
838
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[0].position.class)
|
|
839
|
+
assert_in_delta(0.2, t.atoms[0].position[0], $tolerance)
|
|
840
|
+
assert_in_delta(0.4, t.atoms[0].position[1], $tolerance)
|
|
841
|
+
assert_in_delta(0.6, t.atoms[0].position[2], $tolerance)
|
|
842
|
+
assert_equal('atom0' , t.atoms[0].name)
|
|
843
|
+
# checking atom 1
|
|
844
|
+
assert_equal('O' , t.atoms[1].element)
|
|
845
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[1].position.class)
|
|
846
|
+
assert_in_delta(0.8, t.atoms[1].position[0], $tolerance)
|
|
847
|
+
assert_in_delta(0.6, t.atoms[1].position[1], $tolerance)
|
|
848
|
+
assert_in_delta(0.4, t.atoms[1].position[2], $tolerance)
|
|
849
|
+
assert_equal(nil , t.atoms[1].name)
|
|
850
|
+
|
|
851
|
+
# 非破壊であることを確認。
|
|
852
|
+
t = @c08
|
|
853
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
854
|
+
lc = t.axes.get_lattice_constants
|
|
855
|
+
assert_in_delta(2.0 * Math::sqrt(3.0) , lc[0], $tolerance)
|
|
856
|
+
assert_in_delta(2.0 * Math::sqrt(2.0) , lc[1], $tolerance)
|
|
857
|
+
assert_in_delta(2.0 , lc[2], $tolerance)
|
|
858
|
+
assert_in_delta(45.0000000000000, lc[3], $tolerance)
|
|
859
|
+
assert_in_delta(54.7356103172453, lc[4], $tolerance)
|
|
860
|
+
assert_in_delta(35.2643896827547, lc[5], $tolerance)
|
|
861
|
+
assert_equal(true, t.axes.righthand?)
|
|
862
|
+
assert_equal(2, t.atoms.size)
|
|
863
|
+
# checking atom 0
|
|
864
|
+
assert_equal('Li' , t.atoms[0].element)
|
|
865
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[0].position.class)
|
|
866
|
+
assert_in_delta(0.2, t.atoms[0].position[0], $tolerance)
|
|
867
|
+
assert_in_delta(0.4, t.atoms[0].position[1], $tolerance)
|
|
868
|
+
assert_in_delta(0.6, t.atoms[0].position[2], $tolerance)
|
|
869
|
+
assert_equal('atom0' , t.atoms[0].name)
|
|
870
|
+
# checking atom 1
|
|
871
|
+
assert_equal('O' , t.atoms[1].element)
|
|
872
|
+
assert_equal(Mageo::Vector3DInternal, t.atoms[1].position.class)
|
|
873
|
+
assert_in_delta(0.8, t.atoms[1].position[0], $tolerance)
|
|
874
|
+
assert_in_delta(0.6, t.atoms[1].position[1], $tolerance)
|
|
875
|
+
assert_in_delta(0.4, t.atoms[1].position[2], $tolerance)
|
|
876
|
+
assert_equal(nil , t.atoms[1].name)
|
|
877
|
+
|
|
878
|
+
end
|
|
879
|
+
|
|
880
|
+
# private
|
|
881
|
+
|
|
882
|
+
def test_reset_positions_inside
|
|
883
|
+
tmp = Marshal.load(Marshal.dump(@c00))
|
|
884
|
+
tmp.add_atom(CrystalCell::Atom.new(0, [1.0, 2.3, -2.3]))
|
|
885
|
+
tmp.atoms[0].set_position([1.0, 2.3, -2.3])
|
|
886
|
+
tmp.reset_positions_inside
|
|
887
|
+
assert_equal(1, tmp.positions.size)
|
|
888
|
+
assert_equal(Mageo::Vector3DInternal, tmp.positions[0].class)
|
|
889
|
+
assert_in_delta(0.0, tmp.positions[0][0], $tolerance)
|
|
890
|
+
assert_in_delta(0.3, tmp.positions[0][1], $tolerance)
|
|
891
|
+
assert_in_delta(0.7, tmp.positions[0][2], $tolerance)
|
|
892
|
+
end
|
|
893
|
+
|
|
894
|
+
#undef test_directions_within_distance
|
|
895
|
+
#undef test_nearest_direction
|
|
896
|
+
#undef test_nearest_distance
|
|
897
|
+
#undef test_find_bonds
|
|
898
|
+
#undef test_pairs_within_distance
|
|
899
|
+
#undef test_add_atom
|
|
900
|
+
#undef test_rotate
|
|
901
|
+
#undef test_rotate!
|
|
902
|
+
#undef test_translate
|
|
903
|
+
#undef test_translate!
|
|
904
|
+
#undef test_to_cell
|
|
905
|
+
#undef test_center_of_atoms
|
|
906
|
+
#undef test_inverse_axis!
|
|
907
|
+
#undef test_inverse_axis
|
|
908
|
+
#undef test_exchange_axes!
|
|
909
|
+
#undef test_exchange_axes
|
|
910
|
+
#undef test_reflect!
|
|
911
|
+
#undef test_reflect
|
|
912
|
+
#undef test_reset_positions_inside
|
|
913
913
|
|
|
914
914
|
end
|
|
915
915
|
|
|
916
916
|
class TC_Cell_EXTENSION < Test::Unit::TestCase
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
917
|
+
$tolerance = 10 ** (-10)
|
|
918
|
+
|
|
919
|
+
def test_to_pcell
|
|
920
|
+
c08 = CrystalCell::Cell.new([ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ])
|
|
921
|
+
c08.add_atom(CrystalCell::Atom.new('Li', [ 1.2, 3.4, 5.6], "atom0", [ false, false, true]))
|
|
922
|
+
c08.add_atom(CrystalCell::Atom.new('O', [-1.2, -3.4, -5.6]))
|
|
923
|
+
c08.comment = 'c08'
|
|
924
|
+
#
|
|
925
|
+
t = c08.to_pcell
|
|
926
|
+
assert_equal(CrystalCell::PeriodicCell, t.class)
|
|
927
|
+
assert_equal(CrystalCell::LatticeAxes, t.axes.class)
|
|
928
|
+
assert_in_delta(2.0, t.axes[0][0], $tolerance)
|
|
929
|
+
assert_in_delta(2.0, t.axes[0][1], $tolerance)
|
|
930
|
+
assert_in_delta(2.0, t.axes[0][2], $tolerance)
|
|
931
|
+
assert_in_delta(0.0, t.axes[1][0], $tolerance)
|
|
932
|
+
assert_in_delta(2.0, t.axes[1][1], $tolerance)
|
|
933
|
+
assert_in_delta(2.0, t.axes[1][2], $tolerance)
|
|
934
|
+
assert_in_delta(0.0, t.axes[2][0], $tolerance)
|
|
935
|
+
assert_in_delta(0.0, t.axes[2][1], $tolerance)
|
|
936
|
+
assert_in_delta(2.0, t.axes[2][2], $tolerance)
|
|
937
|
+
#
|
|
938
|
+
assert_equal(2, t.atoms.size)
|
|
939
|
+
assert_equal(CrystalCell::Atom, t.atoms[0].class)
|
|
940
|
+
assert_equal(CrystalCell::Atom, t.atoms[1].class)
|
|
941
|
+
assert_in_delta(0.2, t.atoms[0].position[0], $tolerance)
|
|
942
|
+
assert_in_delta(0.4, t.atoms[0].position[1], $tolerance)
|
|
943
|
+
assert_in_delta(0.6, t.atoms[0].position[2], $tolerance)
|
|
944
|
+
assert_in_delta(0.8, t.atoms[1].position[0], $tolerance)
|
|
945
|
+
assert_in_delta(0.6, t.atoms[1].position[1], $tolerance)
|
|
946
|
+
assert_in_delta(0.4, t.atoms[1].position[2], $tolerance)
|
|
947
|
+
#
|
|
948
|
+
assert_equal("atom0", t.atoms[0].name)
|
|
949
|
+
assert_equal(nil , t.atoms[1].name)
|
|
950
|
+
#
|
|
951
|
+
assert_equal([ false, false, true ], t.atoms[0].movable_flags)
|
|
952
|
+
assert_equal(nil, t.atoms[1].movable_flags)
|
|
953
|
+
#
|
|
954
|
+
assert_equal("c08", t.comment)
|
|
955
|
+
|
|
956
|
+
# 破壊的でないことを確認。
|
|
957
|
+
t = c08
|
|
958
|
+
assert_equal(2, t.atoms.size)
|
|
959
|
+
assert_equal(CrystalCell::Atom, t.atoms[0].class)
|
|
960
|
+
assert_equal(CrystalCell::Atom, t.atoms[1].class)
|
|
961
|
+
assert_in_delta( 1.2, t.atoms[0].position[0], $tolerance)
|
|
962
|
+
assert_in_delta( 3.4, t.atoms[0].position[1], $tolerance)
|
|
963
|
+
assert_in_delta( 5.6, t.atoms[0].position[2], $tolerance)
|
|
964
|
+
assert_in_delta(-1.2, t.atoms[1].position[0], $tolerance)
|
|
965
|
+
assert_in_delta(-3.4, t.atoms[1].position[1], $tolerance)
|
|
966
|
+
assert_in_delta(-5.6, t.atoms[1].position[2], $tolerance)
|
|
967
|
+
end
|
|
968
968
|
|
|
969
969
|
end
|