Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Units calculation error for derived units #62

@iomaganaris

Description

@iomaganaris

When calculating values of derived units from other units when needed to do a calculation like multiplication or division there is an error in the computed values by mod2c and NEURON.
For example for:

UNITS {
	R = 8.313424 (joule/degC)
	J = (R-mole) (1)
	test = (mole) (1)
}

We have with NEURON:

 static double R = 8.313424;
#define J _nrnunit_J[_nrnunit_use_legacy_]
static double _nrnunit_J[2] = {0x1.0912acba81b67p+82, 5.00711e+24}; /* 5.00708642302769403e+24 */
#define test _nrnunit_test[_nrnunit_use_legacy_]
static double _nrnunit_test[2] = {0x1.fe185ca57c517p+78, 6.02217e+23}; /* 6.02214075999999987e+23 */
static int _reset;
static char *modelname = "CaGk";

With mod2c:

double R = 8.313424;
#pragma acc declare copyin(R)
double J = /* 0x1.0912acba81b67p+82; */ 5.00708642302769403e+24;
 #pragma acc declare copyin(J)
double test = /* 0x1.fe185ca57c517p+78; */ 6.02214075999999987e+23;
 #pragma acc declare copyin(test)
static const char *modelname = "CaGk";

With NMODL:

/** constants used in nmodl from UNITS */
    static const double R = 8.313424;
    static const double J = 5.00646095255622339e+24;
    static const double test = 6.02214075999999987e+23;

From the above we see that mole = 6.02214075999999987e+23, R = 8.313424 and if we calculate by hand J = R*mole we have:

>>> 6.02214075999999987e+23 * 8.313424
5.006460952556223e+24

This value is the same with NMODL, however the values in mod2c and NEURON are different

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions