Ejemplo n.º 1
0
    def ParseXMLNode(self, orebodyDataNode):
        """
      Generate Ore body data from xml tree node. 
      """
        self.type = GetAttributeString(orebodyDataNode, "type")
        self.dip = GetAttributeValue(orebodyDataNode, "dip")

        self.cover = GetAttributeValue(orebodyDataNode, "cover")

        if (HasAttribute(orebodyDataNode, "length")):
            self.length = GetAttributeValue(orebodyDataNode, "length")
            self.width = GetAttributeValue(orebodyDataNode, "width")
            self.height = GetAttributeValue(orebodyDataNode, "height")
            if (self.width > self.length):
                temp = self.width
                self.width = self.length
                self.length = temp
        elif (HasAttribute(orebodyDataNode, "mass")):
            self.orebodyMass = GetAttributeValue(orebodyDataNode, "mass")
            self.CalculateDepositVolume()
            self.CalculateDepositDimensionsFromVolume()
        else:
            BluecapError("Failed to find orebody mass or dimensions in input.")

        for child in GetChildren(orebodyDataNode):
            type = GetXMLTag(child)
            name = GetAttributeString(child, "name")
            grade = GetAttributeValue(child, "grade")

            self.metalGrades[name] = grade
Ejemplo n.º 2
0
 def ParseXMLNode(self,actionNode,problemManager):
     """
     Generate an Iterator action from the xml tree node. 
     """
   
     self.number = GetAttributeValueOrDefault(actionNode,"number",self.number)
     for child in GetChildren(actionNode):
       type = GetXMLTag(child)
       self.actions.append(  ActionFactory.CreateFromXML(type,child,problemManager) )
     return
Ejemplo n.º 3
0
        def ParseXMLNode(self, problemManager, solvManagerNode):
            """
        Generate Solvers from xml tree node. 
        """

            for child in GetChildren(solvManagerNode):
                type = GetXMLTag(child)
                name = GetAttributeString(child, "name")
                self.solvers[name] = SolverFactory.CreateFromXML(
                    type, child, problemManager)
Ejemplo n.º 4
0
        def ParseXMLNode(self, fnManagerNode, problemManager):
            """
        Generate Functions  from xml tree node. 
        """

            for child in GetChildren(fnManagerNode):
                type = GetXMLTag(child)
                name = GetAttributeString(child, "name")

                self.functions[name] = FunctionFactory.CreateFromXML(
                    type, child, problemManager)
Ejemplo n.º 5
0
 def ParseXMLNode(self, rootNode):
   """
   Generate Problem Manager data from xml tree node. 
   """
   
   # remove "Problem" branch if present
   if(HasChild(rootNode,"Problem")):
     root = GetChild(rootNode,"Problem")
     
   # load parameters not set from command line
   # done here to prevent recursion
   theParameterManager = ParameterManager()  
   if(HasChild(rootNode,"Parameters")):
     parameterNode = GetChild(rootNode,"Parameters")
     
     for child in GetChildren(parameterNode):
     
       name = GetAttributeString(child,"name")
       
       if(not theParameterManager.HasParameter(name) ):
         paramString = GetAttributeString(child,"value")
         theParameterManager.SetParameter(name,paramString)
         print "param: ", name, " value:",paramString
     
   # create functions before other classes (after UnitManager & Parameter Manager)
   theFunctionManager = FunctionManager()  
   if(HasChild(rootNode,"Functions")):
     functionNode = GetChild(rootNode,"Functions")
     theFunctionManager.ParseXMLNode(functionNode,self) 
   
   # Mine data
   if(HasChild(rootNode,"MineData")):
     mineDataNode = GetChild(rootNode,"MineData")
     self.theMineDataManager.ParseXMLNode(mineDataNode) 
     
    
   # Output - eventually will make into a manager
   if(HasChild(rootNode,"Output")):
     outputNode = GetChild(rootNode,"Output")
     self.outputPrefix = GetAttributeFileString(outputNode,"prefix")
     self.outputType = GetAttributeStringOrDefault(outputNode,"type","")
     
     self.recordRange = GetAttributeValueOrDefault(outputNode,"recordRange",False)
     
   # Regional calculation - optional
   if(HasChild(rootNode,"RegionalCalculation")):
     regionalCalculationNode = GetChild(rootNode,"RegionalCalculation")
     self.theRegionalCalculationManager.ParseXMLNode(regionalCalculationNode) 
Ejemplo n.º 6
0
 def ParseXMLNode(self, economicDataNode):
   """
   Generate Economic Data Manager data from xml tree node. 
   """
   
   self.discountRate = GetAttributeValue(economicDataNode,"discountRate")
   
   for child in GetChildren(economicDataNode,"Commodity"):
   	name = GetAttributeString(child,"name")
   	price = GetAttributeValue(child,"price")
   	self.metalPrices[name] = price
   	
   if(HasAttribute(economicDataNode,"GandAFraction")):
     self.GandAFraction = GetAttributeValue(economicDataNode,"GandAFraction")
     
   if(HasAttribute(economicDataNode,"state")):
     self.state = GetAttributeString(economicDataNode,"state")
     
   if(HasAttribute(economicDataNode,"inflation")):
     self.inflation = GetAttributeValue(economicDataNode,"inflation")
    def ParseXMLNode(self, economicDataNode):
        """
      Generate Economic Data Manager data from xml tree node. 
      """

        EconomicDataManager.ParseXMLNode(self, economicDataNode)

        self.discountRate = GetAttributeValue(economicDataNode, "discountRate")

        for child in GetChildren(economicDataNode, "Commodity"):
            name = GetAttributeString(child, "name")
            price = GetAttributeValue(child, "price")
            self.commodityPrices[name] = price
            self.referenceCommodityPrices[name] = price
            self.commodityPriceSigmas[name] = 0.0
            if (HasAttribute(economicDataNode, "sigma")):
                self.commodityPriceSigmas[name] = GetAttributeValue(
                    child, "sigma")

        if (HasAttribute(economicDataNode, "GandAFraction")):
            self.GandAFraction = GetAttributeValue(economicDataNode,
                                                   "GandAFraction")

        if (HasAttribute(economicDataNode, "state")):
            self.state = GetAttributeString(economicDataNode, "state")

        if (HasAttribute(economicDataNode, "inflation")):
            self.inflation = GetAttributeValue(economicDataNode, "inflation")

        if (HasAttribute(economicDataNode, "calculateGasCosts")):
            self.calculateGasCosts = GetAttributeValue(economicDataNode,
                                                       "calculateGasCosts")

        if (HasAttribute(economicDataNode, "calculateBlackCoalCosts")):
            self.calculateBlackCoalCosts = GetAttributeValue(
                economicDataNode, "calculateBlackCoalCosts")

        if (HasAttribute(economicDataNode, "calculateBrownCoalCosts")):
            ## NB: This model uses CSIRO brown coal cost estimate (good) but employs black coal sensitivity to coal price per GJ due to lack of data.
            self.calculateBrownCoalCosts = GetAttributeValue(
                economicDataNode, "calculateBrownCoalCosts")
Ejemplo n.º 8
0
 def ParseXMLNode(self, rootNode):
   """
   Generate Problem Manager data from xml tree node. 
   """
   
   # remove "Problem" branch if present
   if(HasChild(rootNode,"Problem")):
     root = GetChild(rootNode,"Problem")
     
   # load parameters not set from command line
   # done here to prevent recursion
   theParameterManager = ParameterManager()  
   if(HasChild(rootNode,"Parameters")):
     parameterNode = GetChild(rootNode,"Parameters")
     
     for child in GetChildren(parameterNode):
     
       name = GetAttributeString(child,"name")
       
       if(not theParameterManager.HasParameter(name) ):
         paramString = GetAttributeString(child,"value")
         theParameterManager.SetParameter(name,paramString)
         print("param: ", name, " value:",paramString)
     
   # create functions before other classes (after UnitManager & Parameter Manager)
   theFunctionManager = FunctionManager()  
   if(HasChild(rootNode,"Functions")):
     functionNode = GetChild(rootNode,"Functions")
     theFunctionManager.ParseXMLNode(functionNode,self) 
   
   # Mine data
   if(HasChild(rootNode,"MineData")):
     mineDataNode = GetChild(rootNode,"MineData")
     self.theMineDataManager.ParseXMLNode(mineDataNode) 
   
   # Processing data
   if(HasChild(rootNode,"Processing")):
     processingNode = GetChild(rootNode,"Processing")
     self.theMineDataManager.theProcessingSystem.ParseXMLNode(processingNode)
    
   # Hydrogen data
   if(HasChild(rootNode,"HydrogenData")):
     hydrogenDataNode = GetChild(rootNode,"HydrogenData")
     self.theHydrogenDataManager.ParseXMLNode(hydrogenDataNode) 
     
   # Output - eventually will make into a manager
   if(HasChild(rootNode,"Output")):
     outputNode = GetChild(rootNode,"Output")
     self.outputPrefix = GetAttributeFileString(outputNode,"prefix")
     self.outputType = GetAttributeStringOrDefault(outputNode,"type","")
     
     self.recordRange = GetAttributeValueOrDefault(outputNode,"recordRange",False)
     
   # Regional calculation - optional - eventually will make into a solver
   if(HasChild(rootNode,"RegionalCalculation")):
     regionalCalculationNode = GetChild(rootNode,"RegionalCalculation")
     self.theRegionalCalculationManager.ParseXMLNode(regionalCalculationNode) 
 
   # Solver manager (after UnitManager & Parameter Manager & Function Manager)
   if(HasChild(rootNode,"Solvers")):
     solversNode = GetChild(rootNode,"Solvers")
     theSolverManager = SolverManager()
     theSolverManager.ParseXMLNode(self,solversNode) 
 
   # Create actions after other classes (after UnitManager & Parameter & Solver Manager)
   self.theActionManager = ActionManager()  
   if(HasChild(rootNode,"Actions")):
     actionNode = GetChild(rootNode,"Actions")
     self.theActionManager.ParseXMLNode(actionNode,self)   
   else:
   
     # Add actions for backwards compatibility
     # A) If regional manager present - run regional calculation
     # B) Otherwise add single site calculation
     
     # This will be depreciated (need to issue warning)
     if(self.theRegionalCalculationManager.type):
         self.theActionManager.actions.append( RegionalCalculationAction() )
     else:
         self.theActionManager.actions.append( SingleSiteEvaluationAction() )
Ejemplo n.º 9
0
 def ParseXMLNode(self, mineDataNode):
   """
   Generate Mine Data Manager data from xml tree node. 
   """
   
   # Location
   if(HasChild(mineDataNode,"Location")):
     locNode = GetChild(mineDataNode,"Location")
     self.mineLatLong[0] = GetAttributeValue(locNode,"lat")
     self.mineLatLong[1] = GetAttributeValue(locNode,"long")
   
   # Orebody
   if(HasChild(mineDataNode,"Orebody")):
     orebodyNode = GetChild(mineDataNode,"Orebody")
     orebodyName = GetAttributeStringOrDefault(orebodyNode,"name","unnamed")
     self.theOrebodies[orebodyName] = OreBodyDataManager(orebodyName)
     self.theOrebodies[orebodyName].ParseXMLNode(orebodyNode)
     self.theOrebodies["Active"] = self.theOrebodies[orebodyName]
     self.theOreBody = self.theOrebodies[orebodyName]
     self.theMines[orebodyName] = MiningSystemDataManager(orebodyName)
     self.theMiningSystem = self.theMines[orebodyName]
     
   # Orebody Set
   if(HasChild(mineDataNode,"OrebodyList")):
     orebodyList = GetChild(mineDataNode,"OrebodyList")
     setActive = True
     for orebodyNode in GetChildren(orebodyList):
     
       if(GetXMLTag(orebodyNode) != "note"):
         
         orebodyName = GetAttributeString(orebodyNode,"name")
         self.theOrebodies[orebodyName] = OreBodyDataManager(orebodyName)
         self.theOrebodies[orebodyName].latLong = np.array(self.mineLatLong)  # set global lat long as orebody lat long as default
         self.theOrebodies[orebodyName].ParseXMLNode(orebodyNode)
       
         self.theMines[orebodyName] = MiningSystemDataManager(orebodyName)
       
         if(setActive):
           self.theOrebodies["Active"] = self.theOrebodies[orebodyName]
           self.theOreBody = self.theOrebodies[orebodyName]
           self.theMiningSystem = self.theMines[orebodyName]
           setActive = False
         
       
   
   theFunctionManager = FunctionManager()
   if( (self.theOreBody.cover < 0.0 ) and (theFunctionManager.HasFunction("DepthOfCover") ) ):
     self.theOreBody.cover = theFunctionManager.GetFunction("DepthOfCover").f( self.mineLatLong[::-1]  )
     print("Cover set to: ", self.theOreBody.cover )
     
     
   
   if(HasChild(mineDataNode,"Mining")):
     miningNode = GetChild(mineDataNode,"Mining")
     # pass XML settings to all orebodies
     self.theMines["Active"].ParseXMLNode(miningNode)
     for orebodyName in self.theOrebodies:
       self.theMines[orebodyName].ParseXMLNode(miningNode)
     
   # Infrastructure
   if(HasChild(mineDataNode,"Infrastructure")):
     infrastructureNode = GetChild(mineDataNode,"Infrastructure")
     self.theInfrastructureManager.ParseXMLNode(infrastructureNode)      
 
   # Rehabilitation
   if(HasChild(mineDataNode,"Rehabilitation")):
     rehabNode = GetChild(mineDataNode,"Rehabilitation")
     self.theRehabilitationManager = RehabilitationDataManager()
     self.theRehabilitationManager.ParseXMLNode(rehabNode)    
     
   # Economics
   if(HasChild(mineDataNode,"Economics")):
     economicsNode = GetChild(mineDataNode,"Economics")
     self.theEconomicDataManager.ParseXMLNode(economicsNode)