/** * \brief Registers the created species to the simulation speciesManager * * <p>Registers the created species to the simulation speciesManager * * @param aSimulator The simulator object being used to create the conditions specified in the * protocol file * @param aSpRoot XML markup for the species being created. Taken from the protocol file */ public void register(Simulator aSimulator, XMLParser aSpRoot) { currentSimulator = aSimulator; speciesName = aSpRoot.getName(); speciesIndex = aSimulator.speciesList.size(); aSimulator.speciesList.add(this); domain = aSimulator.world.getDomain(aSpRoot.getAttribute("computationDomain")); }
public void initFromProtocolFile(Simulator aSim, XMLParser aSpeciesRoot) { // Initialisation of Bacterium super.initFromProtocolFile(aSim, aSpeciesRoot); // Chemotaxis-specific protocol parameters chemoeffector = aSpeciesRoot.getParam("chemoeffector").trim(); repellent = aSpeciesRoot.getParamBool("repellent"); chem_threshold = aSpeciesRoot.getParamDbl("chem_threshold"); init(); }
/** * \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"); }
public void init(Simulator aSim, XMLParser aSpeciesRoot, XMLParser speciesDefaults) { super.init(aSim, aSpeciesRoot, speciesDefaults); /* * Retrieving list of environments to which this species is sensitive * to and the correspondent probability of dying if under the * influence of that environment. */ String s; Double p; for (Element aSpeciesMarkUp : aSpeciesRoot.getChildrenElements("envSensitivity")) { s = aSpeciesMarkUp.getAttributeValue("name"); envSensitivity.add(s); p = aSpeciesRoot.getDblAttrOfChildSuchAttribute("envSensitivity", "name", s, "probDie"); envProbDie.put(s, p); } }
/** * \brief Defines a region of the computation domain where a new species may be created, using * restrictions in the protocol file * * <p>Defines a region of the computation domain where a new species may be created, using * restrictions in the protocol file. These restrictions for a particular species are specified in * 'coordinates' tags. There should be two such tags where this is used - one to start the * restriction and one to end it. Example of use: \<coordinates x="0" y="0" z="0"/\> \<coordinates * x="1" y="264" z="0"/\>. This method will read these in and create an array that represents this * area * * @param spRoot The information within the 'initArea' tags of the protocol file * @return A continuous vector representing the area of the domain specified in these tags */ public ContinuousVector[] defineSquareArea(XMLParser spRoot) { List<XMLParser> area = spRoot.getChildrenParsers("coordinates"); ContinuousVector[] initArea = new ContinuousVector[2]; initArea[0] = new ContinuousVector(); initArea[1] = new ContinuousVector(); // KA NOV 13 - CHANGED THIS, AS WE'RE GOING TO LET THE USER NOT DECLARE AN INITIAL AREA IF THEY // WANT THE CELLS SPREAD ACROSS // THE WHOLE DOMAIN. THUS THIS NEEDS CHECKING AND FIXING if (area.size() > 0) { // First Coordinate Tag ContinuousVector cc1 = new ContinuousVector(area.get(0)); // Second Coordinate Tag ContinuousVector cc2 = new ContinuousVector(area.get(1)); // Set each point initArea[0].x = Math.min(cc1.x, cc2.x); initArea[1].x = Math.max(cc1.x, cc2.x); initArea[0].y = Math.min(cc1.y, cc2.y); initArea[1].y = Math.max(cc1.y, cc2.y); // In the case of 2D simulation, the agent's z-coordinate is 0. if (domain.is3D) { initArea[0].z = Math.min(cc1.z, cc2.z); initArea[1].z = Math.max(cc1.z, cc2.z); } else { initArea[0].z = initArea[1].z = 0.0; } } else { // NO INITIAL AREA HAS BEEN DECLARED, USE THE WHOLE SUBSTRATUM. NOTE THAT THE X (HEIGHT) // COORDINATE IS SET TO 1 SO THE // CELLS ARE PLACED NEAR THE SUBSTRATUM // Set each point initArea[0].x = 0.0; initArea[0].y = 0.0; initArea[0].z = 0.0; initArea[1].x = 1.0; initArea[1].y = domain.length_Y; initArea[1].z = domain.length_Z; } return initArea; }
public void initFromProtocolFile(Simulator aSim, XMLParser xmlMarkUp) { // Initilaisation of the Located agent // super.initFromProtocolFile(aSimulator, aSpeciesRoot); // init(); _nCopy = getSpeciesParam().nCopy; int reacIndex; reactionActive = new ArrayList<Integer>(); for (Element aReactionMarkUp : xmlMarkUp.getChildrenElements("reaction")) { reacIndex = aSim.getReactionIndex(aReactionMarkUp.getAttributeValue("name")); /* * Add the reaction to the list of active reactions. */ if (aReactionMarkUp.getAttributeValue("status").equals("active")) reactionActive.add(reacIndex); } }
/** * \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)); }
public static void main(String[] args) throws Exception { // Modeler is either LDA or mallet XMLParser parser = new XMLParser(); parser.processPosts(args[0], args[1]); }