Skip to content

Commit

Permalink
NeuronSharedCOnstants and NeuronConstants are consolidated into one c…
Browse files Browse the repository at this point in the history
…lass (NeuronConstants)
  • Loading branch information
ashrafabu committed Dec 8, 2014
1 parent 5d5c187 commit 5363cb0
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 50 deletions.
15 changes: 13 additions & 2 deletions js/neuron/NeuronConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ define( function( require ) {
var PhetFont = require( 'SCENERY_PHET/PhetFont' );
var Color = require( 'SCENERY/util/Color' );

var clockFrameRate = 15;
var minActionPotentialClockDT = (1 / clockFrameRate) / 3000;
var maxActionPotentialClockDT = (1 / clockFrameRate) / 1000;

return Object.freeze( {
// Fonts
CONTROL_PANEL_TITLE_FONT: new PhetFont( {weight: 'bold', size: 14} ),
Expand All @@ -25,7 +29,14 @@ define( function( require ) {
PROJECT_NAME: "neuron",
MEMBRANE_THICKNESS: 4, // In nanometers, obtained from web research.
DEFAULT_DIAMETER: 150, // In nanometers.
SCREEN_BACKGROUND: '#ccfefa'
SCREEN_BACKGROUND: '#ccfefa',
CLOCK_FRAME_RATE: clockFrameRate, // fps, frames per second (wall time)
// Set up the clock ranges for the various modules. Note that for this
// sim the clock rates are often several orders of magnitude slower than
// real time.
MIN_ACTION_POTENTIAL_CLOCK_DT: minActionPotentialClockDT,
MAX_ACTION_POTENTIAL_CLOCK_DT: maxActionPotentialClockDT,
DEFAULT_ACTION_POTENTIAL_CLOCK_DT: (minActionPotentialClockDT + maxActionPotentialClockDT) * 0.55,
TIME_SPAN: 25 // In seconds.
} );

} );
6 changes: 3 additions & 3 deletions js/neuron/NeuronScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define( function( require ) {
var NeuronModel = require( 'NEURON/neuron/model/NeuronModel' );
var NeuronScreenView = require( 'NEURON/neuron/view/NeuronScreenView' );
var NeuronClockModelAdapter = require( 'NEURON/neuron/model/NeuronClockModelAdapter' );
var NeuronSharedConstants = require( 'NEURON/neuron/common/NeuronSharedConstants' );
var NeuronConstants = require( 'NEURON/neuron/NeuronConstants' );
var Screen = require( 'JOIST/Screen' );

// strings
Expand All @@ -27,8 +27,8 @@ define( function( require ) {
var neuronModel = new NeuronModel();
// NeuronModelAdapter intercepts the default Step function and provides
// "constant" clock and record Playback features to NeuronModel, see NeuronClockModelAdapter
var neuronClockModelAdapter = new NeuronClockModelAdapter( neuronModel, NeuronSharedConstants.CLOCK_FRAME_RATE,
NeuronSharedConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT );
var neuronClockModelAdapter = new NeuronClockModelAdapter( neuronModel, NeuronConstants.CLOCK_FRAME_RATE,
NeuronConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT );

Screen.call( this, neuronSimString, null /* no icon, single-screen sim */,
function() { return neuronClockModelAdapter; },
Expand Down
4 changes: 2 additions & 2 deletions js/neuron/chart/view/MembranePotentialChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ define( function( require ) {
var inherit = require( 'PHET_CORE/inherit' );
var Node = require( 'SCENERY/nodes/Node' );
var Bounds2 = require( 'DOT/Bounds2' );
var NeuronSharedConstants = require( 'NEURON/neuron/common/NeuronSharedConstants' );
var NeuronConstants = require( 'NEURON/neuron/NeuronConstants' );
var Line = require( 'SCENERY/nodes/Line' );
var Panel = require( 'SUN/Panel' );
var Path = require( 'SCENERY/nodes/Path' );
Expand Down Expand Up @@ -57,7 +57,7 @@ define( function( require ) {

// This value sets the frequency of chart updates, which helps to reduce
// the processor consumption.
var UPDATE_PERIOD = 1 * NeuronSharedConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT; // In seconds
var UPDATE_PERIOD = 1 * NeuronConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT; // In seconds

var bounds2 = new Bounds2( 0, 0, 0, 0 );

Expand Down
29 changes: 0 additions & 29 deletions js/neuron/common/NeuronSharedConstants.js

This file was deleted.

6 changes: 3 additions & 3 deletions js/neuron/model/ModifiedHodgkinHuxleyModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define( function( require ) {
// modules
var inherit = require( 'PHET_CORE/inherit' );
var DelayBuffer = require( 'NEURON/neuron/model/DelayBuffer' );
var NeuronSharedConstants = require( 'NEURON/neuron/common/NeuronSharedConstants' );
var NeuronConstants = require( 'NEURON/neuron/NeuronConstants' );

/**
Amount of time used for each iteration of the model. This is fixed,
Expand All @@ -40,8 +40,8 @@ define( function( require ) {
thisModel.perKChannels = 100;
thisModel.elapsedTime = 0;
thisModel.timeSinceActionPotential = Number.POSITIVE_INFINITY;
thisModel.m3hDelayBuffer = new DelayBuffer( MAX_DELAY, NeuronSharedConstants.MIN_ACTION_POTENTIAL_CLOCK_DT );
thisModel.n4DelayBuffer = new DelayBuffer( MAX_DELAY, NeuronSharedConstants.MIN_ACTION_POTENTIAL_CLOCK_DT );
thisModel.m3hDelayBuffer = new DelayBuffer( MAX_DELAY, NeuronConstants.MIN_ACTION_POTENTIAL_CLOCK_DT );
thisModel.n4DelayBuffer = new DelayBuffer( MAX_DELAY, NeuronConstants.MIN_ACTION_POTENTIAL_CLOCK_DT );

thisModel.resting_v = 65;// final doesn't change

Expand Down
4 changes: 2 additions & 2 deletions js/neuron/model/NeuronModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define( function( require ) {
var MembraneCrossingDirection = require( 'NEURON/neuron/model/MembraneCrossingDirection' );
var CaptureZoneScanResult = require( 'NEURON/neuron/model/CaptureZoneScanResult' );
var TimedFadeInStrategy = require( 'NEURON/neuron/model/TimedFadeInStrategy' );
var NeuronSharedConstants = require( 'NEURON/neuron/common/NeuronSharedConstants' );
var NeuronConstants = require( 'NEURON/neuron/NeuronConstants' );
var MathUtils = require( 'NEURON/neuron/utils/MathUtils' );

// Default configuration values.
Expand Down Expand Up @@ -120,7 +120,7 @@ define( function( require ) {
*/
function NeuronModel() {
var thisModel = this;
var maxRecordPoints = Math.ceil( NeuronSharedConstants.TIME_SPAN * 1000 / NeuronSharedConstants.MIN_ACTION_POTENTIAL_CLOCK_DT );
var maxRecordPoints = Math.ceil( NeuronConstants.TIME_SPAN * 1000 / NeuronConstants.MIN_ACTION_POTENTIAL_CLOCK_DT );
thisModel.axonMembrane = new AxonMembrane();

// List of the particles that come and go when the simulation is working in real time.
Expand Down
3 changes: 1 addition & 2 deletions js/neuron/model/PotassiumGatedChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ define( function( require ) {
var NeuronConstants = require( 'NEURON/neuron/NeuronConstants' );
var PieSliceShapedCaptureZone = require( 'NEURON/neuron/model/PieSliceShapedCaptureZone' );
var ParticleType = require( 'NEURON/neuron/model/ParticleType' );
var NeuronSharedConstants = require( 'NEURON/neuron/common/NeuronSharedConstants' );
var MembraneCrossingDirection = require( 'NEURON/neuron/model/MembraneCrossingDirection' );
var MathUtils = require( 'NEURON/neuron/utils/MathUtils' );
var MembraneChannelTypes = require( 'NEURON/neuron/model/MembraneChannelTypes' );
Expand All @@ -38,7 +37,7 @@ define( function( require ) {

// Delay range - used to make the timing of the instances of this gate
// vary a little bit in terms of when they open and close.
var MAX_STAGGER_DELAY = NeuronSharedConstants.MIN_ACTION_POTENTIAL_CLOCK_DT * 10; // In seconds of sim time.
var MAX_STAGGER_DELAY = NeuronConstants.MIN_ACTION_POTENTIAL_CLOCK_DT * 10; // In seconds of sim time.

var RAND = {nextDouble: function() {
return Math.random();
Expand Down
3 changes: 1 addition & 2 deletions js/neuron/model/SodiumDualGatedChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ define( function( require ) {
var MembraneCrossingDirection = require( 'NEURON/neuron/model/MembraneCrossingDirection' );
var DualGateChannelTraversalMotionStrategy = require( 'NEURON/neuron/model/DualGateChannelTraversalMotionStrategy' );
var ParticleType = require( 'NEURON/neuron/model/ParticleType' );
var NeuronSharedConstants = require( 'NEURON/neuron/common/NeuronSharedConstants' );
var MathUtils = require( 'NEURON/neuron/utils/MathUtils' );
var MembraneChannelTypes = require( 'NEURON/neuron/model/MembraneChannelTypes' );

Expand Down Expand Up @@ -59,7 +58,7 @@ define( function( require ) {

// Delay range - used to make the timing of the instances of this gate
// vary a little bit in terms of when they open and close.
var MAX_STAGGER_DELAY = NeuronSharedConstants.MIN_ACTION_POTENTIAL_CLOCK_DT * 5; // In seconds of sim time.
var MAX_STAGGER_DELAY = NeuronConstants.MIN_ACTION_POTENTIAL_CLOCK_DT * 5; // In seconds of sim time.


/**
Expand Down
10 changes: 5 additions & 5 deletions js/neuron/model/WanderAwayThenFadeMotionStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ define( function( require ) {
// modules
var inherit = require( 'PHET_CORE/inherit' );
var MotionStrategy = require( 'NEURON/neuron/model/MotionStrategy' );
var NeuronSharedConstants = require( 'NEURON/neuron/common/NeuronSharedConstants' );
var NeuronConstants = require( 'NEURON/neuron/NeuronConstants' );
var TimedFadeAwayStrategy = require( 'NEURON/neuron/model/TimedFadeAwayStrategy' );

// constants
var CLOCK_TICKS_BEFORE_MOTION_UPDATE = 5;
var CLOCK_TICKS_BEFORE_VELOCITY_UPDATE = CLOCK_TICKS_BEFORE_MOTION_UPDATE * 10;
var MOTION_UPDATE_PERIOD = NeuronSharedConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT * CLOCK_TICKS_BEFORE_MOTION_UPDATE;
var VELOCITY_UPDATE_PERIOD = NeuronSharedConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT * CLOCK_TICKS_BEFORE_VELOCITY_UPDATE;
var MOTION_UPDATE_PERIOD = NeuronConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT * CLOCK_TICKS_BEFORE_MOTION_UPDATE;
var VELOCITY_UPDATE_PERIOD = NeuronConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT * CLOCK_TICKS_BEFORE_VELOCITY_UPDATE;
var MIN_VELOCITY = 500; // In nanometers per second of sim time.
var MAX_VELOCITY = 5000; // In nanometers per second of sim time.

Expand All @@ -46,8 +46,8 @@ define( function( require ) {

// Set up random offsets so that all the particles using this motion
// strategy don't all get updated at the same time.
this.motionUpdateCountdownTimer = RAND.nextInt( CLOCK_TICKS_BEFORE_MOTION_UPDATE ) * NeuronSharedConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT;
this.velocityUpdateCountdownTimer = RAND.nextInt( CLOCK_TICKS_BEFORE_VELOCITY_UPDATE ) * NeuronSharedConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT;
this.motionUpdateCountdownTimer = RAND.nextInt( CLOCK_TICKS_BEFORE_MOTION_UPDATE ) * NeuronConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT;
this.velocityUpdateCountdownTimer = RAND.nextInt( CLOCK_TICKS_BEFORE_VELOCITY_UPDATE ) * NeuronConstants.DEFAULT_ACTION_POTENTIAL_CLOCK_DT;

this.velocityX = 0;
this.velocityY = 0;
Expand Down

0 comments on commit 5363cb0

Please sign in to comment.