# This is a template file for RIETAN-FP for angle-dispersive X-ray and neutron
# diffraction.

# Throughout this file, 'hoge' means the metasyntactic variable that should
# be replaced by the common string consisting of 62 alphanumeric characters
# (A--Z, a--z, and 0--9) plus '_' (underscore).

# Many comments are sprinkled in this file for beginners.  Power users may
# delete part of them to shorten it.  Addition of memorandums is also fine.
# Comments can be input in the following manner:

# (1) # comment
# (2) ! comment
# (3) Comment {
# (4) } comment
# (5) Variable name = value: comment
# (6) Variable name = value! comment

# Form (1) may in input from the middle of a line.  On the other hand, '!' must
# be the first character except for a space in form (2), which is used as a
# bookmark in the RIETAN-FP-VENUS assistance environment.  Lines with top
# characters of '#' and '!', or forms (3) and (6) are regarded as comment lines
# as a whole.  Form (3), which is usually used in combination with form (4), is
# optional; that is, it is a mere comment line without any effect during refinement.
# Form (4) is used to indicate the end of a series of input lines.  Variable names
# in forms (5) and (6) should appear only once in one file.  The first character
# of an integer variable should be I, J, K, L, M, or N whereas that of a real
# variable must be capital letters other than these characters: A-H and O-Z.

# Lines, "Variable name = value", without any comments may be also input. In this
# case, variable names and their values are always read by RIETAN-FP, of course.

# Input data excluding a comment part must be placed up to column 80.  A line,
# which is inadequate to contain the whole data, may be split into two or more
# lines.

# For If and Select blocks, refer to 17.3.5 to 17.3.7 in RIETAN-FP_manual.pdf and
# Sect. 2 in "On New Features in "Multi-Purpose Pattern-Fitting System RIETAN-FP."

! Titles

Ni_20210410

! Radiation (NBEAM)

NBEAM = 0! Neutron powder diffraction.
NBEAM = 1! Conventional X-ray powder diffraction with characteristic X rays.
NBEAM = 2: Synchrotron X-ray powder diffraction.

! Analytical method

NMODE = 0: Rietveld analysis of powder diffraction data.
NMODE = 1! Calculation of powder diffraction intensities (plus simulation).
NMODE = 2! Total-pattern fitting where structure factors are fixed at Fc(MEM)'s.
NMODE = 3! The same as NMODE = 2 but refine |Fc|'s for relaxed reflections.
NMODE = 4! Conventional Le Bail analysis.
NMODE = 5! Le Bail analysis using a partial structure.
NMODE = 6! Individual profile fitting.

NPRINT = 0! Minimal output.
NPRINT = 1! Standard output including a reflection list.
NPRINT = 2! Detailed output including xdc.gpd to plot f' and f'' against lamdba.
NPRINT = 0

! NBEAM

Select case NBEAM
case 0
  ! =0: Neutron PD
   XLMDN = 1.5401: Neutron wavelength/Angstrom.
   RADIUS = 0.5: Radius/cm of the cylindrical cell.
   ABSORP =  1.0! Positive --> Density/g.cm-3 of the sample.*
   ABSORP =  0.0: Zero --> Neglect absorption.
   ABSORP = -1.0! Negative --> -(Linear absorption coefficient)*(radius).
   # * Calculated from the inner diameter, height, and mass of the sample.
case 1
  ! =1: X-ray PD
   NTARG = 1! Ag K_alpha radiation.
   NTARG = 2! Mo K_alpha radiation.
   NTARG = 3! Cu K_beta radiation.
   NTARG = 4: Cu K_alpha radiation.
   NTARG = 5! Co K_alpha radiation.
   NTARG = 6! Fe K_alpha radiation.
   NTARG = 7! Cr K_alpha radiation.

   R12 = 0.5: R12 = Intensity(K_alpha2)/Intensity(K_alpha1) for K_alpha radiation, and R12 = 0.0 for Cu K_beta radiation.#1
   CTHM1 = 0.7998: (cos(2*alpha))**n for the monochromator.#2
   #1: Because Johansson-type monochromators are fairly expensive, Cu K_beta radiation obtained
   #   with a curved graphite monochromator is sometimes used.
   #2: alpha: Bragg angle of the monochromator.  CTHM1 = 1.0 if no monochromator is installed.

   NSURFR = 0: Do not correct for surface roughness.
   NSURFR = 1! Correct for surface roughness by combining NSURFR = 2 and 3.
   NSURFR = 2! Correct for surface roughness with Sparks et al.'s model.
   NSURFR = 3! Correct for surface roughness with Suortti's model.
   NSURFR = 4! Correct for surface roughness with Pitschke et al.'s model.
   NSURFR = 5! Correct for surface roughness with Sidey's model.

   NTRAN = 0: Bragg-Brentano geometry (conventional divergence slit).
   NTRAN = 1! Bragg-Brentano geometry (automatic divergence slit*).
   NTRAN = 2! Transmission geometry (e.g., Guinier diffractometer).
   NTRAN = 3! Debye-Scherrer geometry.
   # * This slit gives variable divergence angles and a fixed irradiation width.

   Select case NTRAN
   case 1
      DSANG = 0.5: Angle/degree of the divergence slit at the minimum 2-theta.
      RGON = 185.0: Goniometer radius/mm.
      SWIDTH = 20.0: Irradiation width/mm for the sample.
   case 2
      PCOR1 = 0.5: Fraction of the perfect crystal contribution.
      SABS = 1.0: (Linear absorption coefficient)*(effective thickness).
   case 3
      XMUR1 = 0.0: (Linear absorption coefficient)*(radius).
   end select
case 2
  ! =2: Synchrotron X-ray PD
   XLMDX = 0.20616: X-Ray wavelength/Angstrom.
   PCOR2 = 0.05: I0(perpendicular)/I0(parallel). I0: incident intensity.
   # Refer to D.E. Cox, "Synchrotron Radiation Crystallography," ed by
   # P. Coppens, Academic Press, London (1992), p. 233.
   CTHM2 = 1.0: cos(2*alpha)**2 for the crystal monochromator (see above).
   XMUR2 = 0.0: (Linear absorption coefficient)*(radius).
