/// <summary>Constructor.</summary> /// <param name="soilThicknesses">Soil thicknesses (mm).</param> /// <param name="nutrientPatchManager">The nutrient patch manager.</param> public NutrientPatch(double[] soilThicknesses, NutrientPatchManager nutrientPatchManager) { soilThickness = soilThicknesses; patchManager = nutrientPatchManager; var simulations = FileFormat.ReadFromString <Simulations>(ReflectionUtilities.GetResourceAsString("Models.Resources.Nutrient.json"), e => throw e, false); if (simulations.Children.Count != 1 || !(simulations.Children[0] is Nutrient)) { throw new Exception("Cannot create nutrient model in NutrientPatchManager"); } Nutrient = simulations.Children[0] as Nutrient; Nutrient.IsHidden = true; // Find all solutes. foreach (ISolute solute in Nutrient.FindAllChildren <ISolute>()) { solutes.Add(solute.Name, solute); } lignin = Nutrient.FindInScope <NutrientPool>("FOMLignin"); if (lignin == null) { throw new Exception("Cannot find lignin pool in the nutrient model."); } cellulose = Nutrient.FindInScope <NutrientPool>("FOMCellulose"); if (cellulose == null) { throw new Exception("Cannot find cellulose pool in the nutrient model."); } carbohydrate = Nutrient.FindInScope <NutrientPool>("FOMCarbohydrate"); if (carbohydrate == null) { throw new Exception("Cannot find carbohydrate pool in the nutrient model."); } }