/// <summary>
        /// Add DMConversionEfficiency node
        /// </summary>
        /// <param name="node">The node to modifiy</param>
        /// <param name="fileName">The name of the .apsimx file</param>
        private static void UpgradeToVersion19(XmlNode node, string fileName)
        {
            //Rename existing DMConversionEfficiencyFunction nodes
            foreach (XmlNode n in XmlUtilities.FindAllRecursivelyByType(node, "Leaf"))
            {
                XmlNode dmFunction = APSIMFileConverterUtilities.FindModelNode(n, "DMConversionEfficiencyFunction");
                if (dmFunction != null)
                {
                    XmlUtilities.SetValue(dmFunction, "Name", "DMConversionEfficiency");
                }
            }

            List <XmlNode> nodeList = new List <XmlNode>();

            XmlUtilities.FindAllRecursively(node, "DMConversionEfficiencyFunction", ref nodeList);
            foreach (XmlNode n in nodeList)
            {
                APSIMFileConverterUtilities.RenameNode(n, "DMConversionEfficiencyFunction", "DMConversionEfficiency");
            }

            nodeList.Clear();
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "Root"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "Leaf"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "GenericOrgan"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "ReproductiveOrgan"));

            foreach (XmlNode n in nodeList)
            {
                XmlNode DMnode;
                DMnode = XmlUtilities.CreateNode(node.OwnerDocument, "Constant", "");
                XmlElement name    = node.OwnerDocument.CreateElement("Name");
                XmlElement element = node.OwnerDocument.CreateElement("FixedValue");
                name.InnerText    = "DMConversionEfficiency";
                element.InnerText = "1.0";
                DMnode.AppendChild(name);
                DMnode.AppendChild(element);

                if (APSIMFileConverterUtilities.FindModelNode(n, "DMConversionEfficiency") == null)
                {
                    n.AppendChild(DMnode);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Rename Plant15 to Plant.
        /// </summary>
        /// <param name="node">The node to modifiy</param>
        /// <param name="fileName">The name of the .apsimx file</param>
        private static void UpgradeToVersion13(XmlNode node, string fileName)
        {
            APSIMFileConverterUtilities.RenameNode(node, "Plant15", "Plant");
            APSIMFileConverterUtilities.RenameVariable(node, "using Models.PMF.OldPlant;", "using Models.PMF;");
            APSIMFileConverterUtilities.RenameVariable(node, "Plant15", "Plant");

            foreach (XmlNode manager in XmlUtilities.FindAllRecursivelyByType(node, "manager"))
            {
                APSIMFileConverterUtilities.SearchReplaceManagerCodeUsingRegEx(manager, @"(\w+).plant.status *== *\042out\042", @"!$1.IsAlive", null);  // /042 is a "
            }
            foreach (XmlNode simulationNode in XmlUtilities.FindAllRecursivelyByType(node, "Simulation"))
            {
                List <XmlNode> plantModels = XmlUtilities.FindAllRecursivelyByType(simulationNode, "Plant");
                plantModels.RemoveAll(p => p.Name == "plant"); // remove lowercase plant nodes - these are in sugarcane

                if (plantModels.Count > 0)
                {
                    XmlUtilities.EnsureNodeExists(simulationNode, "SoilArbitrator");
                    XmlUtilities.EnsureNodeExists(plantModels[0].ParentNode, "MicroClimate");
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Rename NonStructural to Storage in Biomass organs
        /// </summary>
        /// <param name="node">The node to modifiy</param>
        /// <param name="fileName">The name of the .apsimx file</param>
        private static void UpgradeToVersion11(XmlNode node, string fileName)
        {
            APSIMFileConverterUtilities.RenameVariable(node, ".NonStructural", ".Storage");
            APSIMFileConverterUtilities.RenameVariable(node, ".NonStructuralDemand", ".StorageDemand");
            APSIMFileConverterUtilities.RenameVariable(node, ".TotalNonStructuralDemand", ".TotalStorageDemand");
            APSIMFileConverterUtilities.RenameVariable(node, ".NonStructuralAllocation", ".StorageAllocation");
            APSIMFileConverterUtilities.RenameVariable(node, ".NonStructuralFraction", ".StorageFraction");
            APSIMFileConverterUtilities.RenameVariable(node, ".NonStructuralWt", ".StorageWt");
            APSIMFileConverterUtilities.RenameVariable(node, ".NonStructuralN", ".StorageN");
            APSIMFileConverterUtilities.RenameVariable(node, ".NonStructuralNConc", ".StorageNConc");
            APSIMFileConverterUtilities.RenameVariable(node, "NonStructuralFraction", "StorageFraction");
            APSIMFileConverterUtilities.RenameVariable(node, "LeafStartNonStructuralNReallocationSupply", "LeafStartStorageFractionNReallocationSupply");
            APSIMFileConverterUtilities.RenameVariable(node, "LeafStartNonStructuralNRetranslocationSupply", "LeafStartStorageNRetranslocationSupply");
            APSIMFileConverterUtilities.RenameVariable(node, "LeafStartNonStructuralDMReallocationSupply", "LeafStartStorageDMReallocationSupply");
            APSIMFileConverterUtilities.RenameVariable(node, "NonStructuralDMDemand", "StorageDMDemand");
            APSIMFileConverterUtilities.RenameVariable(node, "NonStructuralNDemand", "StorageNDemand");

            // renames
            APSIMFileConverterUtilities.RenamePMFFunction(node, "LeafCohortParameters", "NonStructuralFraction", "StorageFraction");
            APSIMFileConverterUtilities.RenameNode(node, "NonStructuralNReallocated", "StorageNReallocated");
            APSIMFileConverterUtilities.RenameNode(node, "NonStructuralWtReallocated", "StorageWtReallocated");
            APSIMFileConverterUtilities.RenameNode(node, "NonStructuralNRetrasnlocated", "StorageNRetrasnlocated");
        }