Team:BCCS-Bristol/Modeling/HowBSimWorks

From 2009.igem.org

(Difference between revisions)
m (How BSim should work)
Line 1: Line 1:
{{:Team:BCCS-Bristol/Header}}
{{:Team:BCCS-Bristol/Header}}
-
== How BSim works ==
+
= How BSim works =
 +
 
 +
== The new structure ==
 +
 
 +
When we set out to restructure BSim it was decided that it should be made much more versatile and adaptable, and that as much as possible of the physics and coding should effectively be behind the scenes. This would allow stronger focus on the biological aspects of the simulation. To this end BSim has now been rebuilt as an environment where the user takes various functionalities already in place and uses them to create a simulation tailored to their specific requirements.
 +
 
 +
== Concept - how BSim Simulations should work ==
-
== How BSim should work ==
 
<pre>
<pre>
scene.particles.add(
scene.particles.add(
Line 20: Line 25:
   new ChemicalField(chemical: AHL)
   new ChemicalField(chemical: AHL)
)
)
-
 
scene.boundaries(..)
scene.boundaries(..)
Line 33: Line 37:
)
)
app.gui()
app.gui()
-
</pre>
 
-
 
-
== How AgentCell works ==
 
-
 
-
A very cut down version of Example.java in agentcell.runs:
 
-
 
-
<pre>
 
