Exemple #1
0
 /**
  * \brief Select random coordinates for the new agent within a restricted birth area
  *
  * <p>Select random coordinates for the new agent within a restricted birth area. This restricted
  * area is set within the protocol file, and defined as a ContinuousVector by the method
  * defineSquareArea
  *
  * @param cc ContinuousVector that will hold the coordinates of this agent
  * @param area Area within which these coordinates should be restricted
  */
 public void shuffleCoordinates(ContinuousVector cc, ContinuousVector[] area) {
   do {
     cc.x = ExtraMath.getUniRandDbl(area[0].x, area[1].x);
     cc.y = ExtraMath.getUniRandDbl(area[0].y, area[1].y);
     cc.z = ExtraMath.getUniRandDbl(area[0].z, area[1].z);
   } while (domain.testCrossedBoundary(cc) != null);
 }
Exemple #2
0
  /**
   * \brief For self-attachment scenarios, determines whether a swimming agents move has taken it
   * across a boundary, correcting the coordinate accordingly
   *
   * <p>For self-attachment scenarios, the agents are swimming through the domain, and we need to
   * ensure that they perform the correct behaviour when the boundary is met. This method checks
   * whether an agents move has taken it over the boundary and applies the relevant correction
   * (either a bounce off the boundary or a reappearance on the other side). If the cell has hit the
   * surface, the cell is deemed to have adhered to that surface and a relevant x coordinate
   * generated to note that this is the case. The top of the domain is dealt with differently, as
   * this is checked by the call to isNewCoordAboveBoundaryLayer, which determines if the agent has
   * moved out of the boundary layer. If this is the case we assume this cell to have returned to
   * the bulk and do no further action with that cell. An integer is returned noting the fate of
   * this move - a 0 if the move is ok (after adjustment if required), a 1 if the agent has met the
   * substratum and attached, and a 2 if the cell has returned to the bulk
   *
   * @param distanceMoving Distance the agent is moving (in microns) in this move
   * @return Integer noting the fate of this move (0 move ok (after adjustment if required), 1 if
   *     attached to surface, 2 if returned to bulk
   */
  public int agentMoveBorderCheck() {
    // Simplest test to do first is to check if any boundaries have been crossed
    AllBC boundaryCrossed = domain.testCrossedBoundary(swimmingAgentPosition);

    // First is a simple test - has the cell returned to the bulk
    // If this is the case, we can just forget this and have another go
    // The cell will only have the capability to return to the bulk if the angle has it moving
    // upwards or directly across
    // (i.e 0-90 and 270-360 degrees)
    if (isNewCoordAboveBoundaryLayer()) {
      // The cell has returned into the bulk, and thus this try is over.
      // Return 2 so the process starts with a new cell.
      return 2;
    } else {
      // Now to see if the move takes the point outside any of the boundaries
      if (boundaryCrossed == null) {
        // No borders crossed, not back in the bulk.
        return 0;
      } else {
        String boundaryCrossedName = boundaryCrossed.getSideName();

        if (boundaryCrossedName.equals("y0z")) {
          // Detected that the move has crossed the substratum, thus
          // the cell has hit the biofilm. A return of 1 indicates
          // that this is the case.
          // Hit the biofilm, so set the species coordinates as required.

          // We may have hit the biofilm but the Y and Z coordinates
          // in this generated move may still be negative (as they
          // may have gone over another boundary). So before we set
          // the final x, we should check Y and Z.
          // So firstly, set the X position onto the surface
          swimmingAgentPosition.x = ExtraMath.getUniRandDbl();

          // Now set the final X position.
          // Do a new check on the boundary crossed.
          boundaryCrossed = domain.testCrossedBoundarySelfAttach(swimmingAgentPosition);

          if (boundaryCrossed != null) {
            boundaryCrossedName = boundaryCrossed.getSideName();
            if (boundaryCrossedName.equals("xNz") || boundaryCrossedName.equals("x0z"))
              correctCrossedLeftRightBoundaries(boundaryCrossed);
            else correctCrossedFrontBackBoundaries(boundaryCrossed);
          }
          return 1;
        } else if (boundaryCrossedName.equals("xNz") || boundaryCrossedName.equals("x0z")) {
          correctCrossedLeftRightBoundaries(boundaryCrossed);
          return 0;
        }
        // Deal with 3D boundary too
        else if (boundaryCrossedName.equals("x0y") || boundaryCrossedName.equals("xNy")) {
          correctCrossedFrontBackBoundaries(boundaryCrossed);
          return 0;
        } else {
          // This needs to be here so the function returns something.
          // However this deals with the top boundary (yNz) and this
          // has already been dealt with by the crossed bulk method.
          // So it is highly doubtful we will ever end up here.
          return 0;
        }
      }
    }
  }
Exemple #3
0
  /**
   * \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");
  }