コード例 #1
0
ファイル: Species.java プロジェクト: roughhawkbit/iDynoMiCS
  /**
   * \brief Used in 'one-time' attachment scenarios, where clones of the progenitor are created in
   * the birth area of the substratum.
   *
   * @param spRoot The XML mark-up group for a particular species being created.
   */
  public void createPop(XMLParser spRoot) {
    int howMany = spRoot.getAttributeInt("number");
    if (howMany <= 0) return;

    // Define the birth area - this is taken from the coordinates tags in the protocol file
    // (Nov13) OR if an initial area is not declared, this is the whole Y and Z of the domain with a
    // height of 1.
    ContinuousVector[] _initArea = defineSquareArea(spRoot);
    // Create all the required agents
    ContinuousVector cc = new ContinuousVector();

    for (int i = 0; i < howMany; i++)
      if (_progenitor instanceof LocatedAgent) {
        // Set coordinates within the birth area - randomly
        if (!Simulator.isChemostat) shuffleCoordinates(cc, _initArea);

        // Create the agent at these coordinates
        ((LocatedAgent) _progenitor).createNewAgent(cc);
      } else _progenitor.createNewAgent();

    LogFile.writeLog(
        howMany
            + " agents of species "
            + speciesName
            + " for one-time attachment successfully created");
  }
コード例 #2
0
ファイル: Species.java プロジェクト: roughhawkbit/iDynoMiCS
  /**
   * \brief Creates a species object from that specified in the XML protocol file
   *
   * <p>This method takes an object specified in the SPECIES mark-up and creates a simulation object
   * for that species
   *
   * @param aSimulator The simulation object used to simulate the conditions specified in the
   *     protocol file
   * @param aSpRoot A Species mark-up within the specified protocol file
   */
  public Species(Simulator aSimulator, XMLParser aSpRoot, XMLParser speciesDefaults) {
    // Name of the species as specified in the protocol file
    speciesName = aSpRoot.getName();

    // colour is used to distinguish agents in POV-Ray output images - read this from the protocol
    // file
    String colorName = aSpRoot.getParam("color");

    // Set the colour to white if not specified
    if (colorName == null) colorName = "white";
    // Translate this text string into a colour
    color = utils.UnitConverter.getColor(colorName);

    // Register this species
    // KA 8/3/13 - is this correct - this is storing the number of species in the simulation
    speciesIndex = aSimulator.speciesList.size();

    // Take a local copy of the current simulation
    currentSimulator = aSimulator;

    // KA May 2013
    // If this is self-attach, useful to store the injection period parameters here, so can
    // reference these later
    cellInjectionStartHour = aSpRoot.getParamDbl("cellInjectionStartHour");
    injectionOnAttachmentFrequency = aSpRoot.getParamDbl("injectionOnAttachmentFrequency");
    cellInjectionEndHour = aSpRoot.getParamDbl("cellInjectionEndHour");
    injectionOffAttachmentFrequency = aSpRoot.getParamDbl("injectionOffAttachmentFrequency");

    // Create the progenitor and tune its speciesParam object
    _progenitor = (SpecialisedAgent) aSpRoot.instanceCreator("simulator.agent.zoo");
    // Get parameters for this progenitor object from the protocol file if present

    _progenitor.getSpeciesParam().init(aSimulator, aSpRoot, speciesDefaults);

    _progenitor.setSpecies(this);

    // Set the computational domain this species is associated with
    // KA Aug 13 - changed as this may be a default
    domain =
        aSimulator.world.getDomain(
            _progenitor
                .getSpeciesParam()
                .getSpeciesParameterString("computationDomain", aSpRoot, speciesDefaults));
  }
コード例 #3
0
ファイル: Species.java プロジェクト: roughhawkbit/iDynoMiCS
 /**
  * \brief Return the parameters associated with this species (a SpeciesParam object)
  *
  * <p>Return the parameters associated with this species. These are contained within a
  * SpeciesParam object
  *
  * @return SpeciesParam object associated with this Species
  */
 public SpeciesParam getSpeciesParam() {
   return _progenitor.getSpeciesParam();
 }
コード例 #4
0
ファイル: Species.java プロジェクト: roughhawkbit/iDynoMiCS
 /**
  * \brief Returns a clone of the progenitor of this species
  *
  * <p>Returns a clone of the progenitor of this species. Throws an exception if this clone cannot
  * be found
  *
  * @return a clone of the progenitor
  * @throws CloneNotSupportedException
  */
 public SpecialisedAgent sendNewAgent() throws CloneNotSupportedException {
   return _progenitor.sendNewAgent();
 }
