Exemplo n.º 1
0
        /// <summary>
        /// Split an existing patch in two. That is, creates a new patch (k) based on an existing one (j)
        /// </summary>
        /// <param name="j">The j.</param>
        private void SplitPatch(int j)
        {
            // create new patch
            soilCNPatch newPatch = new soilCNPatch(this);

            Patch.Add(newPatch);
            int k = Patch.Count - 1;

            // set the size of arrays
            Patch[k].ResizeLayerArrays(dlayer.Length);

            // set C and N variables to the same state as the 'mother' patch
            for (int layer = 0; layer < dlayer.Length; layer++)
            {
                Patch[k].urea[layer]        = Patch[j].urea[layer];
                Patch[k].nh4[layer]         = Patch[j].nh4[layer];
                Patch[k].no3[layer]         = Patch[j].no3[layer];
                Patch[k].inert_c[layer]     = Patch[j].inert_c[layer];
                Patch[k].biom_c[layer]      = Patch[j].biom_c[layer];
                Patch[k].biom_n[layer]      = Patch[j].biom_n[layer];
                Patch[k].hum_c[layer]       = Patch[j].hum_c[layer];
                Patch[k].hum_n[layer]       = Patch[j].hum_n[layer];
                Patch[k].fom_c_pool1[layer] = Patch[j].fom_c_pool1[layer];
                Patch[k].fom_c_pool2[layer] = Patch[j].fom_c_pool2[layer];
                Patch[k].fom_c_pool3[layer] = Patch[j].fom_c_pool3[layer];
                Patch[k].fom_n_pool1[layer] = Patch[j].fom_n_pool1[layer];
                Patch[k].fom_n_pool2[layer] = Patch[j].fom_n_pool2[layer];
                Patch[k].fom_n_pool3[layer] = Patch[j].fom_n_pool3[layer];
            }

            // store today's values
            Patch[k].InitCalc();
        }
Exemplo n.º 2
0
        /// <summary>Reset the state values to those set during the initialisation</summary>
        public void Reset()
        {
            Patch = new List <soilCNPatch>();
            soilCNPatch newPatch = new soilCNPatch(this);

            Patch.Add(newPatch);
            Patch[0].RelativeArea = 1.0;
            Patch[0].PatchName    = "base";

            // Variable handling when using APSIMX
            initDone     = false;
            dlayer       = Soil.Thickness;
            bd           = Soil.BD;
            sat_dep      = MathUtilities.Multiply(Soil.SAT, Soil.Thickness);
            dul_dep      = MathUtilities.Multiply(Soil.DUL, Soil.Thickness);
            ll15_dep     = MathUtilities.Multiply(Soil.LL15, Soil.Thickness);
            sw_dep       = MathUtilities.Multiply(Soil.InitialWaterVolumetric, Soil.Thickness);
            oc           = Soil.OC;
            ph           = Soil.PH;
            salb         = Soil.SoilWater.Salb;
            NO3ppm       = Soil.InitialNO3N;
            NH4ppm       = Soil.InitialNH4N;
            ureappm      = new double[Soil.Thickness.Length];
            num_residues = 0;

            fbiom       = Soil.FBiom;
            finert      = Soil.FInert;
            soil_cn     = SoilOrganicMatter.SoilCN;
            root_wt     = SoilOrganicMatter.RootWt;
            root_cn     = SoilOrganicMatter.RootCN;
            enr_a_coeff = SoilOrganicMatter.EnrACoeff;
            enr_b_coeff = SoilOrganicMatter.EnrBCoeff;

            if (Soil.SoilType != null && Soil.SoilType.Equals("Sand", StringComparison.CurrentCultureIgnoreCase))
            {
                rd_biom      = new double[] { 0.0324, 0.015 };
                wfmin_values = new double[] { 0.05, 1.0, 1.0, 0.5 };
            }
            else
            {
                rd_biom      = new double[] { 0.0081, 0.004 };
                wfmin_values = new double[] { 0.0, 1.0, 1.0, 0.5 };
            }

            initDone = true;

            // set the size of arrays
            ResizeLayerArrays(dlayer.Length);
            foreach (soilCNPatch aPatch in Patch)
            {
                aPatch.ResizeLayerArrays(dlayer.Length);
            }

            // check few initialisation parameters
            CheckParams();

            // perform initial calculations and setup
            InitCalc();
        }
