A list for the developers of CellML tools

Text archives Help


[cellml-dev] r2392 - in pce/trunk/chrome/content: controls util


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-dev] r2392 - in pce/trunk/chrome/content: controls util
  • Date: Thu, 03 Jul 2008 17:23:46 +1200

Hi,

Some comments inline...

CellML Automated Notifications wrote:
> Author: jmar150
> Date: 2008-07-03 16:48:36 +1200 (Thu, 03 Jul 2008)
> New Revision: 2392
>
> Modified:
> pce/trunk/chrome/content/controls/graph.xml
> pce/trunk/chrome/content/util/GraphSupport.js
> Log:
> Progress towards Tracker Item 405; we can now plot computed constants,
> but can not yet plot precomputed constants.
>
Just a note on terminology: internally in the code, the term computed
constant is used to mean what you are calling precomputed constants,
that is, variables which do not, directly or indirectly, have any
dependence in their equations on any state variables or on time. I
assume when you say computed constants you mean variables which the code
predicts will change throughout the simulation, and so returns a value
for at each time point, but which actually happen to remain constant
(either because an equation could be simplified to remove a dependency
on a state variable / on time, or because the conditions under which a
state variable or time has an effect were never met).
>
> Modified: pce/trunk/chrome/content/controls/graph.xml
> ===================================================================
> --- pce/trunk/chrome/content/controls/graph.xml 2008-07-03 01:08:23
> UTC (rev 2391)
> +++ pce/trunk/chrome/content/controls/graph.xml 2008-07-03 04:48:36
> UTC (rev 2392)
> @@ -1597,10 +1597,24 @@
> </method>
> <method name="computeSpaceTransformation">
> <body>
> + if (this.yMax == this.yMin)
> + {
> + var q = this.yMax > 0 ? 2: -1;
> + var u = this.yMax > 0 ? -1: 2;
> + this.yMax = (q * this.yMax) + 1;
> + this.yMin = (u * this.yMin) - 1;
> + }
>

While the range actually plotted when the true range is zero doesn't
really matter that much, I do find the choice here a bit odd... I would
probably have just gone for something like

var halfrange = Math.abs(this.yMax) * 0.05;
if (halfrange == 0)
halfrange = 0.5;
this.yMin = this.yMax - halfrange;
this.yMax = this.yMax + halfrange;

The reason that this is preferable is that with your code, if this.yMax
(and this.yMin) is something like -1000, you would end up with q=-1,
u=2, yMax=-1 * -1000 + 1 = 1001, yMin = 2 * -1000 - 1 = -2001, which is
a very large range and would make it hard to see the constant value.

With the code I suggested, halfrange = 0.05 * 1000 = 50, and yMin =
-1050, yMax = -9950.

> this.my = (this.cheight - this.graphmargintop -
> this.graphmarginbottom) /
> (this.yMax - this.yMin);
> this.cy = (this.cheight - this.graphmarginbottom) + this.yMin *
> this.my;
> this.my = -this.my;
> + if (this.xMax == this.xMin)
> + {
> + var q = this.xMax > 0 ? 2: -1;
> + var u = this.xMax > 0 ? -1: 2;
> + this.xMax = (q * this.xMax) + 1;
> + this.xMin = (u * this.xMin) - 1;
> + }
>
As for y...

> this.mx = (this.cwidth - this.graphmarginleft -
> this.graphmarginright) /
> (this.xMax - this.xMin);
> this.cx = this.graphmarginleft - this.xMin * this.mx;
>
> Modified: pce/trunk/chrome/content/util/GraphSupport.js
> ===================================================================
> --- pce/trunk/chrome/content/util/GraphSupport.js 2008-07-03 01:08:23
> UTC (rev 2391)
> +++ pce/trunk/chrome/content/util/GraphSupport.js 2008-07-03 04:48:36
> UTC (rev 2392)
> @@ -481,10 +481,10 @@
> {
> if (v.degree != 0)
> return;
> - if (v.type == 0/*VARAIBLE_OF_INTEGRATION*/)
> + if (v.type == 0/*VARIABLE_OF_INTEGRATION*/)
> this.xVariable = 0;
> else if (v.type == 1 /* CONSTANT */)
> - return; // ignore the variable, it doesn't vary.
> + return; //this.xVariable = (-2) - v.assignedIndex; // we must be
> able to plot constants.
> else if (v.type == 2 /* STATE_VARIABLE*/)
> this.xVariable = 1 + v.assignedIndex;
> else
> @@ -495,7 +495,7 @@
> if (v.type == 0/*BOUND*/)
> this.yVariable = 0;
> else if (v.type == 1/* CONSTANT */)
> - return; // ignore the variable, it doesn't vary.
> + return; //this.yVariable = (-2) - v.assignedIndex; // we must be
> able to plot constants.
> else if (v.type == 2 /* STATE_VARIABLE*/)
> this.yVariable = 1 + v.assignedIndex;
> else
> @@ -508,7 +508,7 @@
> {
> if (this.currentModel == null ||
> this.x == null || this.y == null ||
> - this.drawType == 'I' || this.xVariable < 0 ||
> + this.drawType == 'I' || this.xVariable == -1 ||
> this.yVariable < 0)
>
I realise you haven't implemented the code which causes this to matter
yet, but why is x getting treated differently to y here?

> return false;
> return true;
> @@ -999,6 +999,15 @@
>
> spec.dataRange = dataHighest - dataLowest;
>
> + if (spec.dataRange == 0)
> + {
> + var q = dataHighest > 0 ? 2: -1;
> + var u = dataHighest > 0 ? -1: 2;
> + dataHighest = (q * dataHighest) + 1;
> + dataLowest = (u * dataLowest) - 1;
> + spec.dataRange = dataHighest - dataLowest;
> + }
> +
>
As for computeSpaceTransformation.

Other than the above things, it looks good.

Best regards,
Andrew

> var logDataRange;
> var logTickSpacing;
> var includedHalfPowers = 0;
>
> _______________________________________________
> automated-notifications mailing list
> automated-notifications at cellml.org
> http://www.cellml.org/mailman/listinfo/automated-notifications
>




  • [cellml-dev] r2392 - in pce/trunk/chrome/content: controls util, Andrew Miller, 07/03/2008

Archive powered by MHonArc 2.6.18.

Top of page