<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:fews="http://www.wldelft.nl/fews" targetNamespace="http://www.wldelft.nl/fews" elementFormDefault="qualified" version="1.0">
	<!--<include schemaLocation="commonAdapter.xsd"/>-->
	<!-- -->
	<element name="IntegratedReservoirModel" type="fews:IntegratedReservoirModelComplexType"/>
	<!-- -->
	<complexType name="IntegratedReservoirModelComplexType">
		<sequence>
			<element name="general" type="fews:GeneralComplexType"/>
			<element name="reservoir" type="fews:IntegratedReservoirComplexType"/>
		</sequence>
	</complexType>
	<!-- -->
	<complexType name="IntegratedReservoirComplexType">
		<sequence>
			<element name="general" type="fews:GeneralModuleConfigComplexType"/>
			<element name="storageCharacteristics" type="fews:StorageCharacteristicsComplexType">
				<annotation>
					<documentation>Storage characteristics of the node: The storage S as a function of the water level h can be provided as a table or formula.</documentation>
				</annotation>
			</element>
			<element name="uncontrolledOutlet" type="fews:UncontrolledOutletComplexType" minOccurs="0">
				<annotation>
					<documentation>Uncontrolled outlet, the release is a function of the water level h in the reservoir</documentation>
				</annotation>
			</element>
			<element name="input" type="fews:ReservoirInputComplexType"/>
			<element name="output" type="fews:ReservoirOutputComplexType"/>
		</sequence>
		<attribute name="id" type="string" use="required"/>
		<attribute name="name" type="string" use="optional"/>
	</complexType>
	<complexType name="GeneralComplexType">
		<sequence>
			<element name="missingValue" type="double">
				<annotation>
					<documentation>Missing value for adapter input/output files.</documentation>
				</annotation>
			</element>
		</sequence>
	</complexType>
	<complexType name="GeneralModuleConfigComplexType">
		<annotation>
			<documentation>General settings of the reservoir module.</documentation>
		</annotation>
		<sequence>
			<element name="description" type="string" minOccurs="0">
				<annotation>
					<documentation>Optional description of the schematization and its version</documentation>
				</annotation>
			</element>
			<element name="poolRoutingScheme" type="fews:poolRoutingEnumStringType" default="backwardsEulerMethod">
				<annotation>
					<documentation>Pool routing scheme for the network components</documentation>
				</annotation>
			</element>
			<element name="dynamicInterpolation" type="boolean" default="true">
				<annotation>
					<documentation>Allow the model to do dynamic interpolation of data between the records in the (preprocessed) input storage and outflow tables.</documentation>
				</annotation>
			</element>
			<element name="interpolationMethod" type="fews:interpolationMethodEnumStringType" default="linear">
				<annotation>
					<documentation>Interpolation method for elevation tables</documentation>
				</annotation>
			</element>
			<element name="elevationInterval" type="double">
				<annotation>
					<documentation>Resolution for elevation table input interpolation (m) to be performed before the model runs, Not used when dynamicInterpolation is set to True</documentation>
				</annotation>
			</element>
			<element name="extrapolationMethod" type="fews:extrapolationMethodEnumStringType" default="notAllowed" minOccurs="0">
				<annotation>
					<documentation>Interpolation method for elevation tables</documentation>
				</annotation>
			</element>
		</sequence>
	</complexType>
	<simpleType name="poolRoutingEnumStringType">
		<restriction base="string">
			<enumeration value="levelPoolMethod"/>
			<enumeration value="backwardsEulerMethod"/>
		</restriction>
	</simpleType>
	<simpleType name="interpolationMethodEnumStringType">
		<restriction base="string">
			<enumeration value="linear"/>
		</restriction>
	</simpleType>
	<simpleType name="extrapolationMethodEnumStringType">
		<restriction base="string">
			<enumeration value="notAllowed"/>
			<enumeration value="maxMin"/>
			<enumeration value="linear"/>
		</restriction>
	</simpleType>
	<complexType name="StorageCharacteristicsComplexType">
		<sequence>
			<choice>
				<element name="storageTable" type="fews:ElevationStorageTableComplexType">
					<annotation>
						<documentation>Storage table with pairs of elevation h and storage S. This relation should be strictly increasing (monotone)</documentation>
					</annotation>
				</element>
			</choice>
		</sequence>
	</complexType>
	<complexType name="ElevationStorageTableComplexType">
		<annotation>
			<documentation>
                Table containing storage data for different elevations. Value of element 'storage' represents the reservoir storage (m3) at that level (m)
            </documentation>
		</annotation>
		<sequence>
			<element name="elevationStorageRecord" type="fews:ElevationStorageComplexType" minOccurs="2" maxOccurs="unbounded"/>
		</sequence>
	</complexType>
	<complexType name="ElevationStorageComplexType">
		<attribute name="elevation" type="double" use="required"/>
		<attribute name="storage" type="double" use="required"/>
	</complexType>
	<complexType name="UncontrolledOutletComplexType">
		<sequence>
			<element name="capacityCharacteristics" type="fews:CapacityCharacteristicsComplexType">
				<annotation>
					<documentation>Maximum capacity of outlet as function of the water level h, minimum capacity is assumed to be zero</documentation>
				</annotation>
			</element>
		</sequence>
		<attribute name="id" type="string" use="required"/>
		<attribute name="name" type="string" use="optional"/>
	</complexType>
	<complexType name="CapacityCharacteristicsComplexType">
		<sequence>
			<choice>
				<annotation>
					<documentation>Capacity for free flow, i.e. without a potential impact of the optional tailwater</documentation>
				</annotation>
				<element name="outletTable" type="fews:ElevationOutletTableComplexType"/>
			</choice>
		</sequence>
	</complexType>
	<complexType name="ElevationOutletTableComplexType">
		<annotation>
			<documentation>
                Table containing data for different elevations. Value of element 'outlet'
                is the capacity for free flow, i.e. without a potential impact of the optional tailwater
            </documentation>
		</annotation>
		<sequence>
			<element name="elevationOutletRecord" type="fews:ElevationOutletComplexType" minOccurs="2" maxOccurs="unbounded"/>
		</sequence>
	</complexType>
	<complexType name="ElevationOutletComplexType">
		<attribute name="elevation" type="double" use="required"/>
		<attribute name="outlet" type="double" use="required"/>
	</complexType>
	<complexType name="ReservoirInputComplexType">
		<sequence>
			<element name="inflow" type="string" >
				<annotation>
					<documentation>Upstream inflows [m3/s] into the reservoir, can be more than one for aggregation the inflows from several upstream reservoirs or river reaches</documentation>
				</annotation>
			</element>
			<element name="level" type="string" minOccurs="0">
				<annotation>
					<documentation>Optional level [m] for updating the simulated level by an observed water level (simple data assimilation)</documentation>
				</annotation>
			</element>
			<element name="release" type="string" minOccurs="0">
				<annotation>
					<documentation>Optional release [m3/s] for updating the simulated level by an observed release (simple data assimilation)</documentation>
				</annotation>
			</element>
		</sequence>
	</complexType>
	<complexType name="ReservoirOutputComplexType">
		<sequence>
			<element name="inflow" type="string" minOccurs="0">
				<annotation>
					<documentation>Aggregated inflows [m3/s]</documentation>
				</annotation>
			</element>
			<element name="release" type="string">
				<annotation>
					<documentation>Aggregated release [m3/s]</documentation>
				</annotation>
			</element>
			<element name="storage" type="string">
				<annotation>
					<documentation>Storage [m3] (state variable)</documentation>
				</annotation>
			</element>
			<element name="level" type="string">
				<annotation>
					<documentation>Water level [m] in the reservoir</documentation>
				</annotation>
			</element>
			<element name="error" type="string" minOccurs="0">
				<annotation>
					<documentation>Storage error [m3]</documentation>
				</annotation>
			</element>
		</sequence>
	</complexType>
</schema>