Exemplo n.º 3
0
        /// <summary>Initializes a new instance of the <see cref="SoilNitrogen"/> class.</summary>
        public SoilNitrogen()
        {
            Patch = new List <soilCNPatch>();
            soilCNPatch newPatch = new soilCNPatch(this);

            Patch.Add(newPatch);
            Patch[0].RelativeArea = 1.0;
            Patch[0].PatchName    = "base";
            wfpsN2N2O_x           = new double[] { 22, 88 };
            wfpsN2N2O_y           = new double[] { 0.1, 1 };
        }
Exemplo n.º 4
0
        /// <summary>
        /// Clone an existing patch. That is, creates a new patch (k) based on an existing one (j)
        /// </summary>
        /// <param name="j">id of patch to be cloned</param>
        private void ClonePatch(int j)
        {
            // create new patch
            soilCNPatch newPatch = new soilCNPatch(this);

            Patch.Add(newPatch);
            int k = Patch.Count - 1;

            // set the size of arrays
            Patch[k].ResizeLayeredVariables(nLayers);

            // copy the state variables from original patch in to the new one
            CopyCNValuesToPatch(k, j);
        }
Exemplo n.º 5
0
        /// <summary>Reset the state values to those set during the initialisation</summary>
        public void Reset()
        {
            inReset = true;

            // Save present state
            SaveState();

            // reset the size of arrays - so it zeroes them
            ResizeLayerArrays(dlayer.Length);

            // reset patches
            Patch.Clear();
            soilCNPatch newPatch = new soilCNPatch(this);

            Patch.Add(newPatch);

            foreach (soilCNPatch aPatch in Patch)
            {
                aPatch.ResizeLayerArrays(dlayer.Length);
            }

            // reset C and N variables to their initial state
            oc      = OC_reset;
            NO3ppm  = no3ppm_reset;
            NH4ppm  = nh4ppm_reset;
            ureappm = ureappm_reset;

            // perform initial calculations and setup
            InitCalc();

            // reset soil temperature
            if (!use_external_st)
            {
                simpleST = new simpleSoilTemp(MetFile.Latitude, MetFile.Tav, MetFile.Amp, MetFile.MinT, MetFile.MaxT);
                Tsoil    = simpleST.SoilTemperature(Clock.Today, MetFile.MinT, MetFile.MaxT, MetFile.Radn, salb, dlayer, bd, ll15_dep, sw_dep);
            }

            // get the changes of state and publish (let other component to know)
            DeltaState();

            inReset = false;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Split an existing patch in two. That is, creates a new patch (k) based on an existing one (j)
        /// </summary>
        /// <param name="j">The j.</param>
        private void SplitPatch(int j)
        {
            // create new patch
            soilCNPatch newPatch = new soilCNPatch(this);
            Patch.Add(newPatch);
            int k = Patch.Count - 1;

            // set the size of arrays
            Patch[k].ResizeLayerArrays(dlayer.Length);

            // set C and N variables to the same state as the 'mother' patch
            for (int layer = 0; layer < dlayer.Length; layer++)
            {
                Patch[k].urea[layer] = Patch[j].urea[layer];
                Patch[k].nh4[layer] = Patch[j].nh4[layer];
                Patch[k].no3[layer] = Patch[j].no3[layer];
                Patch[k].inert_c[layer] = Patch[j].inert_c[layer];
                Patch[k].biom_c[layer] = Patch[j].biom_c[layer];
                Patch[k].biom_n[layer] = Patch[j].biom_n[layer];
                Patch[k].hum_c[layer] = Patch[j].hum_c[layer];
                Patch[k].hum_n[layer] = Patch[j].hum_n[layer];
                Patch[k].fom_c_pool1[layer] = Patch[j].fom_c_pool1[layer];
                Patch[k].fom_c_pool2[layer] = Patch[j].fom_c_pool2[layer];
                Patch[k].fom_c_pool3[layer] = Patch[j].fom_c_pool3[layer];
                Patch[k].fom_n_pool1[layer] = Patch[j].fom_n_pool1[layer];
                Patch[k].fom_n_pool2[layer] = Patch[j].fom_n_pool2[layer];
                Patch[k].fom_n_pool3[layer] = Patch[j].fom_n_pool3[layer];
            }

            // store today's values
            Patch[k].InitCalc();
        }
Exemplo n.º 7
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            Patch = new List<soilCNPatch>();
            soilCNPatch newPatch = new soilCNPatch(this);
            Patch.Add(newPatch);
            Patch[0].RelativeArea = 1.0;
            Patch[0].PatchName = "base";

            // Variable handling when using APSIMX
            initDone = false;
            dlayer = Soil.Thickness;
            bd = Soil.BD;
            sat_dep = MathUtilities.Multiply(Soil.SAT, Soil.Thickness);
            dul_dep = MathUtilities.Multiply(Soil.DUL, Soil.Thickness);
            ll15_dep = MathUtilities.Multiply(Soil.LL15, Soil.Thickness);
            sw_dep = MathUtilities.Multiply(Soil.InitialWaterVolumetric, Soil.Thickness);
            oc = Soil.OC;
            ph = Soil.PH;
            salb = Soil.SoilWater.Salb;
            NO3ppm = Soil.InitialNO3N;
            NH4ppm = Soil.InitialNH4N;
            num_residues = 0;
            Tsoil = null;
            simpleST = null;

            fbiom = Soil.FBiom;
            finert = Soil.FInert;
            soil_cn = SoilOrganicMatter.SoilCN;
            root_wt = SoilOrganicMatter.RootWt;
            root_cn = SoilOrganicMatter.RootCN;
            enr_a_coeff = SoilOrganicMatter.EnrACoeff;
            enr_b_coeff = SoilOrganicMatter.EnrBCoeff;

            if (Soil.SoilType != null && Soil.SoilType.Equals("Sand", StringComparison.CurrentCultureIgnoreCase))
            {
                rd_biom = new double[] { 0.0324, 0.015 };
                wfmin_values = new double[] {0.05, 1.0, 1.0, 0.5 };
            }
            else
            {
                rd_biom = new double[] { 0.0081, 0.004 };
                wfmin_values = new double[] { 0.0, 1.0, 1.0, 0.5 };
            }

            initDone = true;

            // set the size of arrays
            ResizeLayerArrays(dlayer.Length);
            foreach (soilCNPatch aPatch in Patch)
                aPatch.ResizeLayerArrays(dlayer.Length);

            // check few initialisation parameters
            CheckParams();

            // perform initial calculations and setup
            InitCalc();

            // notifify apsim about solutes
            AdvertiseMySolutes();
        }
