|
| 1 | +:tocdepth: -1 |
| 2 | + |
| 3 | +.. index:: getting-started |
| 4 | + |
| 5 | +.. _getting-started: |
| 6 | + |
| 7 | +================ |
| 8 | +Getting started |
| 9 | +================ |
| 10 | + |
| 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: |
| 14 | + |
| 15 | +- :ref:`runmacro` |
| 16 | +- :ref:`agentify` |
| 17 | + |
| 18 | +.. _runmacro: |
| 19 | + |
| 20 | +Use ``runmacro`` to start refinement with a macro file |
| 21 | +------------------------------------------------------ |
| 22 | + |
| 23 | +The ``runmacro`` application allows users to execute macros written in the |
| 24 | +diffpy macro language. |
| 25 | + |
| 26 | +.. code-block:: bash |
| 27 | +
|
| 28 | + diffpy.app runmacro <macro_file.dp-in> |
| 29 | +
|
| 30 | +To follow the example, |
| 31 | + |
| 32 | +1. download the example files from :download:`here <../example/runmacro_example.zip>` |
| 33 | + |
| 34 | +2. extract the downloaded files and navigate to the extracted directory |
| 35 | + |
| 36 | +.. code-block:: bash |
| 37 | +
|
| 38 | + mv /path/to/runmacro runmacro_example.zip working_directory |
| 39 | + cd working_directory |
| 40 | + unzip runmacro_example.zip |
| 41 | +
|
| 42 | +3. run the macro using the ``runmacro`` application |
| 43 | + |
| 44 | +.. code-block:: bash |
| 45 | +
|
| 46 | + diffpy.app runmacro example_macro.dp-in |
| 47 | +
|
| 48 | +How to write macro |
| 49 | +~~~~~~~~~~~~~~~~~~ |
| 50 | + |
| 51 | +Let's still use the Ni example created earlier, but this time we will |
| 52 | +write the macro file from scratch. |
| 53 | + |
| 54 | +1. Prepare the structure and profile file you want to work with. |
| 55 | + |
| 56 | +.. note:: |
| 57 | + |
| 58 | + The structure file is a ``.cif`` file representing the atomic arrangement in |
| 59 | + your sample, and the profile file is a ``.gr`` file containing the |
| 60 | + experimental data. |
| 61 | + |
| 62 | +Start the macro file with the following two lines: |
| 63 | + |
| 64 | +.. code-block:: text |
| 65 | +
|
| 66 | + load structure G1 from "path/to/structure.cif" |
| 67 | + load profile exp_ni from "path/to/profile.gr" |
| 68 | +
|
| 69 | +``G1`` and ``exp_ni`` are the identifiers used in the macro to refer to the |
| 70 | +structure and profile files, respectively. Quotes ``""`` are must to specify |
| 71 | +the file paths. |
| 72 | + |
| 73 | +2. (Optional) Declare the space group of the structure. |
| 74 | + |
| 75 | +.. code-block:: text |
| 76 | +
|
| 77 | + set G1 spacegroup as Fm-3m |
| 78 | +
|
| 79 | +``G1`` is the identifier for the structure file loaded earlier. Space group |
| 80 | +symmetry ``Fm-3m`` is preserved during the refinement. You can also set |
| 81 | +it to be ``auto`` to use the one automatically parsed from the structure file. |
| 82 | +But if space group is not provided, nor can it be determined from the structure |
| 83 | +file, it will be considered as ``P1`` space group. |
| 84 | + |
| 85 | +3. (Optional) Set the calculation parameters for the refinement. |
| 86 | + |
| 87 | +.. code-block:: text |
| 88 | +
|
| 89 | + set exp_ni calculation_range as 0.5 20.0 0.01 # r_min, r_max, r_step |
| 90 | + set exp_ni q_range as 0.5 20.0 # q_min, q_max |
| 91 | +
|
| 92 | +``exp_ni`` is the identifier for the profile file loaded earlier. |
| 93 | +``calculation_range`` specifies the range and step size for the calculation, |
| 94 | +while ``q_range`` specifies the range of Q values to be used in the refinement. |
| 95 | +If calculation parameters are not set, it will use the ones |
| 96 | +that are defined in the profile file. |
| 97 | + |
| 98 | + |
| 99 | +4. Create the refinement equation. |
| 100 | + |
| 101 | +.. code-block:: text |
| 102 | +
|
| 103 | + create equation variables s0 |
| 104 | + set equation as "G1*s0" |
| 105 | +
|
| 106 | +``G1`` is the identifier for the structure file loaded earlier. In the |
| 107 | +equation, it represents the PDF data generated from the structure `G1`. |
| 108 | +``s0`` is created to count for the scaling factor. |
| 109 | + |
| 110 | +5. Store the results. |
| 111 | + |
| 112 | +.. code-block:: text |
| 113 | +
|
| 114 | + save to "output_results.json" |
| 115 | +
|
| 116 | +The results of the refinement will be saved to a file |
| 117 | +named ``output_results.json``. |
| 118 | + |
| 119 | +6. List variables to be refined. |
| 120 | + |
| 121 | +.. code-block:: text |
| 122 | +
|
| 123 | + variables: |
| 124 | + --- |
| 125 | + - G1.a: 3.52 |
| 126 | + - s0: 0.4 |
| 127 | + - G1.Uiso_0: 0.005 |
| 128 | + - G1.delta2: 2 |
| 129 | + - qdamp: 0.04 |
| 130 | + - qbroad: 0.02 |
| 131 | + --- |
| 132 | +
|
| 133 | +Only variables listed in this section will be refined during the |
| 134 | +execution of the macro, and the variables will also be refined in that order. |
| 135 | +Variables with initial values specified here will be used as the |
| 136 | +starting point for the refinement. |
| 137 | + |
| 138 | +.. note:: |
| 139 | + The naming of variables follows the format |
| 140 | + ``structure_identifier.parameter``, |
| 141 | + ``profile_parameter``, or |
| 142 | + ``equation_parameter``. |
| 143 | + |
| 144 | + For parameters belonging to a specific atom in the parameter, |
| 145 | + the naming follows the format ``structure_identifier.parameter_atomindex``. |
| 146 | + e.g. ``G1.Uiso_0`` here refers to the Uiso parameter of the first atom in |
| 147 | + the structure ``G1``. |
| 148 | + |
| 149 | + For constrained parameters, it will use the first parameter in the |
| 150 | + constraint. e.g. Here, lattice parameter ``a=b=c``, |
| 151 | + and ``Usio_0=Uiso_i, i=1,2,3``, ``a`` and ``Uiso_0`` are used as the |
| 152 | + reference variables. |
| 153 | + |
| 154 | +.. _agentify: |
| 155 | +Use ``agentify`` to deploy agent skills ``diffpy.cmi`` |
| 156 | +------------------------------------------------------ |
| 157 | + |
| 158 | +The ``agentify`` application allows users to deploy agentic skills in the |
| 159 | +local environment. To use this application, run: |
| 160 | + |
| 161 | +.. code-block:: bash |
| 162 | +
|
| 163 | + diffpy.app agentify |
| 164 | +
|
| 165 | +``claude`` and ``codex`` agent skills are supported, and ``claude`` is used |
| 166 | +by default. To specify the agent skill, use the ``--agent`` option: |
| 167 | + |
| 168 | +.. code-block:: bash |
| 169 | +
|
| 170 | + diffpy.app agentify --agent codex |
| 171 | +
|
| 172 | +To deploy the agentic skill to the system directory, use the ``--system`` flag: |
| 173 | + |
| 174 | +.. code-block:: bash |
| 175 | +
|
| 176 | + diffpy.app agentify --system |
| 177 | +
|
| 178 | +To update the existing ``diffpy.cmi`` agentic skill, use the ``--update`` flag: |
| 179 | + |
| 180 | +.. code-block:: bash |
| 181 | +
|
| 182 | + diffpy.app agentify --update |
0 commit comments