-
public class Example {
 
-
 
-
private static List cellArrayList;
 
-
 
-
public Example() {
 
-
        super();
 
-
    }
 
-
 
-
    // Setup and run a model.
 
-
    public static void main(String args[]) {
 
-
         
 
-
        final ChemotaxisModel model = new ChemotaxisModel();
 
-
 
 
-
        model.setDt(0.01);
 
-
        model.setStopTime(4.0); //2000.0);
 
-
        double equilibrationTime=2.0; //1000.0;
 
-
 
-
        final World world = new World();
 
-
        model.setWorld(world);
 
-
        world.setModel(model);
 
-
 
-
       
 
-
        BoundaryConditions boundaryConditions = new BoundaryConditions(world);
 
-
        world.setBoundaryConditions(boundaryConditions);
 
-
 
-
        // Set the chemical gradient.
 
-
        double aspartateGradient = 1.0E-8;  // M / micrometer
 
-
        world.setConcentrationField(new ConcentrationFieldConstantGradientWithBounds(
 
-
                Molecule.ASPARTATE, // type
 
-
                new Vect3(0, 0, 0), // origin
 
-
                0, // concentration at origin in Mol
 
-
                new Vect3(0, 0, aspartateGradient), 0, // min Level
 
-
                1.0E-2)); // max level
 
-
 
 
-
       
 
-
        //Create the cells
 
-
        cellArrayList = RunSetupUtils.findMatchingDirectories(new File(ChemotaxisModel.runDirAbsolutePath), "cell");       
 
-
        model.setAgentCellNumberOfCells(String.valueOf(cellArrayList.size()));
 
-
               
 
-
        for (int i = 0; i < cellArrayList.size(); i++) {
 
-
 
-
            double zpos = 100.0; //position chosen for the cell to be in 1 uM aspartate
 
-
            Vect position = new Vect3(0, 0, zpos);
 
-
 
-
            Orientation orientation = new Orientation(); //local and global axes are aligned
 
-
            orientation.randomize();
 
-
 
-
            double volume = 1.41E-15;
 
-
 
-
            ChemotacticCell cell = new ChemotacticCell(world, position,
 
-
                    orientation, new Copynumber(Molecule.CHEYP), volume);
 
-
           
 
-
 
-
            cell.setPath( new File(cellArrayList.get(i).toString()).getAbsolutePath());                   
 
-
            cell.setEquilibrationTime(equilibrationTime);
 
-
 
-
            Receptors receptors = new Receptors(cell);
 
-
            receptors.getDissociationConstants().put("{asp}",new Double(1.71E-6)); 
 
-
            receptors.getDissociationConstants().put("{asp*}",new Double(12E-6));             
 
-
            cell.setReceptors(receptors);
 
-
 
-
            // Create a Network
 
-
            cell.setChemotaxisNetwork( new ChemotaxisNetwork(cell, "STCHSTC.INI",
 
-
            (new File(cell.getPath(), "network1") + File.separator + "Input")) );
 
-
           
 
-
            cell.getChemotaxisNetwork().getCopynumber(cell.getCheYp());
 
-
                     
 
-
 
-
            int initialMotorState;
 
-
 
-
            if (cell.getCheYp().getLevel() > cheYpThreshold.getLevel()) {
 
-
                initialMotorState = Motor.CW;
 
-
            } else {
 
-
                initialMotorState = Motor.CCW;
 
-
            }
 
-
 
-
            double minCWDuration = 0.1; // seconds
 
-
            double minCCWDuration = 0.1; // seconds
 
-
            double boxcarTimeWidth = 0.3; //seconds
 
-
            cell.setMotor(new AveragedCheYpThresholdMotor(cell,
 
-
                    initialMotorState, minCWDuration, minCCWDuration,
 
-
                    cheYpThreshold,
 
-
                    (int) Math.round(boxcarTimeWidth / model.getDt())));
 
-
 
-
            // Create a flagella group
 
-
            int flagellaState = Flagella.INVALIDSTATE;
 
-
 
-
            if (cell.getMotor().getState() == Motor.CCW) {
 
-
                flagellaState = Flagella.BUNDLED;
 
-
            } else {
 
-
                flagellaState = Flagella.APART;
 
-
            }
 
-
 
-
            //cell.setFlagella(new TetheredFlagellum(cell,flagellaState));
 
-
            cell.setFlagella(new SwimmingFlagella(cell, flagellaState));
 
-
 
-
            // Create a motion stepper with run and tumble states.
 
-
            RunTumbleStepper motionStepper = new RunTumbleStepper(cell);
 
-
 
-
            //Motion:
 
-
            double runSpeed = 20;
 
-
            double runRotationalDiffusion = 0.0620577;
 
-
            motionStepper.setRun(new Run(motionStepper, runSpeed,
 
-
                    runRotationalDiffusion));
 
-
 
-
            //Tumble that fits the distribution in
 
-
            //Fig. 3, p. 501 from Berg and Brown, Nature, 239, 500 (1972)
 
-
            double shape = 4;
 
-
            double scale = 18.32045567939674;
 
-
            double location = -4.606176605609249;
 
-
            motionStepper.setTumble(new TumbleGammaDistribution(motionStepper,
 
-
                    shape, scale, location));
 
-
 
-
            // motionStepper.setTumble(new TumbleCosinusDistribution(motionStepper));
 
-
            cell.setMotionStepper(motionStepper);
 
-
 
-
            //print info about cell
 
-
            System.out.println("Initial position of cell " +
 
-
                cell.getIdentifier() + " is :" + cell.getPosition());
 
-
 
-
            // Add the new cell to the world.
 
-
            world.getCells().add(cell);
 
-
        }
 
-
 
-
        // Create a new time schedule.
 
-
        model.setSchedule(new Schedule());
 
-
 
-
        // Schedule each of the cells to run.
 
-
        model.getSchedule().scheduleActionAtIntervalRnd(model.getDt(),
 
-
            ((List) model.getWorld().getCells()), ChemotacticCell.class, "step");
 
-
 
-
        // Run the model.
 
-
        BatchController control = new BatchController(new Vector());
 
-
        model.setController(control);
 
-
        control.setModel(model);
 
-
        model.addSimEventListener(control);
 
-
        control.begin();
 
-
    }
 
-
 
-
 
-
}
 
</pre>
</pre>

Revision as of 11:51, 25 September 2009

BCCS-Bristol
iGEM 2009

How BSim works

The new structure

When we set out to restructure BSim it was decided that it should be made much more versatile and adaptable, and that as much as possible of the physics and coding should effectively be behind the scenes. This would allow stronger focus on the biological aspects of the simulation. To this end BSim has now been rebuilt as an environment where the user takes various functionalities already in place and uses them to create a simulation tailored to their specific requirements.

Concept - how BSim Simulations should work

scene.particles.add(
  new Bacterium(position: 0 1 0, radius: 1),
  new Bacterium(position: 0 1 0, radius: 1),
  new Bacterium(position: 0 1 0, radius: 1),
  new Bead(position: 0 1 0),
);

b = new Bacterium()
b.grn(new GRN(dy/dx = -2x; dx/dz = y^2))
scene.particles.add(b);

scene.chemicalFields.add(
  new ChemicalField(chemical: aspartate),
  new ChemicalField(chemical: AHL)
)

scene.boundaries(..)
scene.dt(..)
scene.simulationTime(..)

app.renderer(new ProcessingRenderer())
app.exporters.add(
  new FileExporter(),
  new MovieExporter(),
  new ScreenshotExporter()
)
app.gui()