CMS 3D CMS Logo

Public Member Functions | Public Attributes

twikiExport::Material Class Reference

List of all members.

Public Member Functions

def __init__
def __str__
def addConstituent
def getMass
def getRealValues
def getSimValues

Public Attributes

 theComment
 theConstituents
 theDescription
 theMcVolume
 theName

Detailed Description

Definition at line 23 of file twikiExport.py.


Constructor & Destructor Documentation

def twikiExport::Material::__init__ (   self,
  matString,
  comment 
)

Definition at line 24 of file twikiExport.py.

00025                                           :
00026         if matString == "" or not matString[0] == "#":
00027             raise StandardError , "not a valid material Definition: "+matString
00028         line = matString[1:]
00029 
00030         if    len( line.split('"') ) < 5 or len( line.split('"')[4].split() ) < 2:
00031             raise StandardError , "not a well formed Material Definition: "+matString            
00032         self.theDescription = line.split('"')[1]
00033         self.theName = line.split('"')[3]
00034         self.theMcVolume = float(line.split('"')[4].split()[0])
00035         self.theComment = comment
00036         self.theConstituents = []
    

Member Function Documentation

def twikiExport::Material::__str__ (   self)

Definition at line 83 of file twikiExport.py.

00084                      :
00085         result = "[ "+self.theName+" Description: "+self.theDescription+" MC-Volume:"+str(self.theMcVolume)+"\n"
00086         result += "Comments:\n"+self.theComment
00087         return result
00088 
#parses the .in File
def twikiExport::Material::addConstituent (   self,
  constString,
  predefinedMaterials 
)

Definition at line 73 of file twikiExport.py.

00074                                                               :
00075         if constString  == "" or not constString[0] == "*":
00076             raise StandardError , "not a valid Constituent: "+constString
00077         line = constString[1:]
00078         self.theConstituents.append( Constituent(line, predefinedMaterials) )
00079 
00080         number = int( line.split('"')[0].split()[0] )
00081         if not len(self.theConstituents) == number:
00082             raise StandardError, "Constituent Number mismatch for "+str(len(self.theConstituents))+" in: "+line
    
def twikiExport::Material::getMass (   self)

Definition at line 67 of file twikiExport.py.

00068                      :
00069         result = 0
00070         for con in self.theConstituents:
00071             result += con.theMass * con.theCount
00072         return result
        
def twikiExport::Material::getRealValues (   self)

Definition at line 37 of file twikiExport.py.

00038                            :
00039         result = {}
00040         result["Volume"] = 0
00041         result["X0"] = 0
00042         result["L0"] = 0
00043         
00044         totMass =  self.getMass()
00045         invX0 = 0
00046         invL0 = 0
00047         for con in self.theConstituents:
00048             pWeight = con.theVolume * con.theDensity / totMass
00049             invX0 += pWeight / con.theX0
00050             invL0 += pWeight / con.theL0
00051             result["Volume"] += con.theVolume 
00052         result["Density"] = self.getMass() / result["Volume"]            
00053         result["X0"] = 1 / ( invX0 * result["Density"] )
00054         result["L0"] = 1 / ( invL0 * result["Density"] )
00055         
00056         return result
    
def twikiExport::Material::getSimValues (   self)

Definition at line 57 of file twikiExport.py.

00058                           :
00059         result = self.getRealValues()
00060         fraction = self.theMcVolume / result["Volume"]
00061         result["Volume"] = self.theMcVolume
00062         result["Density"] = self.getMass() / self.theMcVolume
00063         result["X0"] *= fraction
00064         result["L0"] *= fraction
00065     
00066         return result
   

Member Data Documentation

Definition at line 24 of file twikiExport.py.

Definition at line 24 of file twikiExport.py.

Definition at line 24 of file twikiExport.py.

Definition at line 24 of file twikiExport.py.

Definition at line 24 of file twikiExport.py.