-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
113 lines (91 loc) · 3.67 KB
/
README.Rmd
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
---
output:
md_document:
variant: markdown_github
bibliography: vignettes/references.bib
citation_package: natbib
biblio-style: apalike
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rgl.cry
<!-- badges: start -->
[](https://CRAN.R-project.org/package=rgl.cry)
[](https://github.com/SaitouToshihide/rgl.cry/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
This is a use case for the ``cry`` and ``rgl`` packages.
This package provides tools for selected area electron diffraction (SAED) pattern and crystal structure visualization using the ``rgl`` and ``cry`` packages.
In particular, the ``cry_demo()`` and ``dp_demo()`` function read files in CIF (Crystallographic Information Framework) format and display SAED patterns and crystal structures.
The ``dp_demo()`` function also performs simple simulations of powder X-ray diffraction (PXRD) patterns, and the results can be saved to a file in the working directory.
The package has been tested on several platforms, including Linux on Crostini with a Core™ m3-8100Y Chromebook, I found that even on this low-powered platform, the performance was acceptable.
## Web Resources
https://saitoutoshihide.github.io/rgl.cry/
## Installation
```{r, eval=FALSE, echo=TRUE}
install.packages("rgl.cry")
```
## Example
A CIF file is read, and a reciprocal lattice map with a cell widget is drawn.
In this example, a file is not specified, so the system default is used.
```{r, eval=FALSE, echo=TRUE}
dp_demo()
```
A CIF file is read, and a crystal structure with a axis widget is drawn.
```{r, eval=FALSE, echo=TRUE}
cry_demo()
```
### Utility functions
The crystal and diffraction pattern are aligned and displayed.
```{r, eval=FALSE, echo=TRUE}
align("a")
align("ra")
align("30 30") # x, y (deg)
```
Select one or more atoms or reciprocal lattice points in the window.
The labels and Miller indices of the selected atoms or lattice points will be displayed.
```{r, eval=FALSE, echo=TRUE}
> dp_demo()
[1] 1
> select()
To select points, use dragging the left mouse button.
To finish, press ESC.
.
[1] "1 1 -3" "1 0 -2" "2 0 -2" "1 1 -1" "1 0 0" "2 0 0" "1 1 1" "1 0 2"
> cry_demo()
[1] 2
> select()
To select points, use dragging the left mouse button.
To finish, press ESC.
.
[1] "Ti1" "Ti1"
```
### Extras
``dp_demo()`` can perform PXRD pattern simulation.
The result is saved as a file in the current directory by specifying options like this:
```{r, eval=FALSE, echo=TRUE}
## Output the simulation results of the PXDR pattern as a file.
dp_demo(xrd = TRUE)
```
The file looks like this:
```zsh
% sort -n +7 rgl.cry.dp.demo.2024-02-26_000000.dat
h k l d absF lp twotheta
137 0 0 0 Inf 308.117522 Inf 0.00000
136 -1 0 0 5.583222 17.389409 101.955123 15.87322
138 1 0 0 5.583222 17.389409 101.955123 15.87322
128 0 -2 0 4.453238 40.628676 63.820476 19.93782
146 0 2 0 4.453238 40.628676 63.820476 19.93782
129 1 -2 0 4.142661 17.444203 54.849532 21.44963
145 -1 2 0 4.142661 17.444203 54.849532 21.44963
```
## References
<div id="refs"></div>
## Acknowledgment
I would like to express my gratitude to the rgl, cry packages, and R for making this work possible. The data for the scattering factors is based on the data from the KEK Report [@sc_table_kek]. For the coloring of the atoms, I used [@mol_color], and for the atomic radii, I used [@enwiki:1179864711].