<amanzi_input version="2.0.0" type="unstructured">

	<model_description name="1D Calcite Dissolution">
		<author>Glenn Hammond</author>
		<units>
			<length_unit>m</length_unit>
			<time_unit>y</time_unit>
			<mass_unit>kg</mass_unit>
			<conc_unit>molar</conc_unit>
		</units>
	</model_description>

	<definitions>
	    	<macros>
				<cycle_macro name = "Every_100_steps">
					<start>0</start>
					<timestep_interval>100</timestep_interval>
					<stop>-1</stop>
				</cycle_macro>
				<time_macro name="Macro 1">
					<time>0.50 y</time>
					<time>1.00 y</time>
					<time>1.50 y</time>
					<time>2.00 y</time>
					<time>3.50 y</time>
					<time>3.00 y</time>
					<time>4.50 y</time>
					<time>4.00 y</time>
					<time>5.50 y</time>
					<time>5.00 y</time>
					<time>6.50 y</time>
					<time>6.00 y</time>
					<time>7.50 y</time>
					<time>7.00 y</time>
					<time>8.50 y</time>
					<time>8.00 y</time>
					<time>9.00 y</time>
					<time>10.00 y</time>
					<time>11.00 y</time>
					<time>12.00 y</time>
					<time>13.00 y</time>
					<time>14.00 y</time>
					<time>15.00 y</time>
					<time>16.00 y</time>
					<time>17.00 y</time>
					<time>18.00 y</time>
					<time>19.00 y</time>
					<time>20.00 y</time>
					<time>21.00 y</time>
					<time>22.00 y</time>
					<time>23.00 y</time>
					<time>24.00 y</time>
					<time>25.00 y</time>
				</time_macro>
		</macros>
	</definitions>


	<process_kernels>
		<flow state="on" model="saturated"/>
		<transport state="on" algorithm="implicit upwind" sub_cycling = "on"/>
		<chemistry state="on" process_model="implicit operator split"/>
	</process_kernels>

	<phases>
		<liquid_phase name="water">
			<eos>False</eos>
			<viscosity>1.0e-3</viscosity>
			<density>1000.0</density>
			<dissolved_components>
				<solutes>
					<solute coefficient_of_diffusion="1.0e-9">H+</solute>
					<solute coefficient_of_diffusion="1.0e-9">HCO3-</solute>
					<solute coefficient_of_diffusion="1.0e-9">Ca++</solute>
				</solutes>
			</dissolved_components>
		</liquid_phase>
		<solid_phase>
			<minerals>
				<mineral>Calcite</mineral>
			</minerals>
		</solid_phase>
	</phases>

	<execution_controls>
			<comments>TDS added these as required by the schema </comments>
			<execution_control_defaults init_dt= "1.0 h"   max_dt="0.25 y"  reduction_factor="0.8"  increase_factor="1.25" mode="steady" method="picard"/>
			<execution_control  start="0.0 y" end="25.0 y" init_dt= "1.0 h" max_dt="0.25 y" reduction_factor="0.5"  increase_factor="2.0"    mode = "steady"  method="picard" />
	</execution_controls>

	<numerical_controls>
		<comments>Numerical controls comments here</comments>
		<steady-state_controls>
		        <comments>Note that this section contained data on timesteps, which was moved into the execution control section.</comments>
          		<min_iterations>10</min_iterations>
		      	<max_iterations>20</max_iterations>
          		<max_preconditioner_lag_iterations>30</max_preconditioner_lag_iterations>
          		<nonlinear_tolerance>1.0e-5</nonlinear_tolerance>
          		<pseudo_time_integrator>
               			<method>picard</method>
          				<preconditioner>hypre_amg</preconditioner>
          				<linear_solver>aztec00</linear_solver>
          				<control_options>pressure</control_options>
          				<clipping_saturation>0.95</clipping_saturation>
          				<convergence_tolerance>0.95</convergence_tolerance>
          				<initialize_with_darcy>true</initialize_with_darcy>
          		</pseudo_time_integrator>
		</steady-state_controls>
		<transient_controls>
			<comments>Proposed comments section.</comments>
			<bdf1_integration_method min_iterations="12" max_iterations="20" max_preconditioner_lag_iterations="5" />
		</transient_controls>
		<linear_solver>
			<comments>Proposed comment section.</comments>
			<method>gmres</method>
			<max_iterations>20</max_iterations>
			<tolerance>1.0e-18</tolerance>
	                <preconditioner name = "hypre_amg">
	                     	<hypre_cycle_applications>10</hypre_cycle_applications>
	                	<hypre_smoother_sweeps>10</hypre_smoother_sweeps>
	                       	<hypre_tolerance>0.1</hypre_tolerance>
	                       	<hypre_strong_threshold>0.8</hypre_strong_threshold>
	                 </preconditioner>
		</linear_solver>
	</numerical_controls>

	<mesh framework="mstk">
		<comments>GEH: Using 3D domain since I don't know the format for 1D.</comments>
		<dimension>3</dimension>
		<generate>
			<number_of_cells nx = "100"  ny = "1"  nz = "1"/>
			<box  low_coordinates = "(0.0,0.0,0.0)" high_coordinates = "(100.0,1.0,1.0)"/>
		</generate>
	</mesh>

	<regions>
		<region name ="All">
			<box low_coordinates= "(0.0,0.0,0.0)"     high_coordinates="(100.0,1.0,1.0)"/>
		</region>

		<region name ="Inlet Boundary">
			<box low_coordinates= "(0.0,0.0,0.0)"     high_coordinates="(0.0,1.0,1.0)"/>
		</region>

		<region name ="Outlet Boundary">
			<box low_coordinates= "(110.0,0.0,0.0)"     high_coordinates="(100.0,1.0,1.0)"/>
		</region>

		<point name="inlet" coordinate="(25.0,1.0,1.0)"/>
		<point name="quarter_distance" coordinate="(25.0,1.0,1.0)"/>
		<point name="half_distance" coordinate="(50.0,1.0,1.0)"/>
		<point name="three_quarter_distance" coordinate="(75.0,1.0,1.0)"/>
		<point name="outlet" coordinate="(25.0,1.0,1.0)"/>

	</regions>

	<materials>
		<material name="soil1">
			<mechanical_properties>
				<porosity value="0.25"/>
				<particle_density value="2720.0"/>
			</mechanical_properties>
			<permeability x="1.0e-12" y="1.0e-12" z="1.0e-12"/>
			<!--No capillary pressure or relative permeability model due to saturated flow-->
			<assigned_regions>All</assigned_regions>
		</material>
	</materials>

  	<geochemistry>
		<reaction_network file = "calcite_flow_and_tran.in" format= "simple"/>
		<constraints>
			<!-- Provide a list of constraints for various chemistry in system. -->
                        <!-- Chemistry input needs to be consolidated and migrated to xml file
                             as funding becomes available -->
			<constraint name="Initial">
				<solute name="H+"        value="1.0e-8"            type="Free Ion Concentration"/>
				<solute name="HCO3-"     value="1.0e-3"            type="Gas"      gas="CO2(g)"/>
				<solute name="Ca++"      value="5.0e-4"            type="Mineral"  mineral="Calcite"/>
				<mineral name="Calcite"  volume_fraction="1.0e-5"  surface_area ="1.0"/>
			</constraint>
			<!-- Mineral named in constraint = "Initial" because it's used to set initial condition -->
			<constraint name="Inlet">
				<solute name="H+"     value="5.0"        type="pH"/>
				<solute name="HCO3-"  value="1.0e-3"	type="Total Component Concentration"/>
				<solute name="Ca++"   value="1.0e-6"     type="Charge Balance"/>
			</constraint>
                        <!-- OR -->
                        <!-- Advantage is that reaction network and associated constraints are
                             all in the same place per Glenn and Vicky's discussion
                             Consolidating to pflotran is first step towards consolidation  -->
			<constraint name="Initial" filename="calcite_flow_and_tran.in"/>
			<constraint name="Inlet" filename="calcite_flow_and_tran.in"/>
		</constraints>
	</geochemistry>

	<initial_conditions>  
		<initial_condition name="Background">
			<assigned_regions>All</assigned_regions>
			<liquid_phase name="water">
				<liquid_component name="water">
					<uniform_pressure value="201325.0"/>
				</liquid_component>
				<geochemistry>
					<constraint name="Initial"/>
				</geochemistry>
    			</liquid_phase>
			<solid_phase name="Solid">
				<geochemistry>
					<constraint name="Initial"/>
				</geochemistry>
			</solid_phase>
		</initial_condition>
	</initial_conditions>

	<boundary_conditions> 
		<boundary_condition name="Inlet">
			<assigned_regions>Inlet Boundary</assigned_regions>
			<liquid_phase name="water">
				<liquid_component name="water">
					<inward_mass_flux value="1.0" start="0" function="constant"/>
				</liquid_component>
				<geochemistry>
					<constraint name="Inlet" start="0.0" function="constant"/>
				</geochemistry>
			</liquid_phase>
		</boundary_condition>
		<boundary_condition name="Outlet">
			<assigned_regions>Outlet Boundary</assigned_regions>
			<liquid_phase name="water">
				<liquid_component name="water">
					<uniform_pressure value="201325.0" start="0.0" function="constant"/>
				</liquid_component>
				<geochemistry>
					<constraint name="Initial" start="0.0" function="constant"/>
				</geochemistry>
			</liquid_phase>
		</boundary_condition>
	</boundary_conditions>

	<output>
		<vis>
			<base_filename>plot</base_filename>
		  	<num_digits>5</num_digits>
		  	<time_macro>Macro 1</time_macro>
		</vis>

		<checkpoint>
			<base_filename>chk</base_filename>
		  	<num_digits>5</num_digits>
		  	<cycle_macro>Every_100_steps</cycle_macro>
		</checkpoint>

		<observations>
       			<filename>observations.out</filename>
			<liquid_phase name="water">
          			<integrated_mass>
              				<filename>imass.out</filename>  <!-- later when there is more $$; for now all observation is output to same file -->
             				<assigned_regions>All</assigned_regions>
            				<functional>integral</functional>
              				<time_macro>Macro 1</time_macro>
           			</integrated_mass>

           			<aqueous_conc solute ="H+">
					<filename>conc.out</filename>  <!-- later when there is more $$; for now all observation is output to same file -->
					<assigned_regions>half_distance,outlet</assigned_regions>
					<functional>point</functional>
					<time_macro>Macro 1</time_macro>
				</aqueous_conc>
			</liquid_phase>
		</observations>
	</output>

</amanzi_input>
