예제 #1
0
 public static int IncreaseSizeOfBiomassRemoved(BiomassRemovedType BiomassRemoved)
 {
     // Make sure the BiomassRemoved structure has enough elements in it.
     if (BiomassRemoved.dm_type == null)
     {
         BiomassRemoved.dm_type             = new string[1];
         BiomassRemoved.fraction_to_residue = new float[1];
         BiomassRemoved.dlt_crop_dm         = new float[1];
         BiomassRemoved.dlt_dm_n            = new float[1];
         BiomassRemoved.dlt_dm_p            = new float[1];
     }
     else
     {
         int NewSize = BiomassRemoved.dm_type.Length + 1;
         Array.Resize(ref BiomassRemoved.dm_type, NewSize);
         Array.Resize(ref BiomassRemoved.fraction_to_residue, NewSize);
         Array.Resize(ref BiomassRemoved.dlt_crop_dm, NewSize);
         Array.Resize(ref BiomassRemoved.dlt_dm_n, NewSize);
         Array.Resize(ref BiomassRemoved.dlt_dm_p, NewSize);
     }
     return(BiomassRemoved.dm_type.Length - 1);
 }
예제 #2
0
        /// <summary>Return a given amount of DM (and N) to surface organic matter</summary>
        /// <param name="amountDM">DM amount to return</param>
        /// <param name="amountN">N amount to return</param>
        private void DoSurfaceOMReturn(double amountDM, double amountN)
        {
            if (BiomassRemoved != null)
            {
                Single dDM = (Single)amountDM;

                PMF.BiomassRemovedType BR = new PMF.BiomassRemovedType();
                String[] type = new String[] { "grass" };  // TODO: this should be "pasture" ??
                Single[] dltdm = new Single[] { (Single)amountDM };
                Single[] dltn = new Single[] { (Single)amountN };
                Single[] dltp = new Single[] { 0 };         // P not considered here
                Single[] fraction = new Single[] { 1 };     // fraction is always 1.0 here

                BR.crop_type = "grass";   //TODO: this could be the Name, what is the diff between name and type??
                BR.dm_type = type;
                BR.dlt_crop_dm = dltdm;
                BR.dlt_dm_n = dltn;
                BR.dlt_dm_p = dltp;
                BR.fraction_to_residue = fraction;
                BiomassRemoved.Invoke(BR);
            }
        }
예제 #3
0
파일: Utility.cs 프로젝트: hol353/ApsimX
 public static int IncreaseSizeOfBiomassRemoved(BiomassRemovedType BiomassRemoved)
 {
     // Make sure the BiomassRemoved structure has enough elements in it.
     if (BiomassRemoved.dm_type == null)
     {
         BiomassRemoved.dm_type = new string[1];
         BiomassRemoved.fraction_to_residue = new float[1];
         BiomassRemoved.dlt_crop_dm = new float[1];
         BiomassRemoved.dlt_dm_n = new float[1];
         BiomassRemoved.dlt_dm_p = new float[1];
     }
     else
     {
         int NewSize = BiomassRemoved.dm_type.Length + 1;
         Array.Resize(ref BiomassRemoved.dm_type, NewSize);
         Array.Resize(ref BiomassRemoved.fraction_to_residue, NewSize);
         Array.Resize(ref BiomassRemoved.dlt_crop_dm, NewSize);
         Array.Resize(ref BiomassRemoved.dlt_dm_n, NewSize);
         Array.Resize(ref BiomassRemoved.dlt_dm_p, NewSize);
     }
     return BiomassRemoved.dm_type.Length - 1;
 }
예제 #4
0
        /// <summary>Returns a given amount of DM (and N) to surface organic matter.</summary>
        /// <param name="amountDM">DM amount to return (kg/ha)</param>
        /// <param name="amountN">N amount to return (kg/ha)</param>
        private void DoSurfaceOMReturn(double amountDM, double amountN)
        {
            if (BiomassRemoved != null)
            {
                BiomassRemovedType biomassData = new BiomassRemovedType();
                string[] type = {mySpeciesFamily.ToString()};
                float[] dltdm = {(float) amountDM};
                float[] dltn = {(float) amountN};
                float[] dltp = {0f}; // P not considered here
                float[] fraction = {1f}; // fraction is always 1.0 here

                biomassData.crop_type = "grass"; //TODO: this could be the Name, what is the diff between name and type??
                biomassData.dm_type = type;
                biomassData.dlt_crop_dm = dltdm;
                biomassData.dlt_dm_n = dltn;
                biomassData.dlt_dm_p = dltp;
                biomassData.fraction_to_residue = fraction;
                BiomassRemoved.Invoke(biomassData);
            }
        }