end select

! Real chemical species

Select case NBEAM
case 0
   # Real neutral chemical species, amounts of substances, plus '/'.  Names of
   # 'real chemical species' are recorded in the database file asfdc.  The
   # amounts of substances are used to calculate absorption factors.  When
   # magnetic scattering is observed, attach '*' or '%' (virtual MUC) to
   # magnetic atoms, e.g., 'Fe*' and 'Mn%'.
   'Ni' 0.0/

   # Input chemical-species names (e.g., 'Fe2+' and 'Ni3+') and Lande splitting
   # factors, g, for magnetic atoms whose names are attached with '*' or '%'.
   # The total number of these lines equals those of magnetic atoms.
   # Note that g = 2.0 when <j2> = 0.

   # The following line is given for 'Co%':
   # 'Co3+'  2.0

   # '}' is unnecessary because the number of atoms attached with '*' and '%'
   #  has already been known.
case 1, 2
   # Real chemical species plus '/'.
   # Refer to the data base file asfdc for chemical species to be input here.
   'Ni' /

   If NBEAM = 2 or NTARG = 3 then
      # Input X-ray dispersion corrections, f' and f'', for real chemical species.
      # Neither '/' nor '}' is required because the number of the real chemical species
      # has already been known. If f' = f'' = 0.0, they are calculated with xdc.bin.
      0.0  0.0
   end if
end select

! Virtual chemical species

# When a site is occupied by two or more chemical species as in solid
# solutions, supposing an 'virtual' chemical species where these chemical
# species are mixed with each other in definite amount-of-substance
# fractions (total = 1) serves to decrease the total number of sites.
# Of course, such virtual species can be used only when their occupancies
# are fixed.  Input one virtual species plus '/' per line and '}' (plus comment)
# in the last line in the following way:

# Virtual chemical species
# 'M1' 'Ba' 0.633 'Nd' 0.367 / # Metal on the rock-salt layer
# 'M2' 'Nd' 0.675 'Ce' 0.325 / # Eight-coordinated atom in the fluorite block
#} End of virtual chemical species.

# 'M1' and 'M2' are names of virtual chemical species, 'Ba', 'Nd,' and 'Ce' are
# names of real chemical species input above, and numbers are amount-of-
# substance fractions of constituent elements.  For the above species, Refer to
# F. Izumi et al., Physica C 160 (1989) 235.
# When no virtual species are used, all the lines must be commented out.

Data concerning crystalline phases contained in the sample {

! Phase(s)
  ! Phase #1

PHNAME1 = 'New structure': Phase name (CHARACTER*68).

VNS1 = 'A-225': (Vol.No. of Int.Tables: A or I)-(Space group No)-(Setting No).

# A Hermann-Mauguin symbol included in Spgr.daf under folder RIETAN_VENUS.
HKLM1 = 'F m -3 m ': hkl and multiplicities are generated from the Hermann-Mauguin symbol.#1
HKLM1 = 'F m -3 m*'! Crystal-structure data based on the Hermann-Mauguin symbol are standardized.#2
#1 The use of crystal-structure data standardized with STRUCTURE TIDY is recommended.
#2 '*' is attached to the tail of the Hermann-Mauguin symbol on standardization of
#  crystal data with STRUCTURE TIDY, which is also possible with VESTA.

If NBEAM >= 1 then
   LPAIR1 = 0: No Friedel pairs (hkl & -h-k-l) are generated.
   LPAIR1 = 1! Friedel pairs (hkl & -h-k-l) are generated.
   # Set at 0 in a centrosymmetric space group.  Note that in 24 centrosymmetric
   # space groups, e.g., origin choice 1 for Pnnn (No. 48), descriptions with
   # points of higher symmetry as origin are also provided.  Setting this value
   # at 0 in the early stage of Rietveld analysis for a concentrosymmetric compound
   # increases the calculation speed with lowering accuracy of structure factors.
end if

INDIV1 = 0! The overall isotropic atomic displacement parameter is input.
INDIV1 = 1: Atomic displacement parameters are assigned to all the sites.
# Neither B's nor beta_ij's are input if INDIV1 = 0.  Input zero for the
# overal isotropic atomic displacement parameter, Q, when INDIV1 = 1.

IHA1 = 0: \
IKA1 = 2:   --> Anisotropic-broadening axis, ha, ka, la.
ILA1 = 1: /
# They are dummies when parameters related to anisotropic profile
# broadening are set at null.

# Three preferred-orientation vectors, hp, kp, and lp, in the modified March-Dollase
# function which is a linear combination of three March-Dollase functions.
# If hp = kp = lp = 0, no preferred-orientation is corrected for that vector.

# Each preferred-orientation vector should be set in such a way that it is
# a reciprocal-lattice vector, hpa* + kpb* + lpc*, perpendicular to a cleavage
# plane for a plate crystal and parallel with an extension direction for a
# needle-like crystal.

IHP1 = 0: \
IKP1 = 2:   --> Preferred-orientation vector, hp1, kp1, lp1.
ILP1 = 1: /

IHP2 = 0: \
IKP2 = 0:   --> Preferred-orientation vector, hp2, kp2, lp2.
ILP2 = 0: /

IHP3 = 0: \
IKP3 = 0:   --> Preferred-orientation vector, hp3, kp3, lp3.
ILP3 = 0: /

# If two or more phases are included in the sample, repeat their date below.
# Note that the same label should not be input repeatedly.

# Place '}" (+ comment) after the input of information on all the phases.
} End of information about phases.

! Profile function

NPRFN = 0! Pseudo-Voigt function of Thompson et al.*
NPRFN = 1! Split pseudo-Voigt function of Toraya.**
NPRFN = 2! Modified split pseudo-Voigt function*** for relaxed reflections.
NPRFN = 3! Split Pearson VII function of Toraya.**
#   * P. Thompson et al., J. Appl. Crystallogr. 20 (1987) 79.
#  ** H. Toraya, J. Appl. Crystallogr., 23 (1990) 485.
# *** FWHM(Lorentz) <> FWHM(Gauss).  The split pseudo-Voigt function is
#     applied for the other reflections.  Refer to the following paper:
#     F. Izumi and T. Ikeda, Mater. Sci. Forum, 321-324 (2000) 198.
NPRFN = 0

Select case NPRFN
case 0
   NASYM = 0! Made asymmetric according to the procedure of Finger et al.*
   NASYM = 1! Made asymmetric according to the procedure of Howard.**
   #  * L. W. Finger et al., J. Appl. Crystallogr. 27 (1994) 892.
   # ** C. J. Howard, J. Appl. Crystallogr. 15 (1982) 615.
   NASYM = 1
case default
   # Selection of the peak-shift function.
   # t0 - t3: Peak-shift parameters; x: 2-theta.
   NSHIFT = 0! t0.
   NSHIFT = 1! t0 + t1*cos(x) + t2*sin(x) + t3*tan(theta).
   NSHIFT = 2! t0 + t1*x + t2*x^2 + t3*x^3.
   NSHIFT = 3! t0 + t1*tan(theta) + t2*(tan(theta))^2 + t3*(tan(theta))^3.
   NSHIFT = 4: Legendre polynomials where 2-theta is normalized as -1 to 1.
   NSHIFT = 5! Legendre polynomials where tan(theta) is normalized as -1 to 1.
end select

# Labels (CHARACTER*25), parameters, A(I), to calculate diffraction intensities,
# and refinement identifiers, ID(I).  ID(I)'s are input without inserting any
# spaces between them only when NMODE = 0 (no problem even if they are input
# when NMODE = 1).

# In what follows, PPP and SPP denote a primary profile parameter and a
# secondary profile parameter, respectively.  For example, when calculating
# the FWHM, H, with the equation H = [U(tan(theta)**2 + Vtan(theta) + W]^0.5,
# H is a PPP, the FWHM parameters U, V, and W are SPPs.  In conventional
# Rietveld analysis, SPP's which are common to the whole 2-theta range are
# refined whereas PPPs are locally refined for relaxed reflections.

# ID(I) = 0: Fix parameter A(I) at the value input by the user.
# ID(I) = 1: Refine parameter A(I).
# ID(I) = 2: Impose a constraint to parameter A(I).
# ID(I) = 3: Fix a PPP at the value calculated from SPP's.
# If A(I) is set at zero by the user, A(I) is calculated from the SPP's in each
# cycle. In this case, if A(I) should actually be fixed at zero, input a value
# which is nearly zero, e.g., 10^(-15).

# Relations between ID(I)'s, NPRFN, and partial profile relaxation:
# (1) Partial profile relaxation cannot be used when NPRFN = 0.
# (2) ID(I)'s are 1-3 when NPRFN = 1-3 with partial profile relaxation.

! Label, A(I), ID(I)

