Component

From VLECK
Jump to: navigation, search

A Component in CSR is the basic building block. nearly everything that is, that is, exists for more than a technical reason, is either a state or a component. Several subclasses are derived from Component to add specific functionality. Components can be created in code, but also defined within a type file.

Components have states and parameters and can own child or member components. A component supplies methods so its can be integrated; descendant components should overide these methods.

printing a component

printing the states

To print the current values of a component's states, use

aComponent.printStates()

This is a non-recursive method to print to screen the states' values and rates, e.g.:

self.metabolicPool.printStates()
• States of MetabolicPool: metabolicPool
   º ammonium  = ammonium: 0.050000 mol (dx/dt = 0.000000)
   º carbon  = carbon: 1.000000 mol (dx/dt = 0.000000)
   º nitrate  = nitrate: 0.050000 mol (dx/dt = 0.000000)
   º water  = water: 0.050000 mol (dx/dt = 0.000000)


print the component's structure

To inspect how a component is built up from member components, both created in code and from it's type definition, use

aComponent.printComponent()

This recursively prints to screen all the component's children, grand-children, etc., e.g.:

self.metabolicPool.printComponent()
• structure of PlantCohort: yggdrasil at patch[0,0]
 º PlantComponent: branches of yggdrasil at patch[0,0]
 º MetabolicPool: metabolicPool of yggdrasil at patch[0,0]
 º CoarseRoot: coarseRoots of yggdrasil at patch[0,0]
 º FineRoot: fineRoots of yggdrasil at patch[0,0]
 º PlantComponent: stem of yggdrasil at patch[0,0]
 º Leaves: leaves of yggdrasil at patch[0,0]
   º Photosynthesis: anonymous component
 º PlantComponent: reserve of yggdrasil at patch[0,0]
 º Allocation: anonymous component of yggdrasil at patch[0,0]
 º Phenology: phenology of yggdrasil at patch[0,0]


print all of the component

A ComponentPrinter is available from the printers-unit, that recurses the component and prints all of its states and members.

ComponentPrinter().printIt(aComponent)
ComponentPrinter().printIt(aComponent)
yggdrasil at patch[0,0]: -----
   · states:
       º age  = age: 0.000000  (dx/dt = 0.000000)
       º crownBase  = crownBase: 2.000000 m (dx/dt = 0.000000)
       º crownHeight  = crownHeight: 10.000000 m (dx/dt = 0.000000)
       º crownRadius  = crownRadius: 2.000000 m (dx/dt = 0.000000)
       º nrOfIndividuals  = nrOfIndividuals: 0.000000  (dx/dt = 0.000000)
       º rootingDepth  = rootingDepth: 1.200000 m (dx/dt = 0.000000)
       º weight  = weight: 100.000000 kg (dx/dt = 0.000000)
   · components:
     º branches
       · states:
           º ammonium  = ammonium: 1.000000 mol (dx/dt = 0.000000)
           º carbon  = carbon: 1.000000 mol (dx/dt = 0.000000)
           º nitrate  = nitrate: 1.000000 mol (dx/dt = 0.000000)
     º coarseRoots
       · states:
           º ammonium  = ammonium: 1.000000 mol (dx/dt = 0.000000)
           º carbon  = carbon: 1.000000 mol (dx/dt = 0.000000)
           º nitrate  = nitrate: 1.000000 mol (dx/dt = 0.000000)
     º fineRoots
       · states:
           º ammonium  = ammonium: 1.000000 mol (dx/dt = 0.000000)
           º carbon  = carbon: 1.000000 mol (dx/dt = 0.000000)
           º nitrate  = nitrate: 1.000000 mol (dx/dt = 0.000000)
     º leaves
       · states:
           º ammonium  = ammonium: 1.000000 mol (dx/dt = 0.000000)
           º carbon  = carbon: 1.000000 mol (dx/dt = 0.000000)
           º nitrate  = nitrate: 1.000000 mol (dx/dt = 0.000000)
     º metabolicPool
       · states:
           º ammonium  = ammonium: 0.050000 mol (dx/dt = 0.000000)
           º carbon  = carbon: 1.000000 mol (dx/dt = 0.000000)
           º nitrate  = nitrate: 0.050000 mol (dx/dt = 0.000000)
           º water  = water: 0.050000 mol (dx/dt = 0.000000)
     º reserve
       · states:
           º ammonium  = ammonium: 1.000000 mol (dx/dt = 0.000000)
           º carbon  = carbon: 1.000000 mol (dx/dt = 0.000000)
           º nitrate  = nitrate: 1.000000 mol (dx/dt = 0.000000)
     º stem
       · states:
           º ammonium  = ammonium: 1.000000 mol (dx/dt = 0.000000)
           º carbon  = carbon: 1.000000 mol (dx/dt = 0.000000)
           º nitrate  = nitrate: 1.000000 mol (dx/dt = 0.000000)