Fitting functions of soil hydraulic properties
PEST is a software package for parameter estimation and inverse analysis. It adjusts model parameters so that simulation results reproduce observed data as closely as possible. PEST is widely used in hydrology and environmental modeling, including workflows with HYDRUS (e.g. Urbina et al., 2021; Liu et al., 2021; Kaur et al., 2025).
When PEST is used together with HYDRUS, it allows estimation of soil hydraulic parameters by repeatedly running HYDRUS simulations and comparing the calculated results with observations. However, when using a hydraulic function that is available in unsatfit but is not supported directly by HYDRUS, an additional step is needed. HYDRUS reads hydraulic properties through Mater.in lookup tables, whereas unsatfit handles analytical WRF (water retention function) and HCF (hydraulic conductivity function) models and their parameters.
This is where the integration described in Using unsatfit with HYDRUS becomes important. By combining PEST, unsatfit, and HYDRUS:
In this way, inverse analysis can be performed even when the hydraulic properties are defined by functions available in unsatfit but not directly implemented in HYDRUS. This approach effectively bypasses the limitation that HYDRUS cannot directly use arbitrary analytical hydraulic functions.
The following diagram illustrates the coupling between the three components:

The overall workflow is as follows:
model.inp using model.tpl.model.inp and generates Mater.in.Mater.in.To perform inverse analysis with PEST, you need the following files:
.pst).tpl).ins)Among these files, the parts related to the WRF and HCF are the parameter group and parameter data sections of the control file. In these sections, you specify:
In the model input/output section, specify that PEST should generate model.inp from model.tpl, for example:
* model input/output
model.tpl model.inp
With this setting, PEST creates model.inp from model.tpl by inserting the current parameter values.
model.tplmodel.tpl is the PEST template file corresponding to model.inp. It defines where parameter values should be inserted.
model.inpmodel.inp is the input file read by unsatfit. It contains:
In a PEST workflow, this file is generated automatically by PEST from model.tpl.
Mater.inMater.in is the lookup-table file used by HYDRUS. It is generated from model.inp by unsatfit.
HYDRUS generates output files (e.g., Nod_Inf.out, Obs_Node.out) that contain simulated variables such as pressure head or water content.
These files are not used directly by PEST but are read through the instruction file (.ins), which extracts the values corresponding to observations.
.ins fileThe instruction file tells PEST how to read simulation results and extract observation values from HYDRUS output files (e.g., Nod_Inf.out, Obs_Node.out). In other words, the instruction file links HYDRUS output to PEST observations.
.pst fileThe control file defines the entire inverse analysis problem, including parameters, observations, files, and the model command line.
The full procedure is as follows.
First, prepare a HYDRUS project that runs correctly with a Mater.in file placed in the project directory.
In HYDRUS, specify Look-up Tables in Soil Hydraulic Model so that the hydraulic functions are read from Mater.in.
Also decide which HYDRUS output file will be used for comparison with observations, because this file will later be read by the PEST instruction file.
Prepare the files needed for the unsatfit-to-HYDRUS conversion as described in Using unsatfit with HYDRUS.
In particular, prepare:
model.tpl, which will be used by PEST,model.inp structure for the selected hydraulic model.If needed, these files can be created either manually or from fitted results in unsatfit, as explained in Using unsatfit with HYDRUS.
Create a PEST control file (.pst) and define the inverse problem.
In particular:
For the unsatfit-HYDRUS workflow, the important setting is:
* model input/output
model.tpl model.inp
This tells PEST to generate model.inp from model.tpl.
In the parameter data section, the parameters should correspond to the WRF and HCF parameters in the order expected by the hydraulic model.
Create an instruction file (.ins) so that PEST can extract simulated values from the HYDRUS output file.
The exact content depends on which HYDRUS output file is used and which values are compared with observations.
The conversion from model.inp to Mater.in is explained in Using unsatfit with HYDRUS. For a PEST workflow, prepare the following:
mat.py, that generates Mater.in from model.inp, for example (update the path to match your environment)import unsatfit
f = unsatfit.Fit()
print('Running mat.py')
f.load_input(filename='model.inp')
f.save_mater(filename=r'C:\Users\Public\Documents\PC-Progress\Hydrus-1D 4.xx\Projects\Test\Mater.in')
runmodel.bat, that runs the Python script and then starts HYDRUS, for example:python mat.py
"C:\Program Files (x86)\PC-Progress\Hydrus-1D 4.xx\H1D_CALC.exe" "C:\Users\Public\Documents\PC-Progress\Hydrus-1D 4.xx\Projects\Test"
* model command line
.\runmodel.bat
The execution sequence is then:
model.inp from model.tpl,runmodel.bat,runmodel.bat runs mat.py,mat.py generates Mater.in from model.inp,runmodel.bat runs HYDRUS,Note that PEST does not directly run HYDRUS; it only executes the command specified in the control file, which orchestrates the entire workflow.
Once the .pst, .tpl, .ins, HYDRUS project, and execution script are ready, run PEST.
During inverse analysis, PEST repeats the following cycle:
model.inp from model.tpl,model.inp to Mater.in,Mater.in,This cycle continues until the optimization stops according to the PEST settings.

By combining PEST, unsatfit, and HYDRUS, inverse analysis can be carried out with hydraulic functions that are available in unsatfit but not directly implemented in HYDRUS:
Mater.in,The key connection points are:
model.tpl -> model.inp by PESTmodel.inp -> Mater.in by unsatfitMater.in -> HYDRUS simulationFor details of PEST syntax and settings, refer to the official website.
As theoretically predicted, the slope of the HCF curve at the adsorption water range can often be assumed to be approximately 1.5. By applying a mathematical relationship to substitute a standard model variable (such as \(q\) or \(r\)) with this slope parameter \(a\), you can treat \(a\) = 1.5 as a constant, effectively reducing the number of free parameters in your PEST optimization by one.
For a detailed explanation of this theory and a step-by-step guide on how to implement this parameter conversion in your Python script and PEST template files, please refer to PEST: Parameter conversion.
As discussed in Seki et al. (2023), when the WRF parameters are determined first and the HCF parameters (Ks, p, r) or (Ks, p, q) are estimated afterward, it is effective to try multiple initial values for (p, r) or (p, q).
For example, you may use:
which gives a total of 12 initial combinations for (p, r).