BhallaLab / moose-core

C++ basecode and python scripting interface
https://moose.ncbs.res.in
GNU General Public License v3.0
15 stars 28 forks source link

moose.GapJunction not working as expected #487

Closed analkumar2 closed 2 months ago

analkumar2 commented 2 months ago

For some reason moose.GapJunction acts as current source with reversal set at 0 mV. Below is a simple example where two models are connected by GapJunction. These models have Em of -80 mV but the output resting membrane comes out to be 0 mV.

import moose
import numpy as np
import rdesigneur as rd

def makerdes():
    rdes = rd.rdesigneur(
        cellProto = [['somaProto', 'soma', 50e-6, 50e-6]],
        passiveDistrib = [['soma', 'Cm', '120e-12', 'Rm', '150e6', 'Em', '-0.080', 'initVm', '-0.080']],
    )
    return rdes

rdes1 = makerdes()
rdes1.buildModel(modelPath='/model1')
moose.element( '/library' ).name = 'lib1'
rdes2 = makerdes()
rdes2.buildModel(modelPath='/model2')

gj = moose.GapJunction('model1/gj')
gj.Gk = 1e-6
moose.connect(gj, 'channel1', moose.element('model1/elec/soma'), 'channel')
moose.connect(gj, 'channel2', moose.element('model2/elec/soma'), 'channel')

moose.reinit()
moose.start(0.3)

print(moose.element('model1/elec/soma').Em)
print(moose.element('model2/elec/soma').Em)
print(moose.element('model1/elec/soma').Vm)
print(moose.element('model2/elec/soma').Vm)

The output is -0.08 -0.08 -0.00053 -0.00053

The Vm of both the models should be -0.08 V.

analkumar2 commented 2 months ago

The issue was with HSolve and not gapjunction. Have found a workaround that involves deleting the HSolve call in rdesigneur.py and then manually calling HSolve after I have setup the two models.