Exemplo n.º 8
0
        /// <summary>Reset the state values to those set during the initialisation</summary>
        public void Reset()
        {
            inReset = true;

            // Save present state
            SaveState();

            // reset the size of arrays - so it zeroes them
            ResizeLayerArrays(dlayer.Length);

            // reset patches
            Patch.Clear();
            soilCNPatch newPatch = new soilCNPatch(this);
            Patch.Add(newPatch);

            foreach (soilCNPatch aPatch in Patch)
                aPatch.ResizeLayerArrays(dlayer.Length);

            // reset C and N variables to their initial state
            oc = OC_reset;
            NO3ppm = no3ppm_reset;
            NH4ppm = nh4ppm_reset;
            ureappm = ureappm_reset;

            // perform initial calculations and setup
            InitCalc();

            // reset soil temperature
            if (!use_external_st)
            {
                simpleST = new simpleSoilTemp(MetFile.Latitude, MetFile.Tav, MetFile.Amp, MetFile.MinT, MetFile.MaxT);
                Tsoil = simpleST.SoilTemperature(Clock.Today, MetFile.MinT, MetFile.MaxT, MetFile.Radn, salb, dlayer, bd, ll15_dep, sw_dep);
            }

            // get the changes of state and publish (let other component to know)
            DeltaState();

            inReset = false;
        }
Exemplo n.º 9
0
 /// <summary>Initializes a new instance of the <see cref="SoilNitrogen"/> class.</summary>
 public SoilNitrogen()
 {
     Patch = new List<soilCNPatch>();
     soilCNPatch newPatch = new soilCNPatch(this);
     Patch.Add(newPatch);
     Patch[0].RelativeArea = 1.0;
     Patch[0].PatchName = "base";
     wfpsN2N2O_x = new double[] { 22, 88 };
     wfpsN2N2O_y = new double[] { 0.1, 1 };
 }