예제 #5
0
파일: Sugarcane.cs 프로젝트: hol353/ApsimX
        //called above
        /// <summary>
        /// Sugar_s the send_ crop_ chopped_ event.
        /// </summary>
        /// <param name="i_crop_type">The i_crop_type.</param>
        /// <param name="i_dm_type">The i_dm_type.</param>
        /// <param name="i_dlt_crop_dm">The i_dlt_crop_dm.</param>
        /// <param name="i_dlt_dm_n">The i_dlt_dm_n.</param>
        /// <param name="i_fraction_to_Residue">The i_fraction_to_ residue.</param>
        void sugar_Send_Crop_Chopped_Event(string i_crop_type, string[] i_dm_type, double[] i_dlt_crop_dm, double[] i_dlt_dm_n, double[] i_fraction_to_Residue)
        {
            //*+  Sub-Program Arguments
            //      character  crop_type*(*)              ! (INPUT) crop type
            //      character  dm_type(*)*(*)             ! (INPUT) residue type
            //      real  dlt_crop_dm(*)                  ! (INPUT) residue weight (kg/ha)
            //      real  dlt_dm_n(*)                     ! (INPUT) residue N weight (kg/ha)
            //      real  fraction_to_Residue(*)          ! (INPUT) residue fraction to residue (0-1)
            //      integer max_part                      ! (INPUT) number of residue types
            //*+  Purpose
            //*     Notify other modules of crop chopped.

            //*+  Mission Statement
            //*     Notify other modules of crop chopped.

            BiomassRemovedType CropChanges = new BiomassRemovedType();
            CropChanges.crop_type = i_crop_type;
            CropChanges.dm_type = i_dm_type;
            CropChanges.dlt_crop_dm = ToFloatArray(i_dlt_crop_dm);
            CropChanges.dlt_dm_n = ToFloatArray(i_dlt_dm_n);
            CropChanges.dlt_dm_p = new float[i_dlt_dm_n.Length];            //sv- this should return a zeroed float array.
            CropChanges.fraction_to_residue = ToFloatArray(i_fraction_to_Residue);

            //! send message regardless of fatal error - will stop anyway
            BiomassRemoved.Invoke(CropChanges);             //trigger/invoke the CropChopped Event
        }
예제 #6
0
파일: AgPasture.cs 프로젝트: hut104/ApsimX
        /// <summary>return plant litter to surface organic matter poor</summary>
        /// <param name="amtDM">The amt dm.</param>
        /// <param name="amtN">The amt n.</param>
        /// <param name="frac">The frac.</param>
        private void DoSurfaceOMReturn(Double amtDM, Double amtN, Double frac)
        {
            if (BiomassRemoved != null)
            {
                Single dDM = (Single)amtDM;

                PMF.BiomassRemovedType BR = new PMF.BiomassRemovedType();
                String[] type = new String[1];
                Single[] dltdm = new Single[1];
                Single[] dltn = new Single[1];
                Single[] dltp = new Single[1];
                Single[] fraction = new Single[1];

                type[0] = "grass";
                dltdm[0] = dDM;				 // kg/ha
                dltn[0] = (Single)amtN;		 // dDM * (Single)dead_nconc;
                dltp[0] = dltn[0] * 0.3F;	   //just a stub here, no P budgeting process in this module
                fraction[0] = (Single)frac;

                BR.crop_type = "grass";
                BR.dm_type = type;
                BR.dlt_crop_dm = dltdm;
                BR.dlt_dm_n = dltn;
                BR.dlt_dm_p = dltp;
                BR.fraction_to_residue = fraction;
                BiomassRemoved.Invoke(BR);
            }
        }