Trace: • t

# t

**[ temperature !E]…**

**[***move_to_the_next_temperature_regardless_of_the_change_in_rwp***]**

**[***save_values_as_best_after_randomization***]**

**[***use_best_values***]**

**[***do_processes***]**

A temperature regime has no affect unless the reserved parameter name T is used in *val_on_continue* attributes, or, if the following temperature dependent keywords are used:

*randomize_on_errors*automatically determines parameter displacements without the need for *rand_xyz*or *val_on_continue*. It performs well on a wide range of problems.

The reserved parameter T returns the current temperature and it can be used in equations and in particular the *val_on_continue* attribute. The first *temperature* defined becomes the starting temperature; subsequent *temperature*(s) become the current temperature.

If _{} increases relative to a previous cycle then the temperature is advanced to the next *temperature*. If _{} decreases relative to previous temperatures of lesser values then the current temperature is rewound to a previous temperature such that its previous is of a greater value.

*move_to_the_next_temperature_regardless_of_the_change_in_rwp* forces the refinement to move to the next temperature regardless of the change in Rwp from the previous temperature.

*save_values_as_best_after_randomization* saves the current set of parameters and gives them the status of “best solution”. Note, this does not change the global “best solution” which is saved at the end of refinement.

*use_best_values* replaces the current set of parameters with those marked as “best solution”.

*do_processes* executes any *swap_sites* or *try_site_patterns* processes.

The temperature regime as defined in the macro Auto_T is sufficient for most problems.

A typical temperature regime starts with a high value and then a series of annealing temperatures, for example:

temperature 2

move_to_the_next_temperature_regardless_of_the_change_in_rwp

temperature 1

temperature 1

temperature 1

If the current temperature is the last one defined (the fourth one), and _{} decreased relative to the second and third *temperature*s, then the current temperature is set to the second temperature.

The current temperature can be used in all equations using the reserved parameter T, for example:

x @ 0.123 val_on_continue = Val + T Rand(-.1, .1)

The following temperature regime will allow parameters to randomly walk for the first temperature. At the second temperature the parameters are reset to those that gave the “best solution”.

temperature 1

temperature 1 use_best_values

temperature 1

temperature 1 use_best_values

temperature 1

temperature 10

save_values_as_best_after_randomization

move_to_the_next_temperature_regardless_of_the_change_in_rwp

Note, that when a “best solution” is encountered the temperature is rewound to a position where the temperature decreased. For example, if the R_{WP} dropped at lines 2 to 5 then the next temperature will be set to “line 1”.

The following will continuously use the “best solution” before randomisation. This particular temperature regime has a tendency to remain in a false minimum.

temperature 1 use_best_values

**[ th2_offset E]…**

Used for applying 2q corrections to phase peaks. The following example applies a sample displacement correction:

th2_offset = -2 Rad © Cos(Th) / Rs;

*th2_offset* is used for example in the Zero_Error and Specimen_Displacement macros.

**[ try_site_patterns $sites [num_patterns_at_a_time #] ]…**

*try_site_patterns* performs an exhaustive search of all possible cation configurations where the cations in question is identified by $sites. *num_patterns_at_a_time* defines the number of patterns to process at any one time. Outline of the algorithm:

While *try_site_patterns* processes still to be processed {

k = 0

Do

Change the cation configuration according to *try_site_patterns*

Find the local minimum of _{}

If _{}(k+1) > _{}(k) then reset site positions

k = k + 1

While _{}(k+1) > _{}(k) or *k* < *num_patterns_at_a_time*

}

The number of possible cation configurations determines the approximate magnitude of a structure determination problem. A structure consisting of N_{A} cation sites of species A and N_{B} cation sites of species B has, for a particular set of cation positions, a number of possible configurations N_{AB} calculated as follows:

N_{AB} = ^{(NA+NB)}C_{NB} / N_{B}!

where the notation ^{u}C_{v}=(u-0)(u-1)(u-2)…(u-(v-1)) has been used. Thus for N_{A}=3 and N_{B}=4 we have N_{AB}=(7 6 5 4)/(4 3 2 1)=N_{BA}=(7 6 5)/(3 2 1)=35. The number of configurations N_{ABD} for and additional set of cation sites of species D becomes:

N_{ABD} = N_{AB} (^{(NA+NB+NDD)}C_{ND} / N_{D}! )

An additional two D sites, or, N_{A}=3, N_{B}=4 and N_{D}=2 gives and N_{ABD}=1260. Thus the number of configurations quickly becomes prohibitive for an exhaustive search.

Here is an example of using *try_site_patterns* on three Ca sites and two Zr sites:

str…

site Ca…

site Ca…

site Ca…

site Zr…

site Zr…

*try_site_patterns* “Ca Zr” *num_patterns_at_a_time* 3

N_{CaZr}=10 and thus *try_site_patterns* will cycle through the 10 patterns searching for a reduction in _{}.