Label, A(I), and ID(I) now starts here {

  ! Phase-independent data

# Peak-shift parameters.
# NPRFN = 0: Z, Ds, Ts & dummy1 (Ds = Ts = 0 in neutron diffraction).
# NPRFN > 0: t0, t1, t2 & t3.

Select case NPRFN
case 0
SHIFT  7.30713E-3  0.0  0.0  0.0  1000
case default
SHIFTN  -3.50141E-3  0.0  0.0  0.0  1000
end select
 
# Surface-roughness parameters.
ROUGH  0.0  0.0  0.0  0.0  0000
 
# Background parameters, b_j (j = 0-11).
# In the early stage of Le Bail anslysis and hybrid pattern decomposition, it is
# to set NRANGE at 2 and fix background intensities at those recorded in hoge.bk
# case, background parameters input below are ragarded as dummies.  In the last
# refining several b_j's with NRANGE = 2 and initial b_j values of b0 = 1.0 and
# is recommended.
BKGD  0 0 0 0 0 0 0 0 0 0 0 0  111111111111
 
  ! Partial profile relaxation
 
# PPP's of relaxed reflections (input as required.  May be lacking).
# Format of each label: PPPn_h.k.l (n: phase number, hkl: diffraction index).
 
# PPP's refined in relaxed reflections:
# NPRFN = 1 (split pseudo-Voigt function): W, A, eta_L, eta_H.
# NPRFN = 2 (modified split pseudo-Voigt function): W1, W2, A, eta_L, eta_H.
# NPRFN = 3 (split Pearson VII function): W, A, mL, mH.
 
#PPP1_1.4.-1  4.13317E-2  1.07098  0.484802  0.341769  1111
 
  ! Phase #1
    ! Scale factor
 
SCALE  4.92929E-7  1
 
    ! Profile parameters
 
If NPRFN = 0 and NASYM = 1 then
 
   # TCH's pseudo-Voigt function made asymmetric by Howard's method.
 
   # FWHM parameters of the Gauss function, U, V, W, and P.
#   GAUSS01  1.539644E-3  -1.017905E-3  3.431561E-4  0.0  0000
GAUSS01  1.48547E-2  -4.65611E-4  3.90206E-5  0.0  1110
 
   # FWHM parameters of the Lorentz function, X, Xe, Y, and Ye.
#   LORENTZ01  7.643094E-3  -8.061990E-3  2.634492E-2  4.593892E-2  0000
LORENTZ01  -1.45465E-3  -1.46631E-3  0.279026  -8.39754E-2  1111
 
   # Asymmetry parameter, As, plus five dummies.
#   ASYM01  2.878251E-4  0.0  0.0  0.0  0.0  0.0  100000
ASYM01  -1.65863E-3  0.0  0.0  0.0  0.0  0.0  100000
 
   # Mixing coefficient, zeta, and S_hkl
ANISTR01  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
          0.0  0.0  0.0  0.0  0000000000000000
 
else if NPRFN = 0 and NASYM = 0 then
 
   # TCH's pseudo-Voigt function made asymmetric by Finger et al.'s method.
 
   # FWHM parameters of the Gauss function, U, V, W, and P.
   GAUSS00  1.539644E-3  -1.017905E-3  3.431561E-4  0.0  0110
 
   # FWHM parameters of the Lorentz function, X, Xe, Y, and Ye.
   LORENTZ00  7.643094E-3  -8.061990E-3  2.634492E-2  4.593892E-2  1010
 
   # Asymmetry parameters, rs and rd, plus four dummies.
   ASYM00  1.492190E-2  1.63252E-2  0.0  0.0  0.0  0.0  110000
 
   # Mixing coefficient, zeta, and S_hkl
   ANISTR00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000000000000000
 
else if NPRFN = 1 or NPRFN = 2 then
 
   # Non-relaxed reflections: split pseudo-Voigt function.
   # Relaxed reflections: Modified split pseudo-Voigt function.
 
   # FWHM parameters, U, V, and W, plus a dummy.
FWHM12  7.08774E-3  -1.80404E-3  1.76346E-3  0.0  1110
 
   # Asymmetry parameters, a0, a1, and a2 plus a dummy.
ASYM12  1.12895  4.87946E-2  -4.45456E-3  0.0  1110
 
   # Decay parameters, eta_L0, eta_L1, eta_H0, and eta_H1.
ETA12  0.335727  0.395366  0.108661  0.553913  1111
 
   # Anisotropic-broadening parameters, Ue and Pe.
ANISOBR12  0.0  0.0  00
 
   # Dummy data
DUMMY12  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
         0.0  0.0  0.0  0000000000000000
 
else if NPRFN = 3 then
 
   # Split Pearson VII function
 
   # FWHM parameters, U, V, W, plus a dummy.
   FWHM3  5.16861E-3  -1.8595E-3  1.5144E-3  0.0  1110
 
   # Asymmetry parameters, a0, a1, and a2, plus a dummy.
   ASYM3  0.839013  -2.98729E-2  6.771E-4  0.0  1110
 
   # Decay parameters, eta_L0, eta_L1, eta_H0, and eta_H1.
   M3   0.436866  0.556523  0.240115  0.374005  1111
 
   # Anisotropic-broadening parameter, Ue and Pe.
   ANISOBR3  0.0  0.0  00
 
   # Dummy data
   DUMMY3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000000000000000
 
end if
 
    ! Preferred orientation
 
# Six preferred-orientation parameters, f1, r1, f2, r2, f3, and r3 are input.
# Usually, f1 is fixed at 1.0 while r1 is refined with f2 = r2 = f3 = r3 = 0.0
 
# If the initial r1 value is far from the true one, no convergence may be attain
# Then, Rietveld refinements where r1 is fixed in such a way that r1 = 1.0, 0.95
# 0.85, ..... are executed to obtain r1 giving the lowest Rwp. Finally, the resu
# r1 parameter is used as an initial value and refined.
PREF  1.0  1.0  0.0  0.0  0.0  0.0  000000
 
    ! Lattice parameters & Q
 
# Lattice parameters, a, b, c, alpha, beta, & gamma.
# Overall isotropic atomic displacement parameter, Q.
CELLQ  3.52236  3.52236  3.52236  90.0  90.0  90.0  0.0  1000000
 
    ! Structure parameters
 
# Label/(chemical species name), occupancy (g) , fractional coordinates
# (x,y,z), isotropic atomic displacement parameter (B), ID(I)'s.
# One label is given to each site.  'Chemical species' include virtual ones
# (should not enclosed by ' ').  On the calculation of anisotropic atomic
# displacement parameters, input beta_11, beta_22, beta_33, beta_12,
# beta_13 and beta_23.  If a dummy '+' is input just before the value of B,
# RIETAN will determine the corresponding beta_ij.  Of course, six ID(I)'s
# must be input in this case.
 
Ni/Ni  1.0  0.0  0.0  0.0  0.241647  00001
} End of lines for label/species, A(I), and ID(I)

# If two or more phases are included in the sample, repeat the input of
# parameters (scale factor or later) after structure parameters in the
# previous phase.  Do not enter labels that have already been input.

! Linear constraints

If NMODE <> 1 then
# Input linear constraints for parameters with ID(I) = 2.  A parameter with
# ID(I) = 2 is place at the left side, and equations to calculate it from other
# parameters with ID = 1.  "Linear" means that the equation is linear with
# respect to parameters contained in the right side.  Linear constraints can
# be imposed on PPPs, SPPs, and structure parameters.  In the case of SPPs,
# the linear constraints are used to set SPPs for two or more phases equal
# to each other.  Refer to the user's manual for the method of describing
# linear constraints.

# For example, linear constraints imposed among anisotropic atomic displacement
# parameters, beta_ij, are described in the following ways:
# A(X,B22)=A(X,B11) #5
# A(X,B22)=A(X,B11); A(X,B23)=A(X,B13) #6
# A(X,B22)=A(X,B11); A(X,B23)=-A(X,B13) #7
# A(X,B22)=A(X,B11) #8
# A(X,B33)=A(X,B22) #9
# A(X,B33)=A(X,B22); A(X,B13)=A(X,B12) #10
# A(X,B33)=A(X,B22); A(X,B13)=-A(X,B12) #11
# A(X,B33)=A(X,B22) #12
# A(X,B12)=0.5*A(X,B22) #13
# A(X,B12)=0.5*A(X,B22) #14
# A(X,B12)=0.5*A(X,B22); A(X,B23)=2.0*A(X,B13) #15
# A(X,B22)=A(X,B11); A(X,B12)=0.5*A(X,B11) #16
# A(X,B22)=A(X,B11); A(X,B33)=A(X,B11) #17
# A(X,B22)=A(X,B11); A(X,B33)=A(X,B11); A(X,B13)=A(X,B12); A(X,B23)=A(X,B12) #18
# where 'X' is a label (site name).  Please replace it with another label.
# Comments ('#'+integer) at the tails of these lines denote reference numbers in
# W. J. A. M. Peterson and J. H. Palm, Acta Crystallogr. 20 (1966) 147.

