|
8 | 8 | Getting started |
9 | 9 | ================ |
10 | 10 |
|
11 | | -Here are some example templates provided to help you get started with writing your documentation. You can use these templates to create your own documentation. |
| 11 | +``diffpy.apps`` provides user applications to help with tasks using |
| 12 | +diffpy packages. This page contains the instructions for all applications |
| 13 | +available, including: |
12 | 14 |
|
13 | | -Reuse ``.rst`` files across multiple pages |
14 | | ------------------------------------------- |
| 15 | +- :ref:`runmacro` |
15 | 16 |
|
16 | | -Here is how you can reuse a reusable block of ``.rst`` files across multiple pages: |
| 17 | +.. _runmacro: |
17 | 18 |
|
18 | | -.. include:: snippets/example-table.rst |
| 19 | +Use ``runmacro`` to start refinement with a macro file |
| 20 | +------------------------------------------------------ |
19 | 21 |
|
20 | | -.. warning:: |
| 22 | +The ``runmacro`` application allows users to execute macros written in the |
| 23 | +diffpy macro language. |
21 | 24 |
|
22 | | - Ensure that the ``.rst`` file you are including is not too long. If it is too long, it may be better to split it into multiple files and include them separately. |
| 25 | +.. code-block:: bash |
23 | 26 |
|
24 | | -Refer to a specific section in the documentation |
25 | | ------------------------------------------------- |
| 27 | + diffpy.app runmacro <macro_file.dp-in> |
26 | 28 |
|
27 | | -You can use the ``ref`` tag to refer to a specific section in the documentation. For example, you can refer to the section below using the ``:ref:`` tag as shown :ref:`here <attach-image>`. |
| 29 | +To follow the example, |
28 | 30 |
|
29 | | -.. note:: |
| 31 | +1. download the example files from :download:`here <../example/runmacro_example.zip>` |
30 | 32 |
|
31 | | - Please check the raw ``.rst`` file of this page to see the exact use of the ``:ref:`` tag. |
| 33 | +2. extract the downloaded files and navigate to the extracted directory |
| 34 | + |
| 35 | +.. code-block:: bash |
32 | 36 |
|
33 | | -Embed your code snippets in the documentation |
34 | | ---------------------------------------------- |
| 37 | + mv /path/to/runmacro runmacro_example.zip working_directory |
| 38 | + cd working_directory |
| 39 | + unzip runmacro_example.zip |
35 | 40 |
|
36 | | -Here is how you can write a block of code in the documentation. You can use the ``code-block`` directive to write a block of code in the documentation. For example, you can write a block of code as shown below: |
| 41 | +3. run the macro using the ``runmacro`` application |
37 | 42 |
|
38 | 43 | .. code-block:: bash |
39 | 44 |
|
40 | | - # Create a new environment, without build dependencies (pure Python package) |
41 | | - conda create -n <package_name>-env python=3.14 \ |
42 | | - --file requirements/tests.txt \ |
43 | | - --file requirements/conda.txt |
| 45 | + diffpy.app runmacro example_macro.dp-in |
| 46 | +
|
| 47 | +How to write macro |
| 48 | +~~~~~~~~~~~~~~~~~~ |
| 49 | + |
| 50 | +Let's still use the Ni example created earlier, but this time we will |
| 51 | +write the macro file from scratch. |
| 52 | + |
| 53 | +1. Prepare the structure and profile file you want to work with. |
| 54 | + |
| 55 | +.. note:: |
| 56 | + |
| 57 | + The structure file is a ``.cif`` file representing the atomic arrangement in |
| 58 | + your sample, and the profile file is a ``.gr`` file containing the |
| 59 | + experimental data. |
| 60 | + |
| 61 | +Start the macro file with the following two lines: |
| 62 | + |
| 63 | +.. code-block:: text |
| 64 | +
|
| 65 | + load structure G1 from "path/to/structure.cif" |
| 66 | + load profile exp_ni from "path/to/profile.gr" |
44 | 67 |
|
45 | | - # Create a new environment, with build dependencies (non-pure Python package) |
46 | | - conda create -n <package_name>-env python=3.14 \ |
47 | | - --file requirements/tests.txt \ |
48 | | - --file requirements/conda.txt \ |
49 | | - --file requirements/build.txt |
| 68 | +``G1`` and ``exp_ni`` are the identifiers used in the macro to refer to the |
| 69 | +structure and profile files, respectively. Quotes ``""`` are must to specify |
| 70 | +the file paths. |
50 | 71 |
|
51 | | - # Activate the environment |
52 | | - conda activate <package_name>_env |
| 72 | +2. (Optional) Declare the space group of the structure. |
53 | 73 |
|
54 | | - # Install your package locally |
55 | | - # `--no-deps` to NOT install packages again from `requirements.pip.txt` |
56 | | - pip install -e . --no-deps |
| 74 | +.. code-block:: text |
57 | 75 |
|
58 | | - # Run pytest locally |
59 | | - pytest |
| 76 | + set G1 spacegroup as Fm-3m |
60 | 77 |
|
61 | | - # ... run example tutorials |
| 78 | +``G1`` is the identifier for the structure file loaded earlier. Space group |
| 79 | +symmetry ``Fm-3m`` is preserved during the refinement. You can also set |
| 80 | +it to be ``auto`` to use the one automatically parsed from the structure file. |
| 81 | +But if space group is not provided, nor can it be determined from the structure |
| 82 | +file, it will be considered as ``P1`` space group. |
62 | 83 |
|
63 | | -.. _attach-image: |
| 84 | +3. (Optional) Set the calculation parameters for the refinement. |
64 | 85 |
|
65 | | -Attach an image to the documentation |
66 | | ------------------------------------- |
| 86 | +.. code-block:: text |
67 | 87 |
|
68 | | -Here is how you attach an image to the documentation. The ``/docs/source/img/scikit-package-logo-text.png`` example image is provided in the template. |
| 88 | + set exp_ni calculation_range as 0.5 20.0 0.01 # r_min, r_max, r_step |
| 89 | + set exp_ni q_range as 0.5 20.0 # q_min, q_max |
69 | 90 |
|
70 | | -.. image:: ./img/scikit-package-logo-text.png |
71 | | - :alt: codecov-in-pr-comment |
72 | | - :width: 400px |
73 | | - :align: center |
| 91 | +``exp_ni`` is the identifier for the profile file loaded earlier. |
| 92 | +``calculation_range`` specifies the range and step size for the calculation, |
| 93 | +while ``q_range`` specifies the range of Q values to be used in the refinement. |
| 94 | +If calculation parameters are not set, it will use the ones |
| 95 | +that are defined in the profile file. |
74 | 96 |
|
75 | 97 |
|
76 | | -Other useful directives |
77 | | ------------------------ |
| 98 | +4. Create the refinement equation. |
78 | 99 |
|
79 | | -Here is how you can do menu selection :menuselection:`Admin --> Settings` and display labels for buttons like :guilabel:`Privacy level`. |
| 100 | +.. code-block:: text |
| 101 | +
|
| 102 | + create equation variables s0 |
| 103 | + set equation as "G1*s0" |
| 104 | +
|
| 105 | +``G1`` is the identifier for the structure file loaded earlier. In the |
| 106 | +equation, it represents the PDF data generated from the structure `G1`. |
| 107 | +``s0`` is created to count for the scaling factor. |
| 108 | + |
| 109 | +5. Store the results. |
| 110 | + |
| 111 | +.. code-block:: text |
| 112 | +
|
| 113 | + save to "output_results.json" |
| 114 | +
|
| 115 | +The results of the refinement will be saved to a file |
| 116 | +named ``output_results.json``. |
| 117 | + |
| 118 | +6. List variables to be refined. |
| 119 | + |
| 120 | +.. code-block:: text |
| 121 | +
|
| 122 | + variables: |
| 123 | + --- |
| 124 | + - G1.a: 3.52 |
| 125 | + - s0: 0.4 |
| 126 | + - G1.Uiso_0: 0.005 |
| 127 | + - G1.delta2: 2 |
| 128 | + - qdamp: 0.04 |
| 129 | + - qbroad: 0.02 |
| 130 | + --- |
| 131 | +
|
| 132 | +Only variables listed in this section will be refined during the |
| 133 | +execution of the macro, and the variables will also be refined in that order. |
| 134 | +Variables with initial values specified here will be used as the |
| 135 | +starting point for the refinement. |
| 136 | + |
| 137 | +.. note:: |
| 138 | + The naming of variables follows the format |
| 139 | + ``structure_identifier.parameter``, |
| 140 | + ``profile_parameter``, or |
| 141 | + ``equation_parameter``. |
| 142 | + |
| 143 | + For parameters belonging to a specific atom in the parameter, |
| 144 | + the naming follows the format ``structure_identifier.parameter_atomindex``. |
| 145 | + e.g. ``G1.Uiso_0`` here refers to the Uiso parameter of the first atom in |
| 146 | + the structure ``G1``. |
| 147 | + |
| 148 | + For constrained parameters, it will use the first parameter in the |
| 149 | + constraint. e.g. Here, lattice parameter ``a=b=c``, |
| 150 | + and ``Usio_0=Uiso_i, i=1,2,3``, ``a`` and ``Uiso_0`` are used as the |
| 151 | + reference variables. |
0 commit comments