nest / nestml

A domain specific language for neuron and synapse models in spiking neural network simulation
GNU General Public License v2.0
46 stars 45 forks source link

the power function with variable parameter #948

Closed max-talanov closed 11 months ago

max-talanov commented 1 year ago

Dear developers. I try to extend nest with the muscle model. https://github.com/max-talanov/bypass/blob/main/muscle/nestmlmodule/hh_moto_5ht_muscle.nestml The problem is in the update block At = AM**alpha If I use alpha as the power function parameter the compilation crashes with following error message (the tail): File "/home/max/.local/lib/python3.10/site-packages/NESTML-5.3.0.post0.dev0-py3.10.egg/pynestml/visitors/ast_power_visitor.py", line 59, in try_to_calculate_resulting_unit exponent_numeric_value_either = self.calculate_numeric_value(expr.get_rhs()) File "/home/max/.local/lib/python3.10/site-packages/NESTML-5.3.0.post0.dev0-py3.10.egg/pynestml/visitors/ast_power_visitor.py", line 84, in calculate_numeric_value elif expr.is_unary_operator() and expr.get_unary_operator().is_unary_minus: AttributeError: 'ASTSimpleExpression' object has no attribute 'is_unary_operator' If i change it to value 2 the compilation goes successfully.

Could you please fix this? Thank you so much in advance.

pnbabu commented 1 year ago

@max-talanov thanks for writing in. I tried to generate code for your model locally and couldn't see any errors. I see that you have installed NESTML from the source (NESTML-5.3.0.post0.dev0). Could you tell us which commit you are at? Note that I tried your model with the commit 092f5faaf23fc0a8a6d38bb4b316b3d9a4fe9e82.

max-talanov commented 1 year ago

Thank you so much for dealing with this issue. I tried to generate code for your model locally and couldn't see any errors. This is because I have used work around in line 248: At = AMalpha -> At = AM2 I can commit the code restoring the error.

I see that you have installed NESTML from the source (NESTML-5.3.0.post0.dev0). Could you tell us which commit you are at? I'm on c0b21ead - add Izhikevich model to STDP window test (#937)

And the other issue is the performance, even if I use several workarounds to avoid compilation errors the simulation of one fibre takes several hours, I guess it is not normal, as in NEURON it takes several seconds. Should I create the separate issue regarding permanence?

Thank you so much in advance.

pnbabu commented 1 year ago

@max-talanov thanks for reporting this. I have now fixed this in the PR #950. Could you pull this to test if the changes work on your side?

Please note that this is developed on the latest NESTML master which has a new change where we have removed units from the spiking input ports. The input block would now look like:

input:
    inh_spikes <- inhibitory spike
        exc_spikes <- excitatory spike
        I_stim pA <- continuous

The corresponding units should be multiplied in the equations accordingly where the input ports are used. Please see here: https://nestml.readthedocs.io/en/latest/nestml_language/neurons_in_nestml.html#input

You would have to make the above changes as well for your model to work with the fix for the power operator.

And the other issue is the performance, even if I use several workarounds to avoid compilation errors the simulation of one fibre takes several hours, I guess it is not normal, as in NEURON it takes several seconds. Should I create the separate issue regarding permanence?

Could you please elaborate on this? Are you generating the NESTML code for every run of your simulation? An example script with the problem would be helpful here.

max-talanov commented 1 year ago

@pnbabu please see the file, line 28: https://github.com/max-talanov/bypass/blob/main/nestML/muscle/nestmlmodule/hh_moto_5ht_muscle.nestml#L248

Thank you for the reference, I'll correct the code when I'll migrate to the new commit.

And the other issue is the performance, even if I use several workarounds to avoid compilation errors the simulation of one fibre takes several hours, I guess it is not normal, as in NEURON it takes several seconds. Should I create the separate issue regarding permanence?

Could you please elaborate on this? Are you generating the NESTML code for every run of your simulation? An example script with the problem would be helpful here.

Please see the file: https://github.com/max-talanov/bypass/blob/main/nestML/muscle/iclamp_sim.py in line 14th https://github.com/max-talanov/bypass/blob/main/nestML/muscle/iclamp_sim.py#L14 I generate the nest target flies and install them in line 15 and later I try to use generated muscle model in the neurosimulation: https://github.com/max-talanov/bypass/blob/main/nestML/muscle/iclamp_sim.py#L113

Unfortunately the computation of one muscle fiber takes more than 24 hours on local machine with 32G and intel Core i7, this seems to bee a bit too long, taking into account that the implementation of the same model in NEURON takes 10 minutes to be calculated on the same machine. Thank you so much in advance.

clinssen commented 11 months ago

If this is indeed fixed in #950, I will close this issue. We will address benchmarking and performance issues in #859. Cheers!