<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="nxdlformat.xsl" ?>
<!--
# NeXus - Neutron and X-ray Common Data Format
# 
# Copyright (C) 2008-2020 NeXus International Advisory Committee (NIAC)
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# For further information, see http://www.nexusformat.org
-->
<definition xmlns="http://definition.nexusformat.org/nxdl/3.1" category="base"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd"
	name="NXsample" 
	type="group" extends="NXobject"
	>

	<symbols>
		<doc>symbolic array lengths to be coordinated between various fields</doc>
		<symbol name="n_comp"><doc>number of compositions</doc></symbol>
		<symbol name="n_Temp"><doc>number of temperatures</doc></symbol>
		<symbol name="n_eField"><doc>number of values in applied electric field</doc></symbol>
		<symbol name="n_mField"><doc>number of values in applied magnetic field</doc></symbol>
		<symbol name="n_pField"><doc>number of values in applied pressure field</doc></symbol>
		<symbol name="n_sField"><doc>number of values in applied stress field</doc></symbol>
	</symbols>

	<doc>
		Any information on the sample. 
		
		This could include scanned variables that
		are associated with one of the data dimensions, e.g. the magnetic field, or
		logged data, e.g. monitored temperature vs elapsed time.
	</doc>
	<field name="name">
		<doc>Descriptive name of sample</doc>
	</field>
	<field name="chemical_formula">
		<doc>
			The chemical formula specified using CIF conventions.
			Abbreviated version of CIF standard: 
			
			* Only recognized element symbols may be used.
			* Each element symbol is followed by a 'count' number. A count of '1' may be omitted.
			* A space or parenthesis must separate each cluster of (element symbol + count).
			* Where a group of elements is enclosed in parentheses, the multiplier for the 
			  group must follow the closing parentheses. That is, all element and group 
			  multipliers are assumed to be printed as subscripted numbers.
			* Unless the elements are ordered in a manner that corresponds to their chemical 
			  structure, the order of the elements within any group or moiety depends on 
			  whether or not carbon is present.
			* If carbon is present, the order should be: 
			
			  - C, then H, then the other elements in alphabetical order of their symbol. 
			  - If carbon is not present, the elements are listed purely in alphabetic order of their symbol. 
			  
			* This is the *Hill* system used by Chemical Abstracts.
		</doc>
	</field>
	<field name="temperature" type="NX_FLOAT" units="NX_TEMPERATURE">
		<doc>Sample temperature. This could be a scanned variable</doc>
		<dimensions rank="anyRank">
			<dim index="1" value="n_Temp"/><!-- could be any length -->
		</dimensions>
	</field>
	<field name="electric_field" type="NX_FLOAT" units="NX_VOLTAGE">
		<doc>Applied electric field</doc>
		<dimensions>
			<dim index="1" value="n_eField"/><!-- could be any length -->
		</dimensions>
        <attribute name="direction">
        	<enumeration>
        		<item value="x"/>
        		<item value="y"/>
        		<item value="z"/>
        	</enumeration>
        </attribute>
	</field>
	<field name="magnetic_field" type="NX_FLOAT" units="NX_ANY">
		<doc>Applied magnetic field</doc>
		<dimensions>
			<dim index="1" value="n_mField"/><!-- could be any length -->
		</dimensions>
        <attribute name="direction">
        	<enumeration>
        		<item value="x"/>
        		<item value="y"/>
        		<item value="z"/>
        	</enumeration>
        </attribute>
	</field>
	<field name="stress_field" type="NX_FLOAT" units="NX_ANY">
		<doc>Applied external stress field</doc>
		<dimensions>
			<dim index="1" value="n_sField"/><!-- could be any length -->
		</dimensions>
        <attribute name="direction">
        	<enumeration>
        		<item value="x"/>
        		<item value="y"/>
        		<item value="z"/>
        	</enumeration>
        </attribute>
	</field>
	<field name="pressure" type="NX_FLOAT" units="NX_PRESSURE">
		<doc>Applied pressure</doc>
		<dimensions>
			<dim index="1" value="n_pField"/><!-- could be any length -->
		</dimensions>
	</field>
	<field name="changer_position" type="NX_INT" units="NX_UNITLESS">
		<doc>Sample changer position</doc>
	</field>
	<field name="unit_cell_abc" type="NX_FLOAT" units="NX_LENGTH">
		<doc>Crystallography unit cell parameters a, b, and c</doc>
		<dimensions>
			<dim index="1" value="3"/>
		</dimensions>
	</field>
	<field name="unit_cell_alphabetagamma" type="NX_FLOAT" units="NX_ANGLE">
		<doc>Crystallography unit cell parameters alpha, beta, and gamma</doc>
		<dimensions>
			<dim index="1" value="3"/>
		</dimensions>
	</field>
	<field name="unit_cell" type="NX_FLOAT" units="NX_LENGTH">
		<doc>Unit cell parameters (lengths and angles)</doc>
		<dimensions rank="2">
			<dim index="1" value="n_comp"/>
			<dim index="2" value="6"/>
		</dimensions>
	</field>
	<field name="unit_cell_volume" type="NX_FLOAT" units="NX_VOLUME">
		<doc>Volume of the unit cell</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
	</field>
	<field name="sample_orientation" type="NX_FLOAT" units="NX_ANGLE">
		<doc>
			This will follow the Busing-Levy convention:
			W. R. Busing and H. A. Levy (1967). Acta Cryst. 22, 457-464
		</doc>
		<dimensions rank="1">
			<dim index="1" value="3"/>
		</dimensions>
	</field>
	<field name="orientation_matrix" type="NX_FLOAT">
		<doc>
			Orientation matrix of single crystal sample using Busing-Levy convention:
			W. R. Busing and H. A. Levy (1967). Acta Cryst. 22, 457-464
		</doc>
		<dimensions rank="3">
			<dim index="1" value="n_comp"/>
			<dim index="2" value="3"/>
			<dim index="3" value="3"/>
		</dimensions>
	</field>
	<field name="ub_matrix" type="NX_FLOAT">
		<doc>
			UB matrix of single crystal sample using Busing-Levy convention:
			W. R. Busing and H. A. Levy (1967). Acta Cryst. 22, 457-464. This is 
			the multiplication of the orientation_matrix, given above, 
			with the :math:`B` matrix which 
			can be derived from the lattice constants. 
		</doc>
		<dimensions rank="3">
			<dim index="1" value="n_comp"/>
			<dim index="2" value="3"/>
			<dim index="3" value="3"/>
		</dimensions>
	</field>
	<field name="mass" type="NX_FLOAT" units="NX_MASS">
		<doc>Mass of sample</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
	</field>
	<field name="density" type="NX_FLOAT" units="NX_MASS_DENSITY">
		<doc>Density of sample</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
	</field>
	<field name="relative_molecular_mass" type="NX_FLOAT" units="NX_MASS">
		<doc>Relative Molecular Mass of sample</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
	</field>
	<field name="type">
		<enumeration>
			<item value="sample" />
			<item value="sample+can" />
			<item value="can" />
			<item value="sample+buffer" />
			<item value="buffer" />
			<item value="calibration sample" />
			<item value="normalisation sample" />
			<item value="simulated data" />
			<item value="none" />
			<item value="sample environment" />
		</enumeration>
	</field>
	<field name="situation">
		<doc>
			The atmosphere will be one of the components, which is where 
			its details will be stored; the relevant components will be 
			indicated by the entry in the sample_component member.
		</doc>
		<enumeration>
			<item value="air" />
			<item value="vacuum" />
			<item value="inert atmosphere" />
			<item value="oxidising atmosphere" />
			<item value="reducing atmosphere" />
			<item value="sealed can" />
			<item value="other" />
		</enumeration>
	</field>
	<field name="description">
		<doc>
			Description of the sample
		</doc>
	</field>
	<field name="preparation_date" type="NX_DATE_TIME">
		<doc>Date of preparation of the sample</doc>
	</field>
	<group name="geometry" type="NXgeometry">
		<doc>The position and orientation of the center of mass of the sample</doc>
	</group>
	<group type="NXbeam">
		<doc>Details of beam incident on sample - used to calculate sample/beam interaction point</doc>
	</group>
	<group type="NXsample_component">
		<doc>
			One group per sample component
			This is the perferred way of recording per component information over the n_comp arrays
		</doc>
	</group>
	<field name="component">
		<doc>Details of the component of the sample and/or can</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
	</field>
	<field name="sample_component">
		<doc>Type of component</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
		<enumeration>
			<item value="sample" />
			<item value="can" />
			<item value="atmosphere" />
			<item value="kit" />
		</enumeration>
	</field>
	<field name="concentration" type="NX_FLOAT" units="NX_MASS_DENSITY">
		<doc>Concentration of each component</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
	</field>
	<field name="volume_fraction" type="NX_FLOAT">
		<doc>Volume fraction of each component</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
	</field>
	<field name="scattering_length_density" type="NX_FLOAT" units="NX_SCATTERING_LENGTH_DENSITY">
		<doc>Scattering length density of each component</doc>
		<dimensions rank="1">
			<dim index="1" value="n_comp"/>
		</dimensions>
	</field>
        <field name="unit_cell_class">
                <doc>
                        In case it is all we know and we want to record/document it
                </doc>
                <enumeration>
                        <item value="triclinic" />
                        <item value="monoclinic" />
                        <item value="orthorhombic" />
                        <item value="tetragonal" />
                        <item value="rhombohedral" />
                        <item value="hexagonal" />
                        <item value="cubic" />
                </enumeration>
        </field>
        <field name="space_group">
                <doc>Crystallographic space group</doc>
		<dimensions>
			<dim index="1" value="n_comp"/>
		</dimensions>
        </field>
        <field name="point_group">
                <doc>Crystallographic point group, deprecated if space_group present</doc>
		<dimensions>
			<dim index="1" value="n_comp"/>
        </dimensions>
		</field>
	<field name="path_length" type="NX_FLOAT" units="NX_LENGTH">
		<doc>
			Path length through sample/can for simple case when 
			it does not vary with scattering direction
		</doc>
	</field>
	<field name="path_length_window" type="NX_FLOAT" units="NX_LENGTH">
		<doc>
			Thickness of a beam entry/exit window on the can (mm) 
			- assumed same for entry and exit
		</doc>
	</field>
	<field name="thickness" type="NX_FLOAT" units="NX_LENGTH">
		<doc>sample thickness</doc>
	</field>
	<group name="transmission" type="NXdata">
		<doc>As a function of Wavelength</doc>
	</group>
	<group name="temperature_log" type="NXlog">
		<doc>temperature_log.value is a link to e.g. temperature_env.sensor1.value_log.value</doc>
	</group>
	<group name="temperature_env" type="NXenvironment">
		<doc>Additional sample temperature environment information</doc>
	</group>
	<group name="magnetic_field_log" type="NXlog">
		<doc>magnetic_field_log.value is a link to e.g. magnetic_field_env.sensor1.value_log.value</doc>
	</group>
	<group name="magnetic_field_env" type="NXenvironment">
		<doc>Additional sample magnetic environment information</doc>
	</group>
	<field name="external_DAC" type="NX_FLOAT" units="NX_ANY">
		<doc>value sent to user's sample setup</doc>
	</field>
	<group name="external_ADC" type="NXlog">
		<doc>logged value (or logic state) read from user's setup</doc>
	</group>
	<field name="short_title">
		<doc>20 character fixed length sample description for legends</doc>
		<!-- How is the string length limitation imposed by the XSD? -->
	</field>
	<field name="rotation_angle" type="NX_FLOAT" units="NX_ANGLE">
		<doc>
			Optional rotation angle for the case when the powder diagram has 
			been obtained through an omega-2theta scan like from a traditional 
			single detector powder diffractometer
		</doc>
	</field>
	<field name="x_translation" type="NX_FLOAT" units="NX_LENGTH">
   <doc>Translation of the sample along the X-direction of the laboratory coordinate system</doc>
  </field>
  <field name="distance" type="NX_FLOAT" units="NX_LENGTH">
   <doc>Translation of the sample along the Z-direction of the laboratory coordinate system</doc>
  </field>
	<group type="NXpositioner">
	  <doc>Any positioner (motor, PZT, ...) used to locate the sample</doc>
	</group>
</definition>

