/// <summary> /// Sugar_harvests this instance. /// </summary> void sugar_harvest() { //*+ Purpose //* Report occurence of harvest and the current status of specific //* variables. //*+ Mission Statement //* Occurance of harvest //*+ Changes //* 070495 nih taken from template //* 191099 jngh changed to sugar_Send_Crop_Chopped_Event //* 101100 dph added eventInterface parameter to crop_root_incorp double l_biomass_dead; //! above ground dead plant wt (kg/ha) double l_biomass_green; //! above ground green plant wt (kg/ha) double l_biomass_senesced; //! above ground senesced plant wt (kg/ha) string l_cultivar_ratoon; double l_dm; //! above ground total dry matter (kg/ha) double l_leaf_no; //! total leaf number double l_N_dead; //! above ground dead plant N (kg/ha) double l_N_green; //! above ground green plant N (kg/ha) double l_N_senesced; //! above ground senesced plant N (kg/ha) double l_N_total; //! total gross nitrogen content (kg/ha) int l_phase; //! phenological phase number double l_si1; //! mean water stress type 1 double l_si2; //! mean water stress type 2 double l_si4; //! mean nitrogen stress type 1 double l_dm_root; //! (g/m^2) double l_N_root; //! (g/m^2) double l_dm_residue; //! (g/m^2) double l_N_residue; //! (g/m^2) double[] l_dlt_dm_crop = new double[max_part]; //! change in crop dry matter (kg/ha) double[] l_dlt_dm_N = new double[max_part]; //! N content of dry matter change (kg/ha) double[] l_fraction_to_Residue = new double[max_part]; //! fraction sent to residue (0-1) int l_hold_ratoon_no; double l_hold_dm_root; double l_hold_n_root; int l_hold_num_layers; double l_hold_root_depth; double[] l_hold_root_length = new double[max_layer]; //! crop harvested. Report status //******************************* if (Harvesting != null) Harvesting.Invoke(this, new EventArgs()); l_biomass_green = (SumArray(g_dm_green, max_part) - g_dm_green[root]) * gm2kg / sm2ha; l_biomass_senesced = (SumArray(g_dm_senesced, max_part) - g_dm_senesced[root]) * gm2kg / sm2ha; l_biomass_dead = (SumArray(g_dm_dead, max_part) - g_dm_dead[root]) * gm2kg / sm2ha; l_dm = (l_biomass_green + l_biomass_senesced + l_biomass_dead); l_leaf_no = sum_between_zb(zb(emerg), zb(now), g_leaf_no_zb); l_N_green = (SumArray(g_n_green, max_part) - g_n_green[root]) * gm2kg / sm2ha; l_N_senesced = (SumArray(g_n_senesced, max_part) - g_n_senesced[root]) * gm2kg / sm2ha; l_N_dead = (SumArray(g_n_dead, max_part) - g_n_dead[root]) * gm2kg / sm2ha; l_N_total = l_N_green + l_N_senesced + l_N_dead; //Summary.WriteMessage(this, ); //Summary.WriteMessage(this, ); Summary.WriteMessage(this, string.Format("{0}{1,4}", " flowering day = ", g_isdate)); //write (string, '(a,i4)') Summary.WriteMessage(this, string.Format("{0}{1,6:F3}", " maximum lai =", g_lai_max)); //write (string, '(a,f6.3)') Summary.WriteMessage(this, string.Format("{0}{1,10:F1}", " total above ground biomass (kg/ha) =", l_dm)); //write (string, '(a,f10.1)') Summary.WriteMessage(this, string.Format("{0}{1,10:F1}", " (green + senesced) above ground biomass (kg/ha) =", l_biomass_green + l_biomass_senesced)); //write (string, '(a,f10.1)') Summary.WriteMessage(this, string.Format("{0}{1,10:F1}", " green above ground biomass (kg/ha) =", l_biomass_green)); //write (string, '(a,f10.1)') Summary.WriteMessage(this,string.Format( "{0}{1,10:F1}", " senesced above ground biomass (kg/ha) =", l_biomass_senesced)); //write (string, '(a,f10.1)') Summary.WriteMessage(this, string.Format("{0}{1,10:F1}", " dead above ground biomass (kg/ha) =", l_biomass_dead)); //write (string, '(a,f10.1)') Summary.WriteMessage(this, string.Format("{0}{1,6:F1}", " number of leaves =", l_leaf_no)); //write (string, '(a,f6.1)') Summary.WriteMessage(this, string.Format("{0}{1,10:F2}{2}{3}{4,10:F2}", " total N content (kg/ha) =", l_N_total, " ", " senesced N content (kg/ha) =", l_N_senesced)); //write (string, '(a,f10.2,t40,a,f10.2)') //sv- to compensate for t40 (tab to column 40) I just added four spaces. (26 + 10 = 36) + 4 = 40 Summary.WriteMessage(this, string.Format("{0}{1,10:F2}{2}{3}{4,10:F2}", " green N content (kg/ha) =", l_N_green, " ", " dead N content (kg/ha) =", l_N_dead)); //write (string, '(a,f10.2,t40,a,f10.2)') //sv- to compensate for t40 (tab to column 40) I just added two spaces. (26 + 10 = 36) + 4 = 40 for (l_phase = zb(emerg_to_begcane); l_phase <= zb(flowering_to_crop_end); l_phase++) { l_si1 = MathUtilities.Divide(g_cswd_photo[l_phase], g_days_tot[l_phase], 0.0); l_si2 = MathUtilities.Divide(g_cswd_expansion[l_phase], g_days_tot[l_phase], 0.0); l_si4 = MathUtilities.Divide(g_cnd_photo[l_phase], g_days_tot[l_phase], 0.0); //Summary.WriteMessage(this, ); //Summary.WriteMessage(this, ); Summary.WriteMessage(this, " stress indices for " + crop.stage_names[l_phase]); Summary.WriteMessage(this, string.Format("{0}{1,16:E2}{2}{3,16:E2}", " water stress 1 =", l_si1, " nitrogen stress 1 =", l_si4)); //write (string,'(2(a, g16.7e2))') Summary.WriteMessage(this, string.Format("{0}{1,16:E2}", " water stress 2 =", l_si2)); //write (string,'(a, g16.7e2)') } //! the following is a copy/adaption of sugar_end_crop //**************************************************** if (g_crop_status != crop_out) { //! report //! now do post harvest processes l_dm_root = g_dm_green[root] * crop.root_die_back_fr + g_dm_dead[root] + g_dm_senesced[root]; l_N_root = g_n_green[root] * crop.root_die_back_fr + g_n_dead[root] + g_n_senesced[root]; //! put stover into surface residue //Dry Matter l_dm_residue = (SumArray(g_dm_green, max_part) - g_dm_green[root] - g_dm_green[sstem] - g_dm_green[sucrose]) //stem and surose goes to the mill not to residue + (SumArray(g_dm_senesced, max_part) - g_dm_senesced[root]) + (SumArray(g_dm_dead, max_part) - g_dm_dead[root]); for (int p = 0; p < max_part; p++) { l_dlt_dm_crop[p] = (g_dm_green[p] + g_dm_senesced[p] + g_dm_dead[p]) * gm2kg / sm2ha; } l_dlt_dm_crop[root] = l_dm_root * gm2kg / sm2ha; //Nitrogen l_N_residue = (SumArray(g_n_green, max_part) - g_n_green[root] - g_n_green[sstem] - g_n_green[sucrose]) //stem and surose goes to the mill not to residue + (SumArray(g_n_senesced, max_part) - g_n_senesced[root]) + (SumArray(g_n_dead, max_part) - g_n_dead[root]); for (int p = 0; p < max_part; p++) { l_dlt_dm_N[p] = (g_n_green[p] + g_n_senesced[p] + g_n_dead[p]) * gm2kg / sm2ha; } l_dlt_dm_N[root] = l_N_root * gm2kg / sm2ha; //TODO: put this back in. Better then below where you refer to "straw". //Console.WriteLine( " Organic matter from crop:- Leaves&Cabbage to surface residue Roots to soil FOM"); //Console.WriteLine("{0}{1,22:F1}{2,44:F3}", " DM (kg/ha) =", (l_dm_residue * gm2kg / sm2ha), (l_dm_root * gm2kg / sm2ha)); //Console.WriteLine("{0}{1,22:F1}{2,44:F3}", " N (kg/ha) =", (l_N_residue * gm2kg / sm2ha), (l_N_root * gm2kg / sm2ha)); //Console.WriteLine( "Organic matter removed from system:- Stem&Sucrose to mill"); //Console.WriteLine("{0}{1,22:F1}", " DM (kg/ha) =", (g_dm_green[sstem] + g_dm_green[sucrose]) * gm2kg / sm2ha ); //Console.WriteLine("{0}{1,22:F1}", " N (kg/ha) =", (g_n_green[sstem] + g_n_green[sucrose]) * gm2kg / sm2ha); string l_40spaces = " "; Summary.WriteMessage(this, string.Format("{0}{1}{2,7:F1}{3}", l_40spaces, " straw residue =", l_dm_residue * gm2kg / sm2ha, " kg/ha")); Summary.WriteMessage(this, string.Format("{0}{1}{2,6:F1}{3}", l_40spaces, " straw N = ", l_N_residue * gm2kg / sm2ha, " kg/ha")); Summary.WriteMessage(this, string.Format("{0}{1}{2,6:F1}{3}", l_40spaces, " root residue = ", l_dm_root * gm2kg / sm2ha, " kg/ha")); Summary.WriteMessage(this, string.Format("{0}{1}{2,6:F1}{3}", l_40spaces, " root N = ", l_N_root * gm2kg / sm2ha, " kg/ha")); // write (string, '(40x, a, f7.1, a, 3(a, 40x, a, f6.1, a))') //: ' straw residue =' //: , dm_residue * gm2kg /sm2ha, ' kg/ha' //: , new_line //: , ' straw N = ' //: , N_residue * gm2kg /sm2ha, ' kg/ha' //: , new_line //: , ' root residue = ' //: , dm_root * gm2kg /sm2ha, ' kg/ha' //: , new_line //: , ' root N = ' //: , N_root * gm2kg /sm2ha, ' kg/ha' crop_root_incorp(l_dm_root, l_N_root, dlayer, g_root_length, g_root_depth, crop_type, max_layer); for (int p = 0; p < max_part; p++) { l_fraction_to_Residue[p] = 1.0; } l_fraction_to_Residue[root] = 0.0; l_fraction_to_Residue[sstem] = 0.0; l_fraction_to_Residue[sucrose] = 0.0; if (SumArray(l_dlt_dm_crop, max_part) > 0.0) { sugar_Send_Crop_Chopped_Event(crop_type, part_name, l_dlt_dm_crop, l_dlt_dm_N, l_fraction_to_Residue); } else { //! no surface residue } //sv- temporarily store some values l_hold_ratoon_no = g_ratoon_no; l_hold_dm_root = g_dm_green[root] * (1.0 - crop.root_die_back_fr); l_hold_n_root = g_n_green[root] * (1.0 - crop.root_die_back_fr); l_hold_num_layers = num_layers; l_hold_root_depth = g_root_depth; //for (int layer=0; layer < max_layer; layer++) for (int layer = 0; layer < g_root_length.Length; layer++) { l_hold_root_length[layer] = g_root_length[layer] * (1.0 - crop.root_die_back_fr); } //sv - zero everything sugar_zero_globals(); sugar_zero_daily_variables(); //sv- use stored values to set them back g_current_stage = (double)sprouting; g_ratoon_no = l_hold_ratoon_no + 1; g_dm_green[root] = l_hold_dm_root; g_n_green[root] = l_hold_n_root; //num_layers = l_hold_num_layers; //sv- num_layers is not settable. g_root_depth = l_hold_root_depth; g_plants = g_initial_plant_density; //for (int layer=0; layer < max_layer; layer++) for (int layer = 0; layer < g_root_length.Length; layer++) { g_root_length[layer] = l_hold_root_length[layer]; } //! now update constants if need be (after havest a plant crop change it to a ratoon crop) if (g_ratoon_no == 1) { crop = sugar_read_crop_constants("ratoon_crop"); l_cultivar_ratoon = g_crop_cultivar + "_ratoon"; cult = sugar_read_cultivar_params(l_cultivar_ratoon); } else { //! only need to update constants when we move from a plant crop to a ratoon crop. } } }
//void sugar_start_crop(SowType i_SowData) /// <summary> /// Sugar_start_crops the specified plants. /// </summary> /// <param name="plants">The plants.</param> /// <param name="Ratoon">The ratoon.</param> /// <param name="sowing_depth">The sowing_depth.</param> /// <param name="Cultivar">The cultivar.</param> /// <exception cref="ApsimXException"> /// \Sugarcane\ was taken out today by \end_crop\ action - /// + \n /// + Unable to accept sow action until the next day. /// or /// \Sugarcane\ is still in the ground - unable to sow until it is taken out by \end_crop\ action. /// </exception> void sugar_start_crop(double plants, int Ratoon, double sowing_depth, string Cultivar) { //*+ Purpose //* Start crop using parameters specified in passed record //*+ Mission Statement //* Start the crop based on passed parameters //*+ Changes //* 041095 nih changed start of ratton crop from emergence to sprouting string l_cultivar; //! name of cultivar string l_cultivar_ratoon; //! name of cultivar ratoon section if (g_crop_status == crop_out) { if (!g_plant_status_out_today) { //! request and receive variables from owner-modules //call sugar_get_met_variables () sugar_get_soil_variables(ref g_no3gsm, ref g_no3gsm_min, ref g_nh4gsm, ref g_nh4gsm_min); Summary.WriteMessage(this, "Sowing initiate"); if (Sowing != null) Sowing.Invoke(this, new EventArgs()); //g_plants = i_SowData.plants; //g_initial_plant_density = g_plants; //g_ratoon_no = i_SowData.Ratoon; //g_sowing_depth = i_SowData.sowing_depth; //l_cultivar = i_SowData.Cultivar; g_plants = plants; g_initial_plant_density = g_plants; //save the intial value of plants because as the crop grows g_plants will be modified. g_ratoon_no = Ratoon; g_sowing_depth = sowing_depth; l_cultivar = Cultivar; //! report Summary.WriteMessage(this, Environment.NewLine + Environment.NewLine); Summary.WriteMessage(this, " Crop Sowing Data"); Summary.WriteMessage(this, " ------------------------------------------------"); Summary.WriteMessage(this, " Sowing Depth Plants Cultivar"); Summary.WriteMessage(this, " Day no mm m^2 Name "); Summary.WriteMessage(this, " ------------------------------------------------"); //http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx Summary.WriteMessage(this, string.Format("{0}{1,7:D}{2,7:F1}{3,7:F1}{4}{5,-10}", " ", g_day_of_year, g_sowing_depth, g_plants, " ", l_cultivar)); //parameters are zero based. // write (string, '(3x, i7, 2f7.1, 1x, a10)') //: g%day_of_year, g%sowing_depth //: , g%Population, cultivar Summary.WriteMessage(this, " ------------------------------------------------"); //! get cultivar parameters if (g_ratoon_no == 0) { crop = sugar_read_crop_constants("plant_crop"); cult = sugar_read_cultivar_params(l_cultivar); } else { crop = sugar_read_crop_constants("ratoon_crop"); l_cultivar_ratoon = l_cultivar + "_ratoon"; cult = sugar_read_cultivar_params(l_cultivar_ratoon); } //! get root profile parameters sugar_read_root_params(); //different if using (SoilWat or SWIM) or Eo modules in the simulation if (g_ratoon_no == 0) g_current_stage = (double)sowing; else g_current_stage = (double)sowing; g_crop_status = crop_alive; g_crop_cultivar = l_cultivar; } else { throw new ApsimXException(this, "\"Sugarcane\" was taken out today by \"end_crop\" action -" + "\n" + " Unable to accept sow action until the next day."); } } else { throw new ApsimXException(this, "\"Sugarcane\" is still in the ground - unable to sow until it is taken out by \"end_crop\" action."); } }