Linear constraints begin {
#A(C2,B)=A(C1,B);A(C3,B)=A(C1,B);A(C4,B)=A(C1,B);A(C5,B)=A(C1,B);A(C6,B)=A(C1,B)
#A(C7,B)=A(C1,B);A(C8,B)=A(C1,B);A(C9,B)=A(C1,B);A(C10,B)=A(C1,B)
#A(N2,B)=A(N1,B);A(N3,B)=A(N1,B);A(N4,B)=A(N1,B);A(N5,B)=A(N1,B);A(N6,B)=A(N1,B)
A(H2,B)=A(H1,B);A(H3,B)=A(H1,B);A(H4,B)=A(H1,B);A(H5,B)=A(H1,B);A(H6,B)=A(H1,B)
A(H7,B)=A(H1,B);A(H8,B)=A(H1,B);A(H9,B)=A(H1,B);A(H10,B)=A(H1,B)
A(H11,B)=A(H1,B);A(H12,B)=A(H1,B);A(H13,B)=A(H1,B);A(H14,B)=A(H1,B)
A(H15,B)=A(H1,B);A(H16,B)=A(H1,B)

# Place '}' + comment after the input of all the linear constraints.
# When no constraints are given, comment out them, including '}.'
} Linear constraints end

end if

! Voxel numbers

If NMODE <> 6 then
   # Unless MEP analysis, Fourier synthesis, or MEM analysis is carried out,
   # set NVOXA, NVOXB, and NVOXC at 0; then, these three are regarded as dummy data.
   NVOXA =  72: Number of voxels along the a axis.
   NVOXB =  72: Number of voxels along the b axis.
   NVOXC =  72: Number of voxels along the c axis.
end if

! PyAbstantia
If NMODE = 1 then
   NPYABST = 0: No input file for PyAbstantia is output.
   NPYABST = 1! BVS.inp for the BVS mode of PyAbstantia is output.
   NPYABST = 2! BVEL.inp for the BVEL mode of PyAbstantia is output.

   # The following Select case block was written for LiCoO2.
   # Rewrite it when dealing with other compounds.
   Select case NPYABST
   case 1
      # Valence of the mobile ion.
      1

      # Counter ion, Ro, and B of the mobile ion (refer to bvparm2016.cif).
      O  1.466  0.37
      } # End of counter ions
   case 2
      # H, Li, Na, or Mg must be included in real chemical species.

      # Formal charges of the elements
      1.0  3.0  -2.0

      # Covalent radii
      # https://en.wikipedia.org/wiki/Covalent_radius
      # https://www.webelements.com/periodicity/covalent_radius/
      # http://doi.org/10.1039/B801115J
      1.34  1.26  0.73
   end select
end if

NCUT = 0! The profile range for relaxed reflections is determined by RIETAN.
NCUT = 1! The profile range for relaxed reflections is input by the user.
NCUT = 0
# NCUT = 0 when NPRFN = 0.

If NCUT = 1 then
   # 2-theta ranges for the profiles of relaxed reflections in the same order
   # as PPPn_h.k.l+PPP.  The total number of 2-theta pairs is equal to that of
   # the PPPn_h.k.l+PPP+ID lines. in the same order.  No '}' is necessary
   # because the number of the relaxed reflections has been already known.
    5.10    9.40
   11.00   14.10
   18.20   21.80
   19.40   24.10
   21.60   23.40
end if

If NMODE <> 1 then

! Diffraction data

   # NMODE = 0, 2-6: pattern fitting (Rietveld analysis, Le Bail analysis, MPF, etc.)

   NEXC = 0! Parameters are refined using all the data points.
   NEXC = 1: Parameters are refined by excluding part of the data points.

   If NEXC = 1 then
      2-theta range not to be used for the refinement {
        0.00    2.2
      22.0  60
      } End of excluded 2-theta ranges.
   end if

   NINT =  0! RIETAN format.
   NINT =  1: General (X-Y) format.
   NINT =  2! IGOR text file.
   NINT =  3! FVFM (Fully Variable ForMat).
   NINT =  4! Standard DBWS format.
   NINT =  5! DBWS format for multiple detectors.
   NINT =  6! Free format.
   NINT =  7! GSAS format.
   NINT =  8! HRPD (JAERI, JRR-3M) formats. Two types are supported.
   NINT =  9! RIGAKU RINT2000 ASCII format.
   NINT = 10! MAC Science format.
   NINT = 11! General-3 format.
   NINT = 12! PANalytical XML format.

! Backgrounds

   NRANGE = 0: Refine background parameters.
   NRANGE = 1! Fix backgrounds at (interpolated) values at specified 2-theta's.
   NRANGE = 2! Fix backgrounds of all the points at values in hoge.bkg.
   NRANGE = 3! Background = (background in hoge.bkg) * (Legendre polynomials).

   # When NRANGE > 0, 2-theta and background pairs are read in from hoge.bkg.
   # (1) NRANGE = 1
   # When a background is zero, it is set at a smoothed value at that data point.
   # Backgrounds at other data points are fixed at interpolated values.  Such a
   # manner is useful for the analysis of diffraction patterns where the number of
   # reflections are relatively small and the background curve is complex, for
   # example, having humps.
   # List-directed READ statement in RIETAN-FP: READ(4,*) (X(J),Y(J), J=1,100).
   # That is, we can input up to 100 diffraction points.  To show the end of data
   # points, place '/' after the last data point.
   # (2) NRANGE = 2
   # Input 2-theta and background pairs whose total number should be equal to
   # that of observed diffraction intensities in hoge.int.
   # List-directed READ statement in RIETAN-FP:
   # READ(8,*,END=9) (DEG(J),BG(J), J=1,NP)
   # (3) NRANGE = 3
   # This composite background function is particularly useful for the Debye-
   # Scherrer geometry where samples are charged in capillaries, which makes the
   # shape of the background complex.

   # A background file, hoge.bgr, created with WinPLOTR can be converted into
   # hoge.bkg (see 3.12.3 in RIETAN-FP_manual.pdf).

   If NRANGE >= 2 then
      # Note that the following three data are ineffective if hoge.bkg or hoge.bgr exists.
      NPICKUP = 20: Intensity data are taken out in every NPICK-th points for background estimation.
      NREPEAT = 40: Repeating time for background subtraction.
      CURVATURE = 0.0: A constant to cosider the curvature of the background.
   end if
