{
  "$type": "Models.Core.Simulations, Models",
  "Version": 206,
  "Name": "Simulations",
  "ResourceName": null,
  "Children": [
    {
      "$type": "Models.Storage.DataStore, Models",
      "CustomFileName": null,
      "Name": "DataStore",
      "ResourceName": null,
      "Children": [],
      "Enabled": true,
      "ReadOnly": false
    },
    {
      "$type": "Models.Core.Simulation, Models",
      "Descriptors": null,
      "Name": "CropRotation_flexible_final",
      "ResourceName": null,
      "Children": [
        {
          "$type": "Models.Clock, Models",
          "Start": "1985-01-01T00:00:00",
          "End": "1999-12-31T00:00:00",
          "Name": "Clock",
          "ResourceName": null,
          "Children": [],
          "Enabled": true,
          "ReadOnly": false
        },
        {
          "$type": "Models.Summary, Models",
          "Verbosity": 100,
          "Name": "Summary",
          "ResourceName": null,
          "Children": [],
          "Enabled": true,
          "ReadOnly": false
        },
        {
          "$type": "Models.Climate.Weather, Models",
          "ConstantsFile": null,
          "FileName": "%root%/Examples/WeatherFiles/AU_Dalby.met",
          "ExcelWorkSheetName": "",
          "Name": "Weather",
          "ResourceName": null,
          "Children": [],
          "Enabled": true,
          "ReadOnly": false
        },
        {
          "$type": "Models.Soils.Arbitrator.SoilArbitrator, Models",
          "Name": "SoilArbitrator",
          "ResourceName": null,
          "Children": [],
          "Enabled": true,
          "ReadOnly": false
        },
        {
          "$type": "Models.Core.Zone, Models",
          "Area": 1.0,
          "Slope": 0.0,
          "AspectAngle": 0.0,
          "Altitude": 50.0,
          "CanopyType": null,
          "Name": "Paddock",
          "ResourceName": null,
          "Children": [
            {
              "$type": "Models.Report, Models",
              "VariableNames": [
                "[Clock].Today",
                "[SurfaceOrganicMatter].Cover",
                "[SurfaceOrganicMatter].Wt",
                "[ISoilWater].Runoff",
                "Sum([Soil].Nutrient.Organic.C) as SoilOrganicC_fullProfile",
                "Sum([Soil].Nutrient.Organic.N) as SoilOrganicN_fullProfile",
                "Sum([Soil].Nutrient.MineralisedN) as MineralisedN_fullProfile",
                "Sum([Soil].Water.Volumetric) as SoilWatVolumetric_fullProfile",
                "Sum([Nutrient].MineralisedN) as MineralisedN_fullProfile",
                "Sum([Nitrification].Value + [Nitrification].Natm) as Nitrification_total",
                "Sum([Denitrification].Value + [Denitrification].Natm) as Denitrification_total"
              ],
              "EventNames": [
                "[Clock].EndOfDay"
              ],
              "GroupByVariableName": null,
              "Name": "DailyReport",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Report, Models",
              "VariableNames": [
                "[Clock].Today",
                "[Sorghum].Grain.Wt",
                "[Sorghum].AboveGround.Wt",
                "[Sorghum].Leaf.LAI"
              ],
              "EventNames": [
                "[Sorghum].Harvesting"
              ],
              "GroupByVariableName": null,
              "Name": "HarvestReport_sorghum",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Report, Models",
              "VariableNames": [
                "[Clock].Today",
                "[Mungbean].Grain.Wt",
                "[Mungbean].AboveGround.Wt",
                "[Mungbean].Leaf.LAI"
              ],
              "EventNames": [
                "[Mungbean].Harvesting"
              ],
              "GroupByVariableName": null,
              "Name": "HarvestReport_mungbean",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Report, Models",
              "VariableNames": [
                "[Clock].Today",
                "[Wheat].Grain.Wt",
                "[Wheat].AboveGround.Wt",
                "[Wheat].Leaf.LAI"
              ],
              "EventNames": [
                "[Wheat].Harvesting"
              ],
              "GroupByVariableName": null,
              "Name": "HarvestReport_wheat",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Report, Models",
              "VariableNames": [
                "[Clock].Today",
                "[Chickpea].Grain.Wt",
                "[Chickpea].AboveGround.Wt",
                "[Chickpea].Leaf.LAI"
              ],
              "EventNames": [
                "[Chickpea].Harvesting"
              ],
              "GroupByVariableName": null,
              "Name": "HarvestReport_chickpea",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Fertiliser, Models",
              "Name": "Fertiliser",
              "ResourceName": "Fertiliser",
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.MicroClimate, Models",
              "a_interception": 0.0,
              "b_interception": 1.0,
              "c_interception": 0.0,
              "d_interception": 0.0,
              "SoilHeatFluxFraction": 0.4,
              "MinimumHeightDiffForNewLayer": 0.0,
              "NightInterceptionFraction": 0.5,
              "ReferenceHeight": 2.0,
              "Name": "MicroClimate",
              "ResourceName": "MicroClimate",
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Soils.Soil, Models",
              "RecordNumber": 0,
              "ASCOrder": null,
              "ASCSubOrder": null,
              "SoilType": "HMM",
              "LocalName": null,
              "Site": "HRS",
              "NearestTown": "Unknown",
              "Region": "SE Queensland",
              "State": null,
              "Country": null,
              "NaturalVegetation": "Unknown",
              "ApsoilNumber": null,
              "Latitude": -27.18,
              "Longitude": 151.26,
              "LocationAccuracy": null,
              "YearOfSampling": null,
              "DataSource": null,
              "Comments": null,
              "Name": "HRS",
              "ResourceName": null,
              "Children": [
                {
                  "$type": "Models.Soils.Physical, Models",
                  "Thickness": [
                    100.0,
                    100.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0
                  ],
                  "ParticleSizeSand": [
                    5.0,
                    5.0,
                    5.0,
                    5.0,
                    5.0,
                    5.0,
                    5.0,
                    5.0,
                    5.0,
                    5.0
                  ],
                  "ParticleSizeSilt": [
                    65.0,
                    65.0,
                    65.0,
                    65.0,
                    65.0,
                    65.0,
                    65.0,
                    65.0,
                    65.0,
                    65.0
                  ],
                  "ParticleSizeClay": [
                    30.0,
                    30.0,
                    30.0,
                    30.0,
                    30.0,
                    30.0,
                    30.0,
                    30.0,
                    30.0,
                    30.0
                  ],
                  "Rocks": [
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0
                  ],
                  "Texture": null,
                  "BD": [
                    1.34,
                    1.34,
                    1.33,
                    1.38,
                    1.4,
                    1.55,
                    1.59,
                    1.63,
                    1.66,
                    1.68
                  ],
                  "AirDry": [
                    0.08,
                    0.19,
                    0.23,
                    0.26,
                    0.26,
                    0.28,
                    0.25,
                    0.28,
                    0.3,
                    0.31
                  ],
                  "LL15": [
                    0.226,
                    0.226,
                    0.258,
                    0.27,
                    0.268,
                    0.304,
                    0.335,
                    0.33,
                    0.32,
                    0.33
                  ],
                  "DUL": [
                    0.42,
                    0.42,
                    0.46,
                    0.46,
                    0.43,
                    0.4,
                    0.37,
                    0.33,
                    0.32,
                    0.33
                  ],
                  "SAT": [
                    0.45,
                    0.45,
                    0.48,
                    0.47,
                    0.45,
                    0.41,
                    0.38,
                    0.37,
                    0.37,
                    0.36
                  ],
                  "KS": null,
                  "BDMetadata": null,
                  "AirDryMetadata": null,
                  "LL15Metadata": null,
                  "DULMetadata": null,
                  "SATMetadata": null,
                  "KSMetadata": null,
                  "RocksMetadata": [
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated"
                  ],
                  "TextureMetadata": null,
                  "ParticleSizeSandMetadata": [
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated"
                  ],
                  "ParticleSizeSiltMetadata": [
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated"
                  ],
                  "ParticleSizeClayMetadata": [
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated"
                  ],
                  "Name": "Physical",
                  "ResourceName": null,
                  "Children": [
                    {
                      "$type": "Models.Soils.SoilCrop, Models",
                      "LL": [
                        0.226,
                        0.226,
                        0.258,
                        0.27,
                        0.268,
                        0.304,
                        0.335,
                        0.33,
                        0.32,
                        0.33
                      ],
                      "KL": [
                        0.07,
                        0.07,
                        0.07,
                        0.07,
                        0.06,
                        0.06,
                        0.06,
                        0.05,
                        0.05,
                        0.04
                      ],
                      "XF": [
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0
                      ],
                      "LLMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "KLMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "XFMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "Name": "SorghumSoil",
                      "ResourceName": null,
                      "Children": [],
                      "Enabled": true,
                      "ReadOnly": false
                    },
                    {
                      "$type": "Models.Soils.SoilCrop, Models",
                      "LL": [
                        0.226,
                        0.226,
                        0.258,
                        0.27,
                        0.268,
                        0.304,
                        0.335,
                        0.33,
                        0.32,
                        0.33
                      ],
                      "KL": [
                        0.06,
                        0.06,
                        0.06,
                        0.06,
                        0.04,
                        0.04,
                        0.04,
                        0.02,
                        0.02,
                        0.01
                      ],
                      "XF": [
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0
                      ],
                      "LLMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "KLMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "XFMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "Name": "WheatSoil",
                      "ResourceName": null,
                      "Children": [],
                      "Enabled": true,
                      "ReadOnly": false
                    },
                    {
                      "$type": "Models.Soils.SoilCrop, Models",
                      "LL": [
                        0.24,
                        0.24,
                        0.275,
                        0.295,
                        0.29,
                        0.33,
                        0.35,
                        0.33,
                        0.32,
                        0.33
                      ],
                      "KL": [
                        0.06,
                        0.06,
                        0.06,
                        0.06,
                        0.04,
                        0.04,
                        0.04,
                        0.0,
                        0.0,
                        0.0
                      ],
                      "XF": [
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0
                      ],
                      "LLMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "KLMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "XFMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "Name": "MungbeanSoil",
                      "ResourceName": null,
                      "Children": [],
                      "Enabled": true,
                      "ReadOnly": false
                    },
                    {
                      "$type": "Models.Soils.SoilCrop, Models",
                      "LL": [
                        0.24,
                        0.24,
                        0.275,
                        0.295,
                        0.29,
                        0.33,
                        0.35,
                        0.33,
                        0.32,
                        0.33
                      ],
                      "KL": [
                        0.06,
                        0.06,
                        0.06,
                        0.06,
                        0.04,
                        0.04,
                        0.04,
                        0.0,
                        0.0,
                        0.0
                      ],
                      "XF": [
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0,
                        1.0
                      ],
                      "LLMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "KLMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "XFMetadata": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                      ],
                      "Name": "ChickpeaSoil",
                      "ResourceName": null,
                      "Children": [],
                      "Enabled": true,
                      "ReadOnly": false
                    }
                  ],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.WaterModel.WaterBalance, Models",
                  "SummerDate": "1-Nov",
                  "SummerU": 1.5,
                  "SummerCona": 6.5,
                  "WinterDate": "1-Apr",
                  "WinterU": 1.5,
                  "WinterCona": 6.5,
                  "DiffusConst": 40.0,
                  "DiffusSlope": 16.0,
                  "Salb": 0.2,
                  "CN2Bare": 85.0,
                  "CNRed": 20.0,
                  "CNCov": 0.8,
                  "DischargeWidth": "NaN",
                  "CatchmentArea": "NaN",
                  "PSIDul": -100.0,
                  "Thickness": [
                    100.0,
                    100.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0
                  ],
                  "SWCON": [
                    0.3,
                    0.3,
                    0.3,
                    0.3,
                    0.3,
                    0.3,
                    0.3,
                    0.3,
                    0.3,
                    0.3
                  ],
                  "KLAT": null,
                  "Name": "SoilWater",
                  "ResourceName": "WaterBalance",
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.Soils.Nutrients.Nutrient, Models",
                  "Name": "Nutrient",
                  "ResourceName": "Nutrient",
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.Soils.Organic, Models",
                  "FOMCNRatio": 50.0,
                  "Thickness": [
                    100.0,
                    100.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0
                  ],
                  "Carbon": [
                    1.19,
                    0.59,
                    0.45,
                    0.3,
                    0.2,
                    0.16,
                    0.17,
                    0.17,
                    0.17,
                    0.17
                  ],
                  "CarbonUnits": 0,
                  "SoilCNRatio": [
                    12.5,
                    12.5,
                    12.5,
                    12.5,
                    12.5,
                    12.5,
                    12.5,
                    12.5,
                    12.5,
                    12.5
                  ],
                  "FBiom": [
                    0.05,
                    0.02,
                    0.01,
                    0.01,
                    0.01,
                    0.01,
                    0.01,
                    0.05,
                    0.02,
                    0.01
                  ],
                  "FInert": [
                    0.45,
                    0.6,
                    0.75,
                    0.9,
                    0.9,
                    0.9,
                    0.9,
                    0.9,
                    0.9,
                    0.9
                  ],
                  "FOM": [
                    260.58740315916066,
                    220.5824745109322,
                    158.0542495509277,
                    113.25081857248298,
                    81.14775745529565,
                    58.14490899956697,
                    41.66264784865344,
                    29.852591664969907,
                    21.390316629725067,
                    15.32683160828522
                  ],
                  "CarbonMetadata": null,
                  "FOMMetadata": null,
                  "Name": "Organic",
                  "ResourceName": null,
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.Soils.Chemical, Models",
                  "Thickness": [
                    100.0,
                    100.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0
                  ],
                  "PH": [
                    6.3,
                    6.4,
                    6.5,
                    6.6,
                    6.6,
                    6.5,
                    6.5,
                    6.5,
                    6.5,
                    6.5
                  ],
                  "PHUnits": 0,
                  "EC": null,
                  "ESP": null,
                  "CEC": [
                    11.0225,
                    9.672500000000001,
                    9.3575,
                    9.020000000000001,
                    8.795,
                    8.705,
                    8.727500000000001,
                    8.727500000000001,
                    8.727500000000001,
                    8.727500000000001
                  ],
                  "ECMetadata": null,
                  "CLMetadata": null,
                  "CECMetadata": [
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated",
                    "Calculated"
                  ],
                  "ESPMetadata": null,
                  "PHMetadata": null,
                  "Name": "Chemical",
                  "ResourceName": null,
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.Soils.Water, Models",
                  "Thickness": [
                    100.0,
                    100.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0
                  ],
                  "InitialValues": [
                    0.32299999999999995,
                    0.32299999999999995,
                    0.359,
                    0.365,
                    0.349,
                    0.35200000000000004,
                    0.3525,
                    0.33,
                    0.32,
                    0.33
                  ],
                  "FilledFromTop": false,
                  "Name": "Water",
                  "ResourceName": null,
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.Soils.Solute, Models",
                  "Thickness": [
                    100.0,
                    100.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0
                  ],
                  "InitialValues": [
                    10.4,
                    1.6329999999999996,
                    1.2330000000000008,
                    0.9,
                    1.1,
                    1.4670000000000005,
                    3.6329999999999996,
                    5.667000000000001,
                    5.8,
                    7.267000000000003
                  ],
                  "InitialValuesUnits": 0,
                  "WaterTableConcentration": 0.0,
                  "D0": 0.0,
                  "Exco": null,
                  "FIP": null,
                  "DepthConstant": 0.0,
                  "MaxDepthSoluteAccessible": 0.0,
                  "RunoffEffectivenessAtMovingSolute": 0.0,
                  "MaxEffectiveRunoff": 0.0,
                  "ConcInSolution": null,
                  "Name": "NO3",
                  "ResourceName": null,
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.Soils.Solute, Models",
                  "Thickness": [
                    100.0,
                    100.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0
                  ],
                  "InitialValues": [
                    0.1,
                    0.1,
                    0.1,
                    0.1,
                    0.1,
                    0.1,
                    0.1,
                    0.1,
                    0.1,
                    0.1
                  ],
                  "InitialValuesUnits": 0,
                  "WaterTableConcentration": 0.0,
                  "D0": 0.0,
                  "Exco": null,
                  "FIP": null,
                  "DepthConstant": 0.0,
                  "MaxDepthSoluteAccessible": 0.0,
                  "RunoffEffectivenessAtMovingSolute": 0.0,
                  "MaxEffectiveRunoff": 0.0,
                  "ConcInSolution": null,
                  "Name": "NH4",
                  "ResourceName": null,
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.Soils.Solute, Models",
                  "Thickness": [
                    100.0,
                    100.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0,
                    200.0
                  ],
                  "InitialValues": [
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0
                  ],
                  "InitialValuesUnits": 1,
                  "WaterTableConcentration": 0.0,
                  "D0": 0.0,
                  "Exco": null,
                  "FIP": null,
                  "DepthConstant": 0.0,
                  "MaxDepthSoluteAccessible": 0.0,
                  "RunoffEffectivenessAtMovingSolute": 0.0,
                  "MaxEffectiveRunoff": 0.0,
                  "ConcInSolution": null,
                  "Name": "Urea",
                  "ResourceName": null,
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                },
                {
                  "$type": "Models.Soils.SoilTemp.SoilTemperature, Models",
                  "Thickness": null,
                  "InitialValues": null,
                  "Name": "Temperature",
                  "ResourceName": null,
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                }
              ],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.PMF.Plant, Models",
              "Name": "Sorghum",
              "ResourceName": "Sorghum",
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.PMF.Plant, Models",
              "Name": "Mungbean",
              "ResourceName": "Mungbean",
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.PMF.Plant, Models",
              "Name": "Wheat",
              "ResourceName": "Wheat",
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.PMF.Plant, Models",
              "Name": "Chickpea",
              "ResourceName": "Chickpea",
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Surface.SurfaceOrganicMatter, Models",
              "SurfOM": [],
              "Canopies": [],
              "InitialResidueName": "wheat_stubble",
              "InitialResidueType": "wheat",
              "InitialResidueMass": 0.0,
              "InitialStandingFraction": 0.0,
              "InitialCPR": 0.0,
              "InitialCNR": 80.0,
              "Name": "SurfaceOrganicMatter",
              "ResourceName": "SurfaceOrganicMatter",
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Management.RotationManager, Models",
              "Nodes": [
                {
                  "$type": "APSIM.Shared.Graphing.Node, APSIM.Shared",
                  "Description": "",
                  "Transparent": false,
                  "ID": 1,
                  "Name": "Sorghum",
                  "Location": "264, 118",
                  "Colour": "158, 77, 77"
                },
                {
                  "$type": "APSIM.Shared.Graphing.Node, APSIM.Shared",
                  "Description": "",
                  "Transparent": false,
                  "ID": 3,
                  "Name": "Mungbean",
                  "Location": "693, 446",
                  "Colour": "97, 172, 126"
                },
                {
                  "$type": "APSIM.Shared.Graphing.Node, APSIM.Shared",
                  "Description": "",
                  "Transparent": false,
                  "ID": 4,
                  "Name": "Fallow",
                  "Location": "487, 281",
                  "Colour": "192, 191, 188"
                },
                {
                  "$type": "APSIM.Shared.Graphing.Node, APSIM.Shared",
                  "Description": "",
                  "Transparent": false,
                  "ID": 7,
                  "Name": "Wheat",
                  "Location": "694, 124",
                  "Colour": "246, 211, 45"
                },
                {
                  "$type": "APSIM.Shared.Graphing.Node, APSIM.Shared",
                  "Description": "",
                  "Transparent": false,
                  "ID": 8,
                  "Name": "Chickpea",
                  "Location": "265, 451",
                  "Colour": "241, 203, 132"
                }
              ],
              "Arcs": [
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 1,
                  "DestinationID": 4,
                  "Conditions": [
                    "[SowHarvest_sorghum].Script.CanHarvest",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_sorghum].Script.HarvestCrop()",
                    ""
                  ],
                  "ID": 2,
                  "Name": "Exit SG",
                  "Location": "344, 215",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 4,
                  "DestinationID": 1,
                  "Conditions": [
                    "[SowHarvest_sorghum].Script.CanSow",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_sorghum].Script.SowCrop()",
                    ""
                  ],
                  "ID": 5,
                  "Name": "Enter SG",
                  "Location": "399, 190",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 8,
                  "DestinationID": 4,
                  "Conditions": [
                    "[SowHarvest_chickpea].Script.CanHarvest",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_chickpea].Script.HarvestCrop()",
                    ""
                  ],
                  "ID": 6,
                  "Name": "Exit CP",
                  "Location": "352, 342",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 4,
                  "DestinationID": 8,
                  "Conditions": [
                    "[SowHarvest_chickpea].Script.CanSow",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_chickpea].Script.SowCrop()",
                    ""
                  ],
                  "ID": 9,
                  "Name": "Enter CP",
                  "Location": "414, 386",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 4,
                  "DestinationID": 7,
                  "Conditions": [
                    "[SowHarvest_wheat].Script.CanSow",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_wheat].Script.SowCrop()",
                    ""
                  ],
                  "ID": 10,
                  "Name": "Enter WH",
                  "Location": "569, 180",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 7,
                  "DestinationID": 4,
                  "Conditions": [
                    "[SowHarvest_wheat].Script.CanHarvest",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_wheat].Script.HarvestCrop()",
                    ""
                  ],
                  "ID": 11,
                  "Name": "Exit WH",
                  "Location": "635, 219",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 4,
                  "DestinationID": 3,
                  "Conditions": [
                    "[SowHarvest_mungbean].Script.CanSow",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_mungbean].Script.SowCrop()",
                    ""
                  ],
                  "ID": 12,
                  "Name": "Enter MB",
                  "Location": "564, 383",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 3,
                  "DestinationID": 4,
                  "Conditions": [
                    "[SowHarvest_mungbean].Script.CanHarvest",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_mungbean].Script.HarvestCrop()",
                    ""
                  ],
                  "ID": 13,
                  "Name": "Exit MB",
                  "Location": "613, 347",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 1,
                  "DestinationID": 4,
                  "Conditions": [
                    "[SowHarvest_sorghum].Script.MustAbandon",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_sorghum].Script.AbandonCrop()",
                    ""
                  ],
                  "ID": 14,
                  "Name": "Abandon SG",
                  "Location": "278, 241",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 7,
                  "DestinationID": 4,
                  "Conditions": [
                    "[SowHarvest_wheat].Script.MustAbandon",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_wheat].Script.AbandonCrop()",
                    ""
                  ],
                  "ID": 15,
                  "Name": "Abandon WH",
                  "Location": "684, 251",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 3,
                  "DestinationID": 4,
                  "Conditions": [
                    "[SowHarvest_mungbean].Script.MustAbandon",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_mungbean].Script.AbandonCrop()",
                    ""
                  ],
                  "ID": 16,
                  "Name": "Abandon MB",
                  "Location": "649, 326",
                  "Colour": ""
                },
                {
                  "$type": "APSIM.Shared.Graphing.Arc, APSIM.Shared",
                  "SourceID": 8,
                  "DestinationID": 4,
                  "Conditions": [
                    "[SowHarvest_chickpea].Script.MustAbandon",
                    ""
                  ],
                  "Actions": [
                    "[SowHarvest_chickpea].Script.AbandonCrop()",
                    ""
                  ],
                  "ID": 17,
                  "Name": "Abandon CP",
                  "Location": "306, 318",
                  "Colour": ""
                }
              ],
              "TopLevel": true,
              "InitialState": "Fallow",
              "Verbose": true,
              "Name": "RotationManager",
              "ResourceName": null,
              "Children": [
                {
                  "$type": "Models.Management.RotationRugplot, Models",
                  "SimulationName": "CropRotation_flexible_final",
                  "CurrentPaddockString": null,
                  "Name": "RotationRugplot",
                  "ResourceName": null,
                  "Children": [],
                  "Enabled": true,
                  "ReadOnly": false
                }
              ],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using System;",
                "using Models.Core;",
                "",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class CropSequenceEnforcer : Model",
                "    {",
                "        // Crop history",
                "        private string previousCrop1 = null;   // Most recent harvested crop",
                "        private string previousCrop2 = null;   // Second most recent harvested crop",
                "",
                "        // Check if the proposed crop is allowed under given cropping sequence rules",
                "        public bool AllowsSowing(string crop)",
                "        {",
                "            crop = crop.ToLower();",
                "",
                "            bool isCereal  = crop == \"sorghum\" || crop == \"wheat\";",
                "            bool isLegume  = crop == \"mungbean\" || crop == \"chickpea\";",
                "",
                "            if (!isCereal && !isLegume)",
                "                throw new Exception($\"CropSequenceEnforcer: Unknown crop '{crop}'.\");",
                "",
                "            // No history yet → allow only cereals",
                "            if (previousCrop1 == null || previousCrop2 == null)",
                "                return isCereal;",
                "",
                "            bool previous_1_wasCereal =",
                "                previousCrop1 == \"sorghum\" || previousCrop1 == \"wheat\";",
                "",
                "            bool previous_2_wasCereal =",
                "                previousCrop2 == \"sorghum\" || previousCrop2 == \"wheat\";",
                "",
                "            // Two cereals in a row → enforce a legume",
                "            if (previous_1_wasCereal && previous_2_wasCereal)",
                "                return isLegume;",
                "",
                "            // Otherwise → enforce a cereal",
                "            return isCereal;",
                "        }",
                "",
                "        // Called at harvest time to update crop sequence history",
                "        public void RecordHarvest(string crop)",
                "        {",
                "            crop = crop.ToLower();",
                "",
                "            bool isRotationCrop =",
                "                crop == \"sorghum\" ||",
                "                crop == \"wheat\"   ||",
                "                crop == \"mungbean\"||",
                "                crop == \"chickpea\";",
                "",
                "            if (isRotationCrop)",
                "            {",
                "                previousCrop2 = previousCrop1;",
                "                previousCrop1 = crop;",
                "            }",
                "        }",
                "",
                "        // Public read-only accessors",
                "        public string PreviousCrop1 => previousCrop1;",
                "        public string PreviousCrop2 => previousCrop2;",
                "    }",
                "}",
                ""
              ],
              "Parameters": [],
              "Name": "CropSequenceEnforcer",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using APSIM.Core;",
                "using Models.Interfaces;",
                "using APSIM.Shared.Utilities;",
                "using Models.Utilities;",
                "using Models.Soils;",
                "using Models.PMF;",
                "using Models.PMF.Organs;",
                "using Models.Core;",
                "using System;",
                "using System.Linq;",
                "using Models.Climate;",
                "using APSIM.Numerics;",
                "",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class Script : Model, IStructureDependency",
                "    {",
                "        [Link] private Clock Clock;",
                "        [Link] private Summary Summary;",
                "        [Link] private Soil Soil;",
                "        [Link] private ISoilWater waterBalance;",
                "        [Link] private CropSequenceEnforcer cropSequenceEnforcer;",
                "        ",
                "        public IStructure Structure { private get; set; }",
                "",
                "        [Separator(\"Script Configuration\")]",
                "        [Description(\"Crop to manage\")]",
                "        public IPlant Crop { get; set; }",
                "",
                "        [Separator(\"Sowing Conditions\")]",
                "        [Description(\"Start of sowing window (d-mmm)\")]",
                "        public string StartDate { get; set; }",
                "        [Description(\"End of sowing window (d-mmm)\")]",
                "        public string EndDate { get; set; }",
                "        [Description(\"Minimum extractable soil water for sowing (mm)\")]",
                "        public double MinESW { get; set; }",
                "        [Description(\"Accumulated rainfall required for sowing (mm)\")]",
                "        public double MinRain { get; set; }",
                "        [Description(\"Duration of rainfall accumulation (d)\")]",
                "        public int RainDays { get; set; }",
                "        [Tooltip(\"If enabled, and if sowing conditions are not met, the crop will be sown on the final day of the sowing window.\")]",
                "        [Description(\"Must sow (yes/no)\")]",
                "        public bool MustSow { get; set; }",
                "",
                "        [Separator(\"Sowing Properties\")]",
                "        [Description(\"Cultivar to be sown\")]",
                "        [Display(Type = DisplayType.CultivarName)]",
                "        public string CultivarName { get; set; }",
                "        [Description(\"Sowing depth (mm)\")]",
                "        public double SowingDepth { get; set; }",
                "        [Description(\"Row spacing (mm)\")]",
                "        public double RowSpacing { get; set; }",
                "        [Description(\"Plant population (/m2)\")]",
                "        public double Population { get; set; }",
                "",
                "        [Description(\"Enter skip row configuration : \")]",
                "        public RowConfigurationType RowConfiguration { get; set; }",
                "        [Description(\"Tillering Method\")]",
                "        public TilleringMethodType TilleringMethod { get; set; } = 0;",
                "        [Description(\"Enter Fertile Tiller No. : \")]",
                "        public double Ftn { get; set; }",
                "        public enum TilleringMethodType { RuleOfThumb = -1, FixedTillering = 0, DynamicTillering = 1 }",
                "        public enum RowConfigurationType { Solid, SingleSkip, DoubleSkip }",
                "",
                "        public Accumulator accumulatedRain { get; private set; }",
                "        private bool afterInit = false;",
                "",
                "        private string GetCropName()",
                "        {",
                "            return (Crop as Model).Name.ToLower();            ",
                "        }",
                "",
                "",
                "        [EventSubscribe(\"StartOfSimulation\")]",
                "        private void OnSimulationCommencing(object sender, EventArgs e)",
                "        {",
                "            if (Crop == null)",
                "                throw new Exception(\"Crop must not be null in rotations\");",
                "            accumulatedRain = new Accumulator(this, \"[Weather].Rain\", RainDays);",
                "            Summary.WriteMessage(this, this.FullPath + \" - Commence, crop=\" + GetCropName(), MessageType.Diagnostic);",
                "            afterInit = true;",
                "            MonthlyHarvestedWt = 0;",
                "        }",
                "",
                "        [EventSubscribe(\"DoManagement\")]",
                "        private void DoManagement(object sender, EventArgs e)",
                "        {",
                "            accumulatedRain.Update();",
                "        }",
                "",
                "",
                "",
                "        // Test whether we can sow a crop today",
                "        // +ve number - yes",
                "        // 0          - no",
                "        // -ve number - no, out of scope (planting window)",
                "        [Units(\"0-1\")]",
                "        public int CanSow",
                "        {",
                "            get",
                "            {",
                "                if (!afterInit)",
                "                    return 0;",
                "",
                "                bool isPossibleToday = false;",
                "                bool inWindow = DateUtilities.WithinDates(StartDate, Clock.Today, EndDate);",
                "                bool endOfWindow = DateUtilities.DatesEqual(EndDate, Clock.Today);",
                "",
                "                if (!Crop.IsAlive && inWindow &&",
                "                    accumulatedRain.Sum > MinRain &&",
                "                    MathUtilities.Sum(waterBalance.ESW) > MinESW)",
                "                    isPossibleToday = true;",
                "",
                "                string cropName = GetCropName();",
                "",
                "                // Case 1: normal sowing",
                "                if (isPossibleToday && cropSequenceEnforcer.AllowsSowing(cropName))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Field history → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                        MessageType.Diagnostic);",
                "",
                "                    return 1;",
                "                }",
                "",
                "                // Case 2: Must sow on last day of window",
                "                if (!Crop.IsAlive && endOfWindow && MustSow &&",
                "                    cropSequenceEnforcer.AllowsSowing(cropName))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Field history (end window) → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                        MessageType.Diagnostic);",
                "",
                "                    return 1;",
                "                }",
                "",
                "                // Out of window",
                "                if (!Crop.IsAlive && !inWindow)",
                "                    return -1;",
                "",
                "                return 0;",
                "            }",
                "        }",
                "",
                "",
                "        public void SowCrop()",
                "        {",
                "            Summary.WriteMessage(this, this.FullPath + \" - sowing \" + GetCropName(), MessageType.Diagnostic);",
                "            Crop.Sow(",
                "                population: Population, ",
                "                cultivar: CultivarName, ",
                "                depth: SowingDepth, ",
                "                rowSpacing: RowSpacing, ",
                "                rowConfig: (double)RowConfiguration, ",
                "                tillering:(int)TilleringMethod, ",
                "                ftn:Ftn",
                "                );",
                "        }",
                "",
                "        [Units(\"0-1\")]",
                "        public int CanHarvest",
                "        {",
                "            get",
                "            {",
                "                if (!afterInit)",
                "                    return 0;",
                "                return Crop.IsReadyForHarvesting ? 1 : 0;",
                "            }",
                "        }",
                "",
                "        public void HarvestCrop()",
                "        {",
                "            Summary.WriteMessage(this,",
                "                this.FullPath + \" - harvesting \" + (Crop as Model).Name,",
                "                MessageType.Diagnostic);",
                "",
                "            MonthlyHarvestedWt = ",
                "                (Structure.FindChild<IModel>(\"Grain\", relativeTo: (INodeModel)Crop) ",
                "                as ReproductiveOrgan).Wt;",
                "",
                "            Crop.Harvest();",
                "            Crop.EndCrop();",
                "",
                "            string harvested = GetCropName();",
                "",
                "            cropSequenceEnforcer.RecordHarvest(harvested);",
                "",
                "            Summary.WriteMessage(this,",
                "                $\"Updated field history → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                MessageType.Diagnostic);",
                "        }",
                "",
                "        [Units(\"0-1\")] ",
                "        public int MustAbandon",
                "        {",
                "            get",
                "            {",
                "                // check if crop is dead",
                "                if (afterInit && !Crop.IsAlive)",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop is dead after initialization.\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // check if crop did not emerge",
                "                else if (((Crop as Plant).DaysAfterSowing > 50) && (!(Crop as Plant).IsEmerged))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop did not emerge within 50 days after sowing.\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // check if crop is late for harvest",
                "                else if (Crop.IsAlive && (Crop as Plant).DaysAfterSowing > 180)",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop is late for harvest (180 days after sowing).\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // crop is neither dead nor late for harvest",
                "                return 0;",
                "            }",
                "        }",
                "",
                "        // Abandon crop",
                "        public void AbandonCrop()",
                "        {",
                "            if (Crop.IsAlive)",
                "            {",
                "                Crop.EndCrop();",
                "            }",
                "        }",
                "",
                "        public double MonthlyHarvestedWt { get; set; }",
                "",
                "        [EventSubscribe(\"StartOfMonth\")]",
                "        private void DoStartOfMonth(object sender, EventArgs e)",
                "        {",
                "            MonthlyHarvestedWt = 0;",
                "        }",
                "    }",
                "}",
                ""
              ],
              "Parameters": [
                {
                  "Key": "Crop",
                  "Value": "[Sorghum]"
                },
                {
                  "Key": "StartDate",
                  "Value": "1-nov"
                },
                {
                  "Key": "EndDate",
                  "Value": "10-jan"
                },
                {
                  "Key": "MinESW",
                  "Value": "50"
                },
                {
                  "Key": "MinRain",
                  "Value": "20"
                },
                {
                  "Key": "RainDays",
                  "Value": "7"
                },
                {
                  "Key": "MustSow",
                  "Value": "False"
                },
                {
                  "Key": "CultivarName",
                  "Value": "Buster"
                },
                {
                  "Key": "SowingDepth",
                  "Value": "30"
                },
                {
                  "Key": "RowSpacing",
                  "Value": "750"
                },
                {
                  "Key": "Population",
                  "Value": "10"
                },
                {
                  "Key": "RowConfiguration",
                  "Value": "Solid"
                },
                {
                  "Key": "TilleringMethod",
                  "Value": "FixedTillering"
                },
                {
                  "Key": "Ftn",
                  "Value": "0"
                }
              ],
              "Name": "SowHarvest_sorghum",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using APSIM.Core;",
                "using Models.Interfaces;",
                "using APSIM.Shared.Utilities;",
                "using Models.Utilities;",
                "using Models.Soils;",
                "using Models.PMF;",
                "using Models.PMF.Organs;",
                "using Models.Core;",
                "using System;",
                "using System.Linq;",
                "using Models.Climate;",
                "using APSIM.Numerics;",
                "",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class Script : Model, IStructureDependency",
                "    {",
                "        [Link] private Clock Clock;",
                "        [Link] private Summary Summary;",
                "        [Link] private Soil Soil;",
                "        [Link] private ISoilWater waterBalance;",
                "        [Link] private CropSequenceEnforcer cropSequenceEnforcer;",
                "",
                "        public IStructure Structure { private get; set; }",
                "",
                "        [Separator(\"Script Configuration\")]",
                "        [Description(\"Crop to manage\")]",
                "        public IPlant Crop { get; set; }",
                "",
                "        [Separator(\"Sowing Conditions\")]",
                "        [Description(\"Start of sowing window (d-mmm)\")]",
                "        public string StartDate { get; set; }",
                "        [Description(\"End of sowing window (d-mmm)\")]",
                "        public string EndDate { get; set; }",
                "        [Description(\"Minimum extractable soil water for sowing (mm)\")]",
                "        public double MinESW { get; set; }",
                "        [Description(\"Accumulated rainfall required for sowing (mm)\")]",
                "        public double MinRain { get; set; }",
                "        [Description(\"Duration of rainfall accumulation (d)\")]",
                "        public int RainDays { get; set; }",
                "        [Tooltip(\"If enabled, and if sowing conditions are not met, the crop will be sown on the final day of the sowing window.\")]",
                "        [Description(\"Must sow (yes/no)\")]",
                "        public bool MustSow { get; set; }",
                "",
                "        [Separator(\"Sowing Properties\")]",
                "        [Description(\"Cultivar to be sown\")]",
                "        [Display(Type = DisplayType.CultivarName)]",
                "        public string CultivarName { get; set; }",
                "        [Description(\"Sowing depth (mm)\")]",
                "        public double SowingDepth { get; set; }",
                "        [Description(\"Row spacing (mm)\")]",
                "        public double RowSpacing { get; set; }",
                "        [Description(\"Plant population (/m2)\")]",
                "        public double Population { get; set; }",
                "",
                "        public Accumulator accumulatedRain { get; private set; }",
                "        private bool afterInit = false;",
                "",
                "        private string GetCropName()",
                "        {",
                "            return (Crop as Model).Name.ToLower();            ",
                "        }",
                "",
                "        [EventSubscribe(\"StartOfSimulation\")]",
                "        private void OnSimulationCommencing(object sender, EventArgs e)",
                "        {",
                "            if (Crop == null)",
                "                throw new Exception(\"Crop must not be null in rotations\");",
                "            accumulatedRain = new Accumulator(this, \"[Weather].Rain\", RainDays);",
                "            Summary.WriteMessage(this, this.FullPath + \" - Commence, crop=\" + (Crop as Model).Name, MessageType.Diagnostic);",
                "            afterInit = true;",
                "            MonthlyHarvestedWt = 0;",
                "        }",
                "        ",
                "        [EventSubscribe(\"DoManagement\")]",
                "        private void DoManagement(object sender, EventArgs e)",
                "        {",
                "            accumulatedRain.Update();",
                "        }",
                "",
                "        // Test whether we can sow a crop today",
                "        // +ve number - yes",
                "        // 0          - no",
                "        // -ve number - no, out of scope (planting window)",
                "        [Units(\"0-1\")]",
                "        public int CanSow",
                "        {",
                "            get",
                "            {",
                "                if (!afterInit)",
                "                    return 0;",
                "",
                "                bool isPossibleToday = false;",
                "                bool inWindow = DateUtilities.WithinDates(StartDate, Clock.Today, EndDate);",
                "                bool endOfWindow = DateUtilities.DatesEqual(EndDate, Clock.Today);",
                "",
                "                if (!Crop.IsAlive && inWindow &&",
                "                    accumulatedRain.Sum > MinRain &&",
                "                    MathUtilities.Sum(waterBalance.ESW) > MinESW)",
                "                    isPossibleToday = true;",
                "",
                "                string cropName = GetCropName();",
                "",
                "                // Case 1: normal sowing",
                "                if (isPossibleToday && cropSequenceEnforcer.AllowsSowing(cropName))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Field history → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                        MessageType.Diagnostic);",
                "",
                "                    return 1;",
                "                }",
                "",
                "                // Case 2: Must sow on last day of window",
                "                if (!Crop.IsAlive && endOfWindow && MustSow &&",
                "                    cropSequenceEnforcer.AllowsSowing(cropName))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Field history (end window) → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                        MessageType.Diagnostic);",
                "",
                "                    return 1;",
                "                }",
                "",
                "                // Out of window",
                "                if (!Crop.IsAlive && !inWindow)",
                "                    return -1;",
                "",
                "                return 0;",
                "            }",
                "        }",
                "",
                "",
                "        public void SowCrop()",
                "        {",
                "            Summary.WriteMessage(this, this.FullPath + \" - sowing \" + GetCropName(), MessageType.Diagnostic);",
                "            Crop.Sow(population: Population, cultivar: CultivarName, depth: SowingDepth, rowSpacing: RowSpacing);",
                "        }",
                "",
                "        [Units(\"0-1\")] ",
                "        public int CanHarvest",
                "        {",
                "            get",
                "            {",
                "                if (!afterInit)",
                "                    return (0);",
                "                //Summary.WriteMessage(this, \"canLeave:\" + Crop.IsReadyForHarvesting, MessageType.Diagnostic);",
                "                return Crop.IsReadyForHarvesting ? 1 : 0;",
                "            }",
                "        }",
                "",
                "",
                "        public void HarvestCrop()",
                "        {",
                "            Summary.WriteMessage(this,",
                "                this.FullPath + \" - harvesting \" + (Crop as Model).Name,",
                "                MessageType.Diagnostic);",
                "",
                "            MonthlyHarvestedWt = ",
                "                (Structure.FindChild<IModel>(\"Grain\", relativeTo: (INodeModel)Crop) ",
                "                as ReproductiveOrgan).Wt;",
                "",
                "            Crop.Harvest();",
                "            Crop.EndCrop();",
                "",
                "            string harvested = GetCropName();",
                "",
                "            cropSequenceEnforcer.RecordHarvest(harvested);",
                "",
                "            Summary.WriteMessage(this,",
                "                $\"Updated field history → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                MessageType.Diagnostic);",
                "        }",
                "",
                "",
                "        [Units(\"0-1\")] ",
                "        public int MustAbandon",
                "        {",
                "            get",
                "            {",
                "                // check if crop is dead",
                "                if (afterInit && !Crop.IsAlive)",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop is dead after initialization.\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // check if crop did not emerge",
                "                else if (((Crop as Plant).DaysAfterSowing > 50) && (!(Crop as Plant).IsEmerged))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop did not emerge within 50 days after sowing.\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // check if crop is late for harvest",
                "                else if (Crop.IsAlive && (Crop as Plant).DaysAfterSowing > 180)",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop is late for harvest (180 days after sowing).\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // crop is neither dead nor late for harvest",
                "                return 0;",
                "            }",
                "        }",
                "",
                "        // Abandon crop",
                "        public void AbandonCrop()",
                "        {",
                "            if (Crop.IsAlive)",
                "            {",
                "                Crop.EndCrop();",
                "            }",
                "        }",
                "",
                "        public double MonthlyHarvestedWt { get; set; }",
                "",
                "        [EventSubscribe(\"StartOfMonth\")]",
                "        private void DoStartOfMonth(object sender, EventArgs e)",
                "        {",
                "            MonthlyHarvestedWt = 0;",
                "        }",
                "    }",
                "}"
              ],
              "Parameters": [
                {
                  "Key": "Crop",
                  "Value": "[Wheat]"
                },
                {
                  "Key": "StartDate",
                  "Value": "25-apr"
                },
                {
                  "Key": "EndDate",
                  "Value": "15-jun"
                },
                {
                  "Key": "MinESW",
                  "Value": "80"
                },
                {
                  "Key": "MinRain",
                  "Value": "30"
                },
                {
                  "Key": "RainDays",
                  "Value": "7"
                },
                {
                  "Key": "MustSow",
                  "Value": "False"
                },
                {
                  "Key": "CultivarName",
                  "Value": "Janz"
                },
                {
                  "Key": "SowingDepth",
                  "Value": "40"
                },
                {
                  "Key": "RowSpacing",
                  "Value": "500"
                },
                {
                  "Key": "Population",
                  "Value": "25"
                }
              ],
              "Name": "SowHarvest_wheat",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using APSIM.Core;",
                "using Models.Interfaces;",
                "using APSIM.Shared.Utilities;",
                "using Models.Utilities;",
                "using Models.Soils;",
                "using Models.PMF;",
                "using Models.PMF.Organs;",
                "using Models.Core;",
                "using System;",
                "using System.Linq;",
                "using Models.Climate;",
                "using APSIM.Numerics;",
                "",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class Script : Model, IStructureDependency",
                "    {",
                "        [Link] private Clock Clock;",
                "        [Link] private Summary Summary;",
                "        [Link] private Soil Soil;",
                "        [Link] private ISoilWater waterBalance;",
                "        [Link] private CropSequenceEnforcer cropSequenceEnforcer;",
                "",
                "        public IStructure Structure { private get; set; }",
                "",
                "        [Separator(\"Script Configuration\")]",
                "        [Description(\"Crop to manage\")]",
                "        public IPlant Crop { get; set; }",
                "",
                "        [Separator(\"Sowing Conditions\")]",
                "        [Description(\"Start of sowing window (d-mmm)\")]",
                "        public string StartDate { get; set; }",
                "        [Description(\"End of sowing window (d-mmm)\")]",
                "        public string EndDate { get; set; }",
                "        [Description(\"Minimum extractable soil water for sowing (mm)\")]",
                "        public double MinESW { get; set; }",
                "        [Description(\"Accumulated rainfall required for sowing (mm)\")]",
                "        public double MinRain { get; set; }",
                "        [Description(\"Duration of rainfall accumulation (d)\")]",
                "        public int RainDays { get; set; }",
                "        [Tooltip(\"If enabled, and if sowing conditions are not met, the crop will be sown on the final day of the sowing window.\")]",
                "        [Description(\"Must sow (yes/no)\")]",
                "        public bool MustSow { get; set; }",
                "",
                "        [Separator(\"Sowing Properties\")]",
                "        [Description(\"Cultivar to be sown\")]",
                "        [Display(Type = DisplayType.CultivarName)]",
                "        public string CultivarName { get; set; }",
                "        [Description(\"Sowing depth (mm)\")]",
                "        public double SowingDepth { get; set; }",
                "        [Description(\"Row spacing (mm)\")]",
                "        public double RowSpacing { get; set; }",
                "        [Description(\"Plant population (/m2)\")]",
                "        public double Population { get; set; }",
                "",
                "        public Accumulator accumulatedRain { get; private set; }",
                "        private bool afterInit = false;",
                "",
                "        private string GetCropName()",
                "        {",
                "            return (Crop as Model).Name.ToLower();            ",
                "        }",
                "",
                "        [EventSubscribe(\"StartOfSimulation\")]",
                "        private void OnSimulationCommencing(object sender, EventArgs e)",
                "        {",
                "            if (Crop == null)",
                "                throw new Exception(\"Crop must not be null in rotations\");",
                "            accumulatedRain = new Accumulator(this, \"[Weather].Rain\", RainDays);",
                "            Summary.WriteMessage(this, this.FullPath + \" - Commence, crop=\" + (Crop as Model).Name, MessageType.Diagnostic);",
                "            afterInit = true;",
                "            MonthlyHarvestedWt = 0;",
                "        }",
                "        ",
                "        [EventSubscribe(\"DoManagement\")]",
                "        private void DoManagement(object sender, EventArgs e)",
                "        {",
                "            accumulatedRain.Update();",
                "        }",
                "",
                "        // Test whether we can sow a crop today",
                "        // +ve number - yes",
                "        // 0          - no",
                "        // -ve number - no, out of scope (planting window)",
                "        [Units(\"0-1\")]",
                "        public int CanSow",
                "        {",
                "            get",
                "            {",
                "                if (!afterInit)",
                "                    return 0;",
                "",
                "                bool isPossibleToday = false;",
                "                bool inWindow = DateUtilities.WithinDates(StartDate, Clock.Today, EndDate);",
                "                bool endOfWindow = DateUtilities.DatesEqual(EndDate, Clock.Today);",
                "",
                "                if (!Crop.IsAlive && inWindow &&",
                "                    accumulatedRain.Sum > MinRain &&",
                "                    MathUtilities.Sum(waterBalance.ESW) > MinESW)",
                "                    isPossibleToday = true;",
                "",
                "                string cropName = GetCropName();",
                "",
                "                // Case 1: normal sowing",
                "                if (isPossibleToday && cropSequenceEnforcer.AllowsSowing(cropName))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Field history → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                        MessageType.Diagnostic);",
                "",
                "                    return 1;",
                "                }",
                "",
                "                // Case 2: Must sow on last day of window",
                "                if (!Crop.IsAlive && endOfWindow && MustSow &&",
                "                    cropSequenceEnforcer.AllowsSowing(cropName))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Field history (end window) → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                        MessageType.Diagnostic);",
                "",
                "                    return 1;",
                "                }",
                "",
                "                // Out of window",
                "                if (!Crop.IsAlive && !inWindow)",
                "                    return -1;",
                "",
                "                return 0;",
                "            }",
                "        }",
                "",
                "",
                "        public void SowCrop()",
                "        {",
                "            Summary.WriteMessage(this, this.FullPath + \" - sowing \" + GetCropName(), MessageType.Diagnostic);",
                "            Crop.Sow(population: Population, cultivar: CultivarName, depth: SowingDepth, rowSpacing: RowSpacing);",
                "        }",
                "",
                "        [Units(\"0-1\")] ",
                "        public int CanHarvest",
                "        {",
                "            get",
                "            {",
                "                if (!afterInit)",
                "                    return (0);",
                "                //Summary.WriteMessage(this, \"canLeave:\" + Crop.IsReadyForHarvesting, MessageType.Diagnostic);",
                "                return Crop.IsReadyForHarvesting ? 1 : 0;",
                "            }",
                "        }",
                "",
                "",
                "        public void HarvestCrop()",
                "        {",
                "            Summary.WriteMessage(this,",
                "                this.FullPath + \" - harvesting \" + (Crop as Model).Name,",
                "                MessageType.Diagnostic);",
                "",
                "            MonthlyHarvestedWt = ",
                "                (Structure.FindChild<IModel>(\"Grain\", relativeTo: (INodeModel)Crop) ",
                "                as ReproductiveOrgan).Wt;",
                "",
                "            Crop.Harvest();",
                "            Crop.EndCrop();",
                "",
                "            string harvested = GetCropName();",
                "",
                "            cropSequenceEnforcer.RecordHarvest(harvested);",
                "",
                "            Summary.WriteMessage(this,",
                "                $\"Updated field history → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                MessageType.Diagnostic);",
                "        }",
                "",
                "",
                "        [Units(\"0-1\")] ",
                "        public int MustAbandon",
                "        {",
                "            get",
                "            {",
                "                // check if crop is dead",
                "                if (afterInit && !Crop.IsAlive)",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop is dead after initialization.\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // check if crop did not emerge",
                "                else if (((Crop as Plant).DaysAfterSowing > 50) && (!(Crop as Plant).IsEmerged))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop did not emerge within 50 days after sowing.\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // check if crop is late for harvest",
                "                else if (Crop.IsAlive && (Crop as Plant).DaysAfterSowing > 180)",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop is late for harvest (180 days after sowing).\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // crop is neither dead nor late for harvest",
                "                return 0;",
                "            }",
                "        }",
                "",
                "        // Abandon crop",
                "        public void AbandonCrop()",
                "        {",
                "            if (Crop.IsAlive)",
                "            {",
                "                Crop.EndCrop();",
                "            }",
                "        }",
                "",
                "        public double MonthlyHarvestedWt { get; set; }",
                "",
                "        [EventSubscribe(\"StartOfMonth\")]",
                "        private void DoStartOfMonth(object sender, EventArgs e)",
                "        {",
                "            MonthlyHarvestedWt = 0;",
                "        }",
                "    }",
                "}"
              ],
              "Parameters": [
                {
                  "Key": "Crop",
                  "Value": "[Mungbean]"
                },
                {
                  "Key": "StartDate",
                  "Value": "1-oct"
                },
                {
                  "Key": "EndDate",
                  "Value": "30-dec"
                },
                {
                  "Key": "MinESW",
                  "Value": "50"
                },
                {
                  "Key": "MinRain",
                  "Value": "20"
                },
                {
                  "Key": "RainDays",
                  "Value": "7"
                },
                {
                  "Key": "MustSow",
                  "Value": "False"
                },
                {
                  "Key": "CultivarName",
                  "Value": "CeleraII"
                },
                {
                  "Key": "SowingDepth",
                  "Value": "40"
                },
                {
                  "Key": "RowSpacing",
                  "Value": "500"
                },
                {
                  "Key": "Population",
                  "Value": "25"
                }
              ],
              "Name": "SowHarvest_mungbean",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using APSIM.Core;",
                "using Models.Interfaces;",
                "using APSIM.Shared.Utilities;",
                "using Models.Utilities;",
                "using Models.Soils;",
                "using Models.PMF;",
                "using Models.PMF.Organs;",
                "using Models.Core;",
                "using System;",
                "using System.Linq;",
                "using Models.Climate;",
                "using APSIM.Numerics;",
                "",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class Script : Model, IStructureDependency",
                "    {",
                "        [Link] private Clock Clock;",
                "        [Link] private Summary Summary;",
                "        [Link] private Soil Soil;",
                "        [Link] private ISoilWater waterBalance;",
                "        [Link] private CropSequenceEnforcer cropSequenceEnforcer;",
                "",
                "        public IStructure Structure { private get; set; }",
                "",
                "        [Separator(\"Script Configuration\")]",
                "        [Description(\"Crop to manage\")]",
                "        public IPlant Crop { get; set; }",
                "",
                "        [Separator(\"Sowing Conditions\")]",
                "        [Description(\"Start of sowing window (d-mmm)\")]",
                "        public string StartDate { get; set; }",
                "        [Description(\"End of sowing window (d-mmm)\")]",
                "        public string EndDate { get; set; }",
                "        [Description(\"Minimum extractable soil water for sowing (mm)\")]",
                "        public double MinESW { get; set; }",
                "        [Description(\"Accumulated rainfall required for sowing (mm)\")]",
                "        public double MinRain { get; set; }",
                "        [Description(\"Duration of rainfall accumulation (d)\")]",
                "        public int RainDays { get; set; }",
                "        [Tooltip(\"If enabled, and if sowing conditions are not met, the crop will be sown on the final day of the sowing window.\")]",
                "        [Description(\"Must sow (yes/no)\")]",
                "        public bool MustSow { get; set; }",
                "",
                "        [Separator(\"Sowing Properties\")]",
                "        [Description(\"Cultivar to be sown\")]",
                "        [Display(Type = DisplayType.CultivarName)]",
                "        public string CultivarName { get; set; }",
                "        [Description(\"Sowing depth (mm)\")]",
                "        public double SowingDepth { get; set; }",
                "        [Description(\"Row spacing (mm)\")]",
                "        public double RowSpacing { get; set; }",
                "        [Description(\"Plant population (/m2)\")]",
                "        public double Population { get; set; }",
                "",
                "        public Accumulator accumulatedRain { get; private set; }",
                "        private bool afterInit = false;",
                "",
                "        private string GetCropName()",
                "        {",
                "            return (Crop as Model).Name.ToLower();            ",
                "        }",
                "",
                "        [EventSubscribe(\"StartOfSimulation\")]",
                "        private void OnSimulationCommencing(object sender, EventArgs e)",
                "        {",
                "            if (Crop == null)",
                "                throw new Exception(\"Crop must not be null in rotations\");",
                "            accumulatedRain = new Accumulator(this, \"[Weather].Rain\", RainDays);",
                "            Summary.WriteMessage(this, this.FullPath + \" - Commence, crop=\" + (Crop as Model).Name, MessageType.Diagnostic);",
                "            afterInit = true;",
                "            MonthlyHarvestedWt = 0;",
                "        }",
                "        ",
                "        [EventSubscribe(\"DoManagement\")]",
                "        private void DoManagement(object sender, EventArgs e)",
                "        {",
                "            accumulatedRain.Update();",
                "        }",
                "",
                "        // Test whether we can sow a crop today",
                "        // +ve number - yes",
                "        // 0          - no",
                "        // -ve number - no, out of scope (planting window)",
                "        [Units(\"0-1\")]",
                "        public int CanSow",
                "        {",
                "            get",
                "            {",
                "                if (!afterInit)",
                "                    return 0;",
                "",
                "                bool isPossibleToday = false;",
                "                bool inWindow = DateUtilities.WithinDates(StartDate, Clock.Today, EndDate);",
                "                bool endOfWindow = DateUtilities.DatesEqual(EndDate, Clock.Today);",
                "",
                "                if (!Crop.IsAlive && inWindow &&",
                "                    accumulatedRain.Sum > MinRain &&",
                "                    MathUtilities.Sum(waterBalance.ESW) > MinESW)",
                "                    isPossibleToday = true;",
                "",
                "                string cropName = GetCropName();",
                "",
                "                // Case 1: normal sowing",
                "                if (isPossibleToday && cropSequenceEnforcer.AllowsSowing(cropName))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Field history → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                        MessageType.Diagnostic);",
                "",
                "                    return 1;",
                "                }",
                "",
                "                // Case 2: Must sow on last day of window",
                "                if (!Crop.IsAlive && endOfWindow && MustSow &&",
                "                    cropSequenceEnforcer.AllowsSowing(cropName))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Field history (end window) → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                        MessageType.Diagnostic);",
                "",
                "                    return 1;",
                "                }",
                "",
                "                // Out of window",
                "                if (!Crop.IsAlive && !inWindow)",
                "                    return -1;",
                "",
                "                return 0;",
                "            }",
                "        }",
                "",
                "",
                "        public void SowCrop()",
                "        {",
                "            Summary.WriteMessage(this, this.FullPath + \" - sowing \" + GetCropName(), MessageType.Diagnostic);",
                "            Crop.Sow(population: Population, cultivar: CultivarName, depth: SowingDepth, rowSpacing: RowSpacing);",
                "        }",
                "",
                "        [Units(\"0-1\")] ",
                "        public int CanHarvest",
                "        {",
                "            get",
                "            {",
                "                if (!afterInit)",
                "                    return (0);",
                "                //Summary.WriteMessage(this, \"canLeave:\" + Crop.IsReadyForHarvesting, MessageType.Diagnostic);",
                "                return Crop.IsReadyForHarvesting ? 1 : 0;",
                "            }",
                "        }",
                "",
                "",
                "        public void HarvestCrop()",
                "        {",
                "            Summary.WriteMessage(this,",
                "                this.FullPath + \" - harvesting \" + (Crop as Model).Name,",
                "                MessageType.Diagnostic);",
                "",
                "            MonthlyHarvestedWt = ",
                "                (Structure.FindChild<IModel>(\"Grain\", relativeTo: (INodeModel)Crop) ",
                "                as ReproductiveOrgan).Wt;",
                "",
                "            Crop.Harvest();",
                "            Crop.EndCrop();",
                "",
                "            string harvested = GetCropName();",
                "",
                "            cropSequenceEnforcer.RecordHarvest(harvested);",
                "",
                "            Summary.WriteMessage(this,",
                "                $\"Updated field history → PreviousCrop1={cropSequenceEnforcer.PreviousCrop1 ?? \"null\"}, PreviousCrop2={cropSequenceEnforcer.PreviousCrop2 ?? \"null\"}\",",
                "                MessageType.Diagnostic);",
                "        }",
                "",
                "",
                "        [Units(\"0-1\")] ",
                "        public int MustAbandon",
                "        {",
                "            get",
                "            {",
                "                // check if crop is dead",
                "                if (afterInit && !Crop.IsAlive)",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop is dead after initialization.\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // check if crop did not emerge",
                "                else if (((Crop as Plant).DaysAfterSowing > 50) && (!(Crop as Plant).IsEmerged))",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop did not emerge within 50 days after sowing.\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // check if crop is late for harvest",
                "                else if (Crop.IsAlive && (Crop as Plant).DaysAfterSowing > 180)",
                "                {",
                "                    Summary.WriteMessage(this,",
                "                        $\"Abandoning crop: Crop is late for harvest (180 days after sowing).\",",
                "                        MessageType.Diagnostic);",
                "                    return 1;",
                "                }",
                "",
                "                // crop is neither dead nor late for harvest",
                "                return 0;",
                "            }",
                "        }",
                "",
                "        // Abandon crop",
                "        public void AbandonCrop()",
                "        {",
                "            if (Crop.IsAlive)",
                "            {",
                "                Crop.EndCrop();",
                "            }",
                "        }",
                "",
                "        public double MonthlyHarvestedWt { get; set; }",
                "",
                "        [EventSubscribe(\"StartOfMonth\")]",
                "        private void DoStartOfMonth(object sender, EventArgs e)",
                "        {",
                "            MonthlyHarvestedWt = 0;",
                "        }",
                "    }",
                "}"
              ],
              "Parameters": [
                {
                  "Key": "Crop",
                  "Value": "[Chickpea]"
                },
                {
                  "Key": "StartDate",
                  "Value": "15-may"
                },
                {
                  "Key": "EndDate",
                  "Value": "15-jun"
                },
                {
                  "Key": "MinESW",
                  "Value": "80"
                },
                {
                  "Key": "MinRain",
                  "Value": "30"
                },
                {
                  "Key": "RainDays",
                  "Value": "7"
                },
                {
                  "Key": "MustSow",
                  "Value": "False"
                },
                {
                  "Key": "CultivarName",
                  "Value": "Amethyst"
                },
                {
                  "Key": "SowingDepth",
                  "Value": "40"
                },
                {
                  "Key": "RowSpacing",
                  "Value": "500"
                },
                {
                  "Key": "Population",
                  "Value": "25"
                }
              ],
              "Name": "SowHarvest_chickpea",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using Models.Soils;",
                "using System;",
                "using System.Linq;",
                "using Models.Core;",
                "using Models.PMF;",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class Script : Model",
                "    {",
                "        [Link] Clock Clock;",
                "        [Link] Fertiliser Fertiliser;",
                "        ",
                "        [Description(\"Crop to be fertilised\")]",
                "        public IPlant Crop { get; set; }",
                "",
                "        [Description(\"Type of fertiliser to apply? \")] ",
                "        [Display(Type = DisplayType.FertiliserType)]public string FertiliserType { get; set; }",
                "    ",
                "        [Description(\"Amount of fertiliser to be applied (kg/ha)\")]",
                "        public double Amount { get; set; }",
                "        ",
                "        [EventSubscribe(\"Sowing\")]",
                "        private void OnSowing(object sender, EventArgs e)",
                "        {",
                "            Model crop = sender as Model;",
                "            if (Crop != null && crop.Name.ToLower() == (Crop as IModel).Name.ToLower())",
                "                Fertiliser.Apply(amount: Amount, type: FertiliserType);",
                "        }",
                "    }",
                "}"
              ],
              "Parameters": [
                {
                  "Key": "Crop",
                  "Value": "[Sorghum]"
                },
                {
                  "Key": "FertiliserType",
                  "Value": "UreaN"
                },
                {
                  "Key": "Amount",
                  "Value": "100"
                }
              ],
              "Name": "Fert_sorghum",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using Models.Soils;",
                "using System;",
                "using System.Linq;",
                "using Models.Core;",
                "using Models.PMF;",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class Script : Model",
                "    {",
                "        [Link] Clock Clock;",
                "        [Link] Fertiliser Fertiliser;",
                "        ",
                "        [Description(\"Crop to be fertilised\")]",
                "        public IPlant Crop { get; set; }",
                "",
                "        [Description(\"Type of fertiliser to apply? \")] ",
                "        [Display(Type = DisplayType.FertiliserType)]public string FertiliserType { get; set; }",
                "    ",
                "        [Description(\"Amount of fertiliser to be applied (kg/ha)\")]",
                "        public double Amount { get; set; }",
                "        ",
                "        [EventSubscribe(\"Sowing\")]",
                "        private void OnSowing(object sender, EventArgs e)",
                "        {",
                "            Model crop = sender as Model;",
                "            if (Crop != null && crop.Name.ToLower() == (Crop as IModel).Name.ToLower())",
                "                Fertiliser.Apply(amount: Amount, type: FertiliserType);",
                "        }",
                "    }",
                "}"
              ],
              "Parameters": [
                {
                  "Key": "Crop",
                  "Value": "[Wheat]"
                },
                {
                  "Key": "FertiliserType",
                  "Value": "UreaN"
                },
                {
                  "Key": "Amount",
                  "Value": "100"
                }
              ],
              "Name": "Fert_wheat",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using Models.Soils;",
                "using System;",
                "using System.Linq;",
                "using Models.Core;",
                "using Models.PMF;",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class Script : Model",
                "    {",
                "        [Link] Clock Clock;",
                "        [Link] Fertiliser Fertiliser;",
                "        ",
                "        [Description(\"Crop to be fertilised\")]",
                "        public IPlant Crop { get; set; }",
                "",
                "        [Description(\"Type of fertiliser to apply? \")] ",
                "        [Display(Type = DisplayType.FertiliserType)]public string FertiliserType { get; set; }",
                "    ",
                "        [Description(\"Amount of fertiliser to be applied (kg/ha)\")]",
                "        public double Amount { get; set; }",
                "        ",
                "        [EventSubscribe(\"Sowing\")]",
                "        private void OnSowing(object sender, EventArgs e)",
                "        {",
                "            Model crop = sender as Model;",
                "            if (Crop != null && crop.Name.ToLower() == (Crop as IModel).Name.ToLower())",
                "                Fertiliser.Apply(amount: Amount, type: FertiliserType);",
                "        }",
                "    }",
                "}"
              ],
              "Parameters": [
                {
                  "Key": "Crop",
                  "Value": "[Mungbean]"
                },
                {
                  "Key": "FertiliserType",
                  "Value": "UreaN"
                },
                {
                  "Key": "Amount",
                  "Value": "15"
                }
              ],
              "Name": "Fert_mungbean",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Manager, Models",
              "CodeArray": [
                "using Models.Soils;",
                "using System;",
                "using System.Linq;",
                "using Models.Core;",
                "using Models.PMF;",
                "namespace Models",
                "{",
                "    [Serializable]",
                "    public class Script : Model",
                "    {",
                "        [Link] Clock Clock;",
                "        [Link] Fertiliser Fertiliser;",
                "        ",
                "        [Description(\"Crop to be fertilised\")]",
                "        public IPlant Crop { get; set; }",
                "",
                "        [Description(\"Type of fertiliser to apply? \")] ",
                "        [Display(Type = DisplayType.FertiliserType)]public string FertiliserType { get; set; }",
                "    ",
                "        [Description(\"Amount of fertiliser to be applied (kg/ha)\")]",
                "        public double Amount { get; set; }",
                "        ",
                "        [EventSubscribe(\"Sowing\")]",
                "        private void OnSowing(object sender, EventArgs e)",
                "        {",
                "            Model crop = sender as Model;",
                "            if (Crop != null && crop.Name.ToLower() == (Crop as IModel).Name.ToLower())",
                "                Fertiliser.Apply(amount: Amount, type: FertiliserType);",
                "        }",
                "    }",
                "}"
              ],
              "Parameters": [
                {
                  "Key": "Crop",
                  "Value": "[Sorghum]"
                },
                {
                  "Key": "FertiliserType",
                  "Value": "UreaN"
                },
                {
                  "Key": "Amount",
                  "Value": "15"
                }
              ],
              "Name": "Fert_chickpea",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            }
          ],
          "Enabled": true,
          "ReadOnly": false
        },
        {
          "$type": "Models.Graph, Models",
          "Caption": null,
          "Axis": [
            {
              "$type": "APSIM.Shared.Graphing.Axis, APSIM.Shared",
              "Title": null,
              "Position": 3,
              "Inverted": false,
              "CrossesAtZero": false,
              "LabelOnOneLine": false,
              "Minimum": null,
              "Maximum": null,
              "Interval": null
            },
            {
              "$type": "APSIM.Shared.Graphing.Axis, APSIM.Shared",
              "Title": null,
              "Position": 0,
              "Inverted": false,
              "CrossesAtZero": false,
              "LabelOnOneLine": false,
              "Minimum": null,
              "Maximum": null,
              "Interval": null
            }
          ],
          "LegendPosition": 0,
          "LegendOrientation": 0,
          "AnnotationLocation": 0,
          "DisabledSeries": [],
          "LegendOutsideGraph": false,
          "Name": "Crop Yield",
          "ResourceName": null,
          "Children": [
            {
              "$type": "Models.Series, Models",
              "Type": 1,
              "XAxis": 3,
              "YAxis": 0,
              "ColourArgb": 0,
              "FactorToVaryColours": "Graph series",
              "FactorToVaryMarkers": null,
              "FactorToVaryLines": null,
              "Marker": 0,
              "MarkerSize": 0,
              "Line": 4,
              "LineThickness": 0,
              "TableName": "HarvestReport_sorghum",
              "XFieldName": "Clock.Today",
              "YFieldName": "Sorghum.Grain.Wt",
              "X2FieldName": null,
              "Y2FieldName": null,
              "ShowInLegend": false,
              "IncludeSeriesNameInLegend": false,
              "Cumulative": false,
              "CumulativeX": false,
              "Filter": null,
              "Name": "Yield_sorghum",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Series, Models",
              "Type": 1,
              "XAxis": 3,
              "YAxis": 0,
              "ColourArgb": 0,
              "FactorToVaryColours": "Graph series",
              "FactorToVaryMarkers": null,
              "FactorToVaryLines": null,
              "Marker": 0,
              "MarkerSize": 0,
              "Line": 4,
              "LineThickness": 0,
              "TableName": "HarvestReport_mungbean",
              "XFieldName": "Clock.Today",
              "YFieldName": "Mungbean.Grain.Wt",
              "X2FieldName": null,
              "Y2FieldName": null,
              "ShowInLegend": false,
              "IncludeSeriesNameInLegend": false,
              "Cumulative": false,
              "CumulativeX": false,
              "Filter": null,
              "Name": "Yield_mungbean",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Series, Models",
              "Type": 1,
              "XAxis": 3,
              "YAxis": 0,
              "ColourArgb": 0,
              "FactorToVaryColours": "Graph series",
              "FactorToVaryMarkers": null,
              "FactorToVaryLines": null,
              "Marker": 0,
              "MarkerSize": 0,
              "Line": 4,
              "LineThickness": 0,
              "TableName": "HarvestReport_wheat",
              "XFieldName": "Clock.Today",
              "YFieldName": "Wheat.Grain.Wt",
              "X2FieldName": null,
              "Y2FieldName": null,
              "ShowInLegend": false,
              "IncludeSeriesNameInLegend": false,
              "Cumulative": false,
              "CumulativeX": false,
              "Filter": null,
              "Name": "Yield_wheat",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            },
            {
              "$type": "Models.Series, Models",
              "Type": 1,
              "XAxis": 3,
              "YAxis": 0,
              "ColourArgb": 0,
              "FactorToVaryColours": "Graph series",
              "FactorToVaryMarkers": null,
              "FactorToVaryLines": null,
              "Marker": 0,
              "MarkerSize": 0,
              "Line": 4,
              "LineThickness": 0,
              "TableName": "HarvestReport_chickpea",
              "XFieldName": "Clock.Today",
              "YFieldName": "Chickpea.Grain.Wt",
              "X2FieldName": null,
              "Y2FieldName": null,
              "ShowInLegend": false,
              "IncludeSeriesNameInLegend": false,
              "Cumulative": false,
              "CumulativeX": false,
              "Filter": null,
              "Name": "Yield_chickpea",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            }
          ],
          "Enabled": true,
          "ReadOnly": false
        },
        {
          "$type": "Models.Graph, Models",
          "Caption": null,
          "Axis": [
            {
              "$type": "APSIM.Shared.Graphing.Axis, APSIM.Shared",
              "Title": "Clock.Today",
              "Position": 3,
              "Inverted": false,
              "CrossesAtZero": false,
              "LabelOnOneLine": false,
              "Minimum": null,
              "Maximum": null,
              "Interval": null
            },
            {
              "$type": "APSIM.Shared.Graphing.Axis, APSIM.Shared",
              "Title": null,
              "Position": 0,
              "Inverted": false,
              "CrossesAtZero": false,
              "LabelOnOneLine": false,
              "Minimum": null,
              "Maximum": null,
              "Interval": null
            }
          ],
          "LegendPosition": 0,
          "LegendOrientation": 0,
          "AnnotationLocation": 0,
          "DisabledSeries": [],
          "LegendOutsideGraph": false,
          "Name": "SOC",
          "ResourceName": null,
          "Children": [
            {
              "$type": "Models.Series, Models",
              "Type": 1,
              "XAxis": 3,
              "YAxis": 0,
              "ColourArgb": -16747854,
              "FactorToVaryColours": null,
              "FactorToVaryMarkers": null,
              "FactorToVaryLines": null,
              "Marker": 11,
              "MarkerSize": 1,
              "Line": 0,
              "LineThickness": 0,
              "TableName": "DailyReport",
              "XFieldName": "Clock.Today",
              "YFieldName": "SoilOrganicC_fullProfile",
              "X2FieldName": null,
              "Y2FieldName": null,
              "ShowInLegend": false,
              "IncludeSeriesNameInLegend": false,
              "Cumulative": false,
              "CumulativeX": false,
              "Filter": null,
              "Name": "Series",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            }
          ],
          "Enabled": true,
          "ReadOnly": false
        },
        {
          "$type": "Models.Graph, Models",
          "Caption": null,
          "Axis": [
            {
              "$type": "APSIM.Shared.Graphing.Axis, APSIM.Shared",
              "Title": "Clock.Today",
              "Position": 3,
              "Inverted": false,
              "CrossesAtZero": false,
              "LabelOnOneLine": false,
              "Minimum": null,
              "Maximum": null,
              "Interval": null
            },
            {
              "$type": "APSIM.Shared.Graphing.Axis, APSIM.Shared",
              "Title": null,
              "Position": 0,
              "Inverted": false,
              "CrossesAtZero": false,
              "LabelOnOneLine": false,
              "Minimum": null,
              "Maximum": null,
              "Interval": null
            }
          ],
          "LegendPosition": 0,
          "LegendOrientation": 0,
          "AnnotationLocation": 0,
          "DisabledSeries": [],
          "LegendOutsideGraph": false,
          "Name": "SoilWater",
          "ResourceName": null,
          "Children": [
            {
              "$type": "Models.Series, Models",
              "Type": 1,
              "XAxis": 3,
              "YAxis": 0,
              "ColourArgb": -16747854,
              "FactorToVaryColours": null,
              "FactorToVaryMarkers": null,
              "FactorToVaryLines": null,
              "Marker": 11,
              "MarkerSize": 1,
              "Line": 0,
              "LineThickness": 0,
              "TableName": "DailyReport",
              "XFieldName": "Clock.Today",
              "YFieldName": "SoilWatVolumetric_fullProfile",
              "X2FieldName": null,
              "Y2FieldName": null,
              "ShowInLegend": false,
              "IncludeSeriesNameInLegend": false,
              "Cumulative": false,
              "CumulativeX": false,
              "Filter": null,
              "Name": "Series",
              "ResourceName": null,
              "Children": [],
              "Enabled": true,
              "ReadOnly": false
            }
          ],
          "Enabled": true,
          "ReadOnly": false
        }
      ],
      "Enabled": true,
      "ReadOnly": false
    }
  ],
  "Enabled": true,
  "ReadOnly": false
}