Unit not found: ymol

4 views
Skip to first unread message

Gordon Erlebacher

unread,
Oct 15, 2019, 5:39:06 PM10/15/19
to Brian Development
HI, 

I am trying to use ymol units in Brian2. This unit is officially in the file brian2.units.allunits. Therefore, I expect the following to work: 

from brian2 import *
from brian2.units import *
import brian2.units as un
from brian2.units.constants import * # GE

set_device
('cpp_standalone', directory=None) # Use fast "C++ standalone mode"


################################################################################
# Model parameters
################################################################################
### General parameters
duration
= 4000*msecond # Total simulation time
ssim1
= 50*ymole # (ymole not found)
ssim2
= 50*mmole #  (WORKS)
ssim3
= 50*umole # (WORKS)

ymole, ymol, ymolar, Ymolar are not found. Could you please tell me how to access these units? 

I also looked in the file: allunits.py and found lines such as: 

amole = Unit.create_scaled_unit(mole, "a")
cmole
= Unit.create_scaled_unit(mole, "c")
Zmole = Unit.create_scaled_unit(mole, "Z")
Pmole = Unit.create_scaled_unit(mole, "P")
dmole
= Unit.create_scaled_unit(mole, "d")
Gmole = Unit.create_scaled_unit(mole, "G")
fmole
= Unit.create_scaled_unit(mole, "f")
hmole
= Unit.create_scaled_unit(mole, "h")
damole
= Unit.create_scaled_unit(mole, "da")
mmole
= Unit.create_scaled_unit(mole, "m")
nmole
= Unit.create_scaled_unit(mole, "n")
pmole
= Unit.create_scaled_unit(mole, "p")
umole
= Unit.create_scaled_unit(mole, "u")
Tmole = Unit.create_scaled_unit(mole, "T")
ymole
= Unit.create_scaled_unit(mole, "y")
Emole = Unit.create_scaled_unit(mole, "E")
zmole
= Unit.create_scaled_unit(mole, "z")
Mmole = Unit.create_scaled_unit(mole, "M")
kmole
= Unit.create_scaled_unit(mole, "k")
Ymole = Unit.create_scaled_unit(mole, "Y")
amol
= Unit.create_scaled_unit(mol, "a")
cmol
= Unit.create_scaled_unit(mol, "c")
Zmol = Unit.create_scaled_unit(mol, "Z")
Pmol = Unit.create_scaled_unit(mol, "P")
dmol
= Unit.create_scaled_unit(mol, "d")
Gmol = Unit.create_scaled_unit(mol, "G")
fmol
= Unit.create_scaled_unit(mol, "f")
hmol
= Unit.create_scaled_unit(mol, "h")
damol
= Unit.create_scaled_unit(mol, "da")
mmol
= Unit.create_scaled_unit(mol, "m")
nmol
= Unit.create_scaled_unit(mol, "n")
pmol
= Unit.create_scaled_unit(mol, "p")
umol
= Unit.create_scaled_unit(mol, "u")
Tmol = Unit.create_scaled_unit(mol, "T")
ymol
= Unit.create_scaled_unit(mol, "y")
Emol = Unit.create_scaled_unit(mol, "E")
zmol
= Unit.create_scaled_unit(mol, "z")
Mmol = Unit.create_scaled_unit(mol, "M")
kmol
= Unit.create_scaled_unit(mol, "k")
Ymol = Unit.create_scaled_unit(mol, "Y")


Thanks.

    Gordon

Marcel Stimberg

unread,
Oct 16, 2019, 12:41:41 PM10/16/19
to brian-de...@googlegroups.com
Hi Gordon,

please have a look at
https://brian2.readthedocs.io/en/stable/user/units.html#importing-units

We do generate a larger number of units than what is imported by
default, since most of these units will never be used. By default (i.e.
when doing "from brian2.units import *" or "from brian2 import *"), only
the units mentioned in the first paragraph of
https://brian2.readthedocs.io/en/stable/user/units.html#physical-units
are imported, and this only includes prefixes between pico and Terra –
for anything else you'll have to import it explicitly, i.e. either use

from brian2.units.allunits import ymole

or

from brian2.units.allunits import *

Best,

  Marcel


Gordon Erlebacher

unread,
Oct 16, 2019, 10:16:18 PM10/16/19
to Brian Development

Thank you, Marcel. This makes sense.

   Gordon
Reply all
Reply to author
Forward
0 new messages