else
   # NMODE = 1: Simulation of a diffraction pattern.

   DEG1 = 10.0: Minimum 2-theta in the calculated (simulated) pattern.
   DEG2 = 60.0: Maximum 2-theta in the calculated (simulated) pattern.
   USTP = 0.01: Step width/degree.
end if

! Profile cutoff

# PC: A constant to determine a 2-theta range for calculating profiles.
# PC < 1 ==> A region where the profile function exceeds peak intensity X PC.
#            If NPRFN = 0, PC < 1.
# PC > 1 ==> A region within peak position +/- FWHM*PC.
Select case NPRFN
case 0
   PC = 0.004
case 1
   PC = 10.00
case 2, 3
   PC = 7.00
end select

If NMODE = 1 then
   Go to *Graphs
end if

! Pattern decomposition

If NMODE = 4 then
   # Initial values of integrated intensities, |F|**2, for the 1st phase are
   NSFF = 0: estimated according to the Wilson statistics.
   NSFF = 1! input from hoge.ffi.
   NSFF = 2! all set at 100.0.

   If NSFF = 1 then
      NCONST = 0! Integrated intensities are varied during Le Bail analysis.
      NCONST = 1! Integrated intensities remain constant during Le Bail analysis.*
      # * |F|'s are calculated from final refined parameters.
      NCONST = 0
   end if

   CHGPC = 1.0: Cut-off is at first set at CHGPC*PC.*
   # * Restored when lattice or profile parameters are refined.

   NOPT = 0! No integrated intensities are refined after Le Bail analysis.
   NOPT = 1: Hybrid pattern decomposition where integrated intensities are refined after Le Bail analysis.

   If NOPT = 1 then
      MREG = 15: Maximum number of reflections in each group of overlapped reflections.
      RWID = 0.350: Integrated intensities of reflections with Delta.2-theta < RWID*FWHM are set equal.
      XMAX = 180.0: Integrated intensities are refined up to XMAX/degrees.
      WNEG = 1.E30: Weight to suppress negative integrated intensities.
   end if

   INCLH = 0: Output no reflections near 2-theta(max) to hoge.ffo for lack of partial observed intensities.
   INCLH = 1! Output reflections near 2-theta(max) to hoge.ffo despite partial lack of observed intensities.

   MEP = 0! No integrated intensities are improved by the maximum-entropy Patterson method.
   MEP = 1: Integrated intensities are improved by the maximum-entropy Patterson method.

   If MEP = 1 then
      # Element symbols and numbers of atoms in the unit cell.
      'C' 40.0 'N' 24.0 'S' 4.0 'H' 64.0 /

      FLAMBDAMEP = 0.005: Initial Lagrange multiplier.
            TMEP = 0.010: Coefficient, t, to adjust the Lagrangian multiplier.

      ISCIOMEP = 5700: Coefficient to adjust estimated standard uncertainties.
      MAXITERMEP = 999999: Maximum number of MEP iterations.
   end if
end if

! Least-squares method

NLESQ = 0! Marquardt method (recommended in most cases).
NLESQ = 1! Gauss-Newton method.
NLESQ = 2! Conjugate-direction method (stable but very slow).
NLESQ = 0

NESU = 0: Standard uncertainties are estimated by the conventional method.
NESU = 1! Standard uncertainties are estimated by Scott's method.*
# * Much larger standard uncertainties will result in comparison with NESU = 0.

Select case NLESQ
case 0, 1
   NAUTO = 0! Refine all the variable parameters simultaneously.
   NAUTO = 1! Refine incrementally (specify variable parameters in each cycle).
   NAUTO = 2! Refine incrementally (automatic; recommended in most cases).
   NAUTO = 3! In addition to NAUTO = 2, check convergence to the global min.
   NAUTO = 2
   # Set NAUTO at 2 usually and at zero near the convergence.

   NCYCL = 50: Maximum number of cycles.
   CONV = 0.0001: Small positive number used for convergence judgement.
   NCONV = 6: Number of cycles used for convergence judgement.

   NC = 0: No nonlinear restraints are imposed on geometric parameters.
   NC = 1! Nonlinear restraints are imposed on geometric parameters.

   TK = 650.0: Penalty parameter.
   FINC = 2.0: Factor by which TK is multiplied when TK is increased.

   Select case NAUTO
   case 1
      # Specify parameters to be refined in each cycle plus '/'.
      # In addition to absolute parameter numbers, "label,number/symbol" may be
      # used (Refer to user's manual).
      Parameters refined in each cycle {
      BKGD,1 BKGD,2 BKGD,3 BKGD,4 BKGD,5 BKGD,6 BKGD,7 BKGD,8 BKGD,9 BKGD,10
      BKGD,11 BKGD,12 SCALE,1 /
      CELLQ,1 CELLQ,2 CELLQ,3 CELLQ,5 /
      # Place '}' (+ comment) after the last cycle.
      } End of inputs for numbers of refinable parameters.
   case 3
      # Input data for the conjugate-direction method (used to check the
      # convergence at a local minimum).
      MITER = 10: Maximum number of iterations.
      STEP = 0.02: Coefficient to calculate the initial step interval.
      ACC = 1.0E-6: Small positive number used for convergence judgement.
   end select
case 2
   MITER = 6: Maximum number of iterations.
   STEP = 0.02: Coefficient to calculate the initial step interval.
   ACC = 1.0E-6: Small positive number used for convergence judgement.

   NC = 0: No nonlinear restraints are imposed on geometric parameters.
   NC = 1! Nonlinear restraints are imposed on geometric parameters.

   TK = 650.0: Penalty parameter.
end select

If NC = 0 or NMODE <> 0 then
   Go to *Update
end if

! Restraints

LSER = 0! Input site names for restrained bond lengths/angles.
LSER = 1! Input serial numbers of restrained bond lengths/angles in hoge.ffe.
LSER = 0

# Note: The following part until just before '*Update' consists of dummy data copied from Fapatite.ins.
Select case LSER
case 0
   LPAIR = 0! Input no pairs of site names, 'A' and 'B', for restrained A-B bond lengths.
   LPAIR = 1: Input pairs of site names, 'A' and 'B', for restrained A-B bond lengths.

   LTRIP = 0! Input no triplets of site names, 'A', 'B', and 'C', for restrained A-B-C bond angles.
   LTRIP = 1! Input triplets of site names, 'A', 'B', and 'C', for restrained A-B-C bond angles.
   LTRIP = 0

   If LPAIR = 1 then
      # Bond lengths between l_min and l_max are restrained.
      # 'A' and 'B' should not contain serial numbers.
      'A'  'B'  l_min  l_max  l_exp  Allowed dev.  Weight {
      'P'  'O'  1.3    1.7    1.50   0.08          0.0
      # Place '}' (+ comment) after the last restraint.
      } End of nonlinear restraints for bond lengths.
   end if

   If LTRIP = 1 then
      # Bond angles between phi_min and phi_max are restrained
      'A'  'B'  'C'   phi_min  phi_max  phi_exp  Allowed dev.  Weight {
      'O'  'P'  'O'   99.47    119.47   109.47   6.0           0.0
      # Place '}' (+ comment) after the last restraint.
      } End of nonlinear restraints for bond angles.
   end if
case 1
   # To specify nonlinear restraints, an input file for ORFFE, hoge.xyz,
   # must be created by inputting non-zero NDA (described below).  Then, ORFFE
   # is executed to output hoge.ffe, which is referred to learn serial
   # numbers for various interatomic distances and bond angles to enter them
   # in addition to their expected values and allowed deviations.
   # If hoge.ffe has already been created, it is not created at all.
   # Therefore, note that hoge.ffe must be wasted to make it again.

  ! on bond lengths and angles
   Ser. No.  Exp. value  Allowed dev.  Weight {
   # Place '}' (+ comment) after the last restraint.
   } End of nonlinear restraints on bond lengths/angles.
end select

LQUART = 0! Input no quartets of atoms related to restrained torsion angles.
LQUART = 1! Input quartets of atoms related to restrained torsion angles.
LQUART = 1

If LQUART = 1 then
   1      O1  O  0.48563  1.16145  0.75000 ( 0, 1, 1)+ y, -x+y, -z
   3      O3  O  0.25697  0.91812  0.93008 ( 0, 1, 1)+ y, -x+y, -z
   3      O3  O  0.25697  0.91812  0.56992 ( 0, 1, 0)+ y, -x+y, z+1/2
   2      O2  O  0.46981  0.87819  0.75000 ( 0, 1, 1)+ y, -x+y, -z
   # Exp. value  Allowed dev.  Weight
   71.0          0.2            0.015
   # Place '}' (+ comment) after the last restraint.
   } End of nonlinear restraints on torsion angles.
end if

*Update

! Update of hoge.ins

NUPDT = 0! Variable parameters (ID = 1, 2) in the input file remain unchanged.
NUPDT = 1! Variable parameters (ID = 1, 2) are updated in the packing mode.
NUPDT = 0
# When NUPDT = 1, parameters are updated by inserting two spaces between data.

*Graphs

! Graphs

# A graph to plot results of pattern fitting (NMODE <> 1) and simulation (NMODE = 1).
NPAT = 1: Output gnuplot files, hoge.plt and hoge.gpd, to plot a graph.
NPAT = 2! Output an Igor text file, hoge.itx, to plot a graph.
NPAT = 3! Output a RietPlot file, hoge.itx, to plot a graph (obselete).
# NPAT = 1 is higly recommended because gnuplot is multi-platform free software.

If NMODE <> 1 then
   # NMODE = 0, 2-6: pattern fitting (Rietveld analysis, Le Bail analysis, MPF, etc.)

   Select case NPAT
   case 1
  ! Gnuplot
      INDREF = 0: Output no profile intensities of individual reflections.
      INDREF = 1! Output profile intensities of individual reflections.

      LBG = 0: Plot no background.
      LBG = 1! Plot the background.

      LRES = 0: Plot Delta_y = (observed intensity - calculated intensity).
      LRES = 1! Plot Delta_y/(standard uncertainty).
      LRES = 2! Plot [Delta_y/(observed intensity)]/(standard uncertainty).*
      # * Refer to Eq. (1.13) in R. A. Young, "The Rietveld Method," p. 24.

       WIDTH = 24.5: Width/cm of the graph.
      HEIGHT = 13.0: Height/cm of the graph.

      YMIN = -1000: Minimum value for the y axis.
      YMAX = 10000: Maximum value for the y axis.
      YINC =  2000: Increment for ticks on the y axis.

      IVSIZE = 15: Size of numerical values for the x and y axes.
      ILSIZE = 17: Size of labels for axes.

      PSIZE = 0.35: Size of '+' marks representing observed intensities.
      TSIZE = 0.90: Length (in percent of the y-axis length) of tick marks to show peak positions.

      OFFSETD = -500: Offset for the residual curve.

      OFFSET1 = -300: Offset (nonzero) for tick marks (peak positions) for phase No. 1.
      # When other phases are contained, input offsets in the above way.
      / # Place '/' if the number of phases whose offsets are input is less than 16.

      MSCS = 0! No commands to draw a Williamson-Hall or Halder-Wagner plot are appended to hoge.plt.
      MSCS = 1! Commands to draw a Williamson-Hall plot are appended to hoge.plt as comment lines.
      MSCS = 2! Commands to draw a Halder-Wagner plot are appended to hoge.plt as comment lines.
      MSCS = 2

      POWER = 2.0: n in [beta(sample)]**n = [beta(obs)]**n - [beta(instr)]**n.

      # You may also modify hoge.plt by an editor to replot refinement patterns.
   case 2
  ! Igor Pro
      IWIDTH = 800: Width of the graph.
      IHEIGHT = 400: Height of the graph.
      IYMIN = -30000: Minimum value for the y axis (default for zero).
      IYMAX = 175000: Maximum value for the y axis (default for zero).

      LBG = 0: Do not plot the background.
      LBG = 1! Plot the background.

      # Kind of a residual curve
      LDEL = 0: Plot Delta_y = (observed intensity - calculated intensity).
      LDEL = 1! Plot Delta_y/(standard uncertainty).
      LDEL = 2! Plot [Delta_y/(observed intensity)]/(standard uncertainty).*

      IOFFSETD = -18000: Offset for the residual curve.
      IPSIZE = 3: Length of tick marks to show peak positions.
      IFSIZE = 12: Size of numerical values attached to the x and y axes.
      ILSIZE = 14: Size of labels for axes.

      INDREF = 0: Do not output waves xrefl or yrefl.
      INDREF = 1! The profile of each reflection is output to waves xrefl and yrefl.

      IOFFSET1 = -3000: Offset for tick marks (peak positions) for the first phase.
      # When other phases are contained, input offsets in the above way.
      / # Place '/' if the number of phases whose offsets are input is less than 16.

      # You may also edit Igor procedures at the tail of hoge.itx with an editor.
   end select
else
   # NMODE = 1: Simulation of a diffraction pattern.

   Select case NPAT
  ! Simulation
   case 1
      WIDTH = 24.5: Width/cm of the graph.
      HEIGHT = 12.0: Height/cm of the graph.

      IVSIZE = 15: Size of numerical values for the x and y axes.
      ILSIZE = 17: Size of labels for axes.
   case 2
      IWIDTH = 800: Width of the graph.
      IHEIGHT = 400: Height of the graph.

      LBG = 0: Plot no background (fixed).

      IPSIZE =  3: Length of tick marks (peak positions).
      IFSIZE = 12: Size of numerical values attached to the x and y axes.
      ILSIZE = 14: Size of labels for axes.
   end select
end if

! hoge.inflip & hoge.exp

If NMODE <> 1 and NMODE <> 6 then
   NCF = 0: No input file, hoge.inflip, of superflip is output for charge flipping.
   NCF = 1! An input file, hoge.inflip, of superflip is output for charge flipping.

   If NCF = 1 then
      # COMPOSCF = ' ' if command 'composition' is not used.
      # Only integers may be input after element symbols.
      COMPOSCF = 'C40 N24 S4': String following 'composition' (CHARACTER*100)
   end if
end if

If NMODE = 4 or NMODE = 5 then
   NEXPO = 0! No input file, hoge.exp, of EXPO is output for buidling a structural model.
   NEXPO = 1: An input file, hoge.exp, of EXPO is output for buidling a structural model.

   If NEXPO = 1 then
      CONTENTEXP = 'C 40 N 24 S 4': String following 'content' in hoge.exp (CHARACTER*100)
   end if
end if

Select case NMODE
case 0, 1
  # Proceed to the input of NDA.
case 2, 3
  Go to *MEM
case 4-6
  Go to *Quit
end select

! Bond lengths and angles

NDA = 0! No file is output which store ORFFE data.
NDA = 1! hoge.xyz for ORFFE is output for the first phase.
NDA = 0

If NDA > 0 then
# Input ORFFE functions as required and place '}' (+ comment) at the tail.
# Refer to the user's manual for ORFFE functions used frequently.  ORFFE
# functions must be input with a fixed column format; note not to set input
# data at erroneous positions.  When NDA > 0, hoge.xyz is output.  This file is
# used as an input file for ORFFE to calculate interatomic distances and bond
# angles.  ORFFE functions in hoge.xyz can be modified and/or added by the user.

ORFFE functions start {
# Note that the formats of ORFFE functions differ from original ones!
#        1         2         3         4         5         6         7         8
#2345678901234567890123456789012345678901234567890123456789012345678901234567890

# Function 201, FORMAT(2I5,15X,I5).  Output a list of interatomic distances for
# all the sites.  The second number is the number of sites, and the third integer
# is 10 X (maximum distance in Angstroms).
# Interatomic distances less than 3.1 angstroms are listed
  201   17                  31

# Function 002, FORMAT(7I5).  Calculate a bond angle.  Three sets of A and
# 1000*C + S (refer to the output of ORFFE) follow after function 002.  Automatic
# generation of functions 002 is highly recommended (see Appendix D.4).

} End of ORFFE functions.
# ORFFE functions can be modified and added by editing hoge.xyz directly.
end if

If NMODE = 1 then
   Go to *Quit
end if

NFR = 0! No file is output for Fourier/D synthesis.
NFR = 1! hoge.hkl for Fourier/D synthesis is output for the first phase.
NFR = 0

If NFR = 1 then
   TSCAT = 536.0: Total number of electrons (X-ray) or sum of b_c (N).
   # b_c: coherent scattering length (International Tables, Vol. C, p. 384).
end if

*MEM

! MEM analysis

NMEM = 0! No file is output for MEM analysis.
NMEM = 1! hoge.fos for MEM analysis is output for the first phase.
NMEM = 0

If NMEM = 1 then
   LANOM = 0: Calculate esu's from I's without contributions of a.d.
   LANOM = 1! Calculate esu's from I's with contributions of a.d.
   # esu: estimated standard uncertainty, I: integrated intensity,
   # a.d.: anomalous dispersion

   LGR = 0: All the reflections are output independently (should be fixed at 0).
   LGR = 1! Reflections overlapped heavily are output by being grouped.

   LFOFC = 0: Using calculated F'o' based on Rietveld refinement.
   LFOFC = 1! Using Fcal (dependent on the model) in Rietveld refinement.

   EPSD = 0.001: Maximum difference in d/Angstrom in grouped reflections.
   TSCAT1 = 536.0: Total number of electrons (X-ray diffraction) or
                   # sum of positive b_c (neutron diffraction).
   TSCAT2 = 0.0: Zero (X-ray diffraction) or
                 # sum of negative b_c (Neutron diffraction).
end if

# Cite the following reference whenever you report scientific results obtained
# with RIETAN-FP:
# F. Izumi and K. Momma, Solid State Phenom., 130 (2007) 15-20.
# Giving credit to RIETAN-FP is fine in the cases of abstracts, reports, etc.

# Fujio IZUMI
# E-mail: fujioizumi@me.com

*Quit