コード例 #5
0
ファイル: Species.java プロジェクト: roughhawkbit/iDynoMiCS
  /**
   * \brief For self-attachment scenarios, initialises agents on the boundary layer rather than
   * substrarum, and models their swim to the surface or biofilm
   *
   * <p>For self-attachment scenarios, the agents are initialised at the top of the boundary layer
   * rather than on the substratum. These agents then perform a 'run and tumble' motion until they
   * either attach to the substratum or forming biofilm. This method captures this behaviour for
   * cells that are created for a time step. Once this swimming action has been performed, the agent
   * is created at its final position. Note that input of agents onto the boundary layer is decided
   * by a parameter set in the protocol file, cellAttachmentFrequency, measured in hours. The number
   * of cells is adjusted to suit the global time step that is being used. Also note that this
   * injection of cells can be for a set period (specified in the protocol file as parameter
   * cellInjectionPeriod), or can be stopped and started (modelling a 'settling' period) using
   * parameters cellInjectionOffPeriod and cellInjectionStopHour. This is explained in detail in the
   * tutorial for version 1.2 of iDynoMiCS.
   *
   * @param spRoot The Species markup from the protocol file for one particular species being
   *     initialised
   * @param numberAttachedInjectedAgents The number of agents of this type that need to be created
   *     in this global timestep
   */
  public void createBoundaryLayerPop(XMLParser spRoot, int numberAttachedInjectedAgents) {
    LogFile.writeLog(
        "\t\tAttempting to create "
            + numberAttachedInjectedAgents
            + " agents of "
            + speciesName
            + " in the boundary layer");
    // Create all the required agents

    // Note that this continues UNTIL THE DESIRED NUMBER OF CELLS HAVE ATTACHED SOMEWHERE
    // Just out of interest, I've decided to keep a count of how many cells are required for this to
    // happen
    int totalNumberOfInjectedAgents = 0;
    int agentsReturnedToBulk = 0;
    int requiredNumAttachedAgents = numberAttachedInjectedAgents;

    // Temporary DiscreteVector to make finding the boundary layer tidier.
    DiscreteVector dV = new DiscreteVector();

    while (numberAttachedInjectedAgents > 0) {
      totalNumberOfInjectedAgents++;

      if (_progenitor instanceof LocatedAgent) {
        swimmingAgentPosition.reset();

        // Now to choose coordinates for this particular agent
        while (true) {
          // This cell needs to take a random location in the Z and Y
          // directions. The X will come from the position of the
          // boundary layer on those axes. Generate these randomly.
          swimmingAgentPosition.y = ExtraMath.getUniRandDbl() * domain.length_Y;
          if (domain.is3D) {
            swimmingAgentPosition.z = ExtraMath.getUniRandDbl() * domain.length_Z;
          }
          // Now to work out the X coordinate. This is based on where
          // the top of the boundary layer is when this agent is
          // created. The top of the boundary layer is calculated in
          // Domain at each step. Now the resolution differs (this is
          // in nI x nJ x nK rather than microns - so this will need
          // to be converted accordingly. Method to calculate this:
          // - get the value from the top of the boundary layer
          // - reduce by 1 (such that the micron value will be the
          // 						 top of the layer)
          // - multiply by resolution of this domain.
          dV.set(swimmingAgentPosition, domain._resolution);
          if (!domain.is3D) dV.k = 1;
          swimmingAgentPosition.x = domain._topOfBoundaryLayer[dV.j][dV.k] - 1.0;

          swimmingAgentPosition.x *= domain._resolution;
          // Check this is ok.
          // System.out.println("Trying starting position "+dV.toString()+" =>
          // "+this.swimmingAgentPosition.toString());
          if (domain.testCrossedBoundary(swimmingAgentPosition) == null) break;
        }

        // Now we can do the run and tumble motion of these cells

        int cellRunResult = performRunAndTumble(spRoot);

        // If increment the relevant counters, as these may be useful
        switch (cellRunResult) {
          case 1: // Successfully Attached
            numberAttachedInjectedAgents--;
            // Create the agent at these coordinates
            ((LocatedAgent) _progenitor).createNewAgent(this.swimmingAgentPosition);
            // System.out.println("Cell "+swimmingAgentPosition.toString()+" attached");
            break;
          case 2:
            // System.out.println("Cell at "+swimmingAgentPosition.toString()+" returned to bulk");
            agentsReturnedToBulk++;
            break;
        }
      } else {
        // If this isn't a located species, just create a new agent.
        _progenitor.createNewAgent();
      }
    }
    // Write the stats to the log file incase of interest
    LogFile.writeLog(
        requiredNumAttachedAgents
            + " agents of species "
            + speciesName
            + " for self-attachment successfully created");
    LogFile.writeLog(
        totalNumberOfInjectedAgents + " agents of species " + speciesName + " attempted to attach");
    LogFile.writeLog(
        agentsReturnedToBulk + " agents of species " + speciesName + " returned to the bulk");
  }
コード例 #6
0
ファイル: Species.java プロジェクト: roughhawkbit/iDynoMiCS
 /**
  * \brief Create a species from a set progenitor
  *
  * <p>Create a species from a set progenitor
  *
  * @param aProgenitor Progenitor from which the species is being created
  */
 public Species(SpecialisedAgent aProgenitor) {
   _progenitor = aProgenitor;
   aProgenitor.setSpecies(this);
 }