First let me thank you for using NEURON in your work, and also for asking an excellent question.
We tried to collect all the membrane currents . . . [but] the momentary sum of the currents was not zero
This statement raises several interesting issues about conservation of charge and current.
To start with, NEURON handles conservation of charge and current correctly, regardless of what some careless reader might infer from statements like this
We consulted with the LFPy guys, and they figured out, that if the synapses are located at the initial (0) or end (1) points of any segments than the zero sum stands, but if the alpha synapses are not located on either of the the ends of the segment, than the sum of all currents does not give zero, however they should.
I'm sure you will agree that if axial current is nonzero anywhere in a cell, then somewhere in that cell the net membrane current will be nonzero, at least for a while. And it follows that this is also true if a cell's membrane potential is nonuniform; actually it's true from the very instant at which membrane potential starts to deviate from being uniform over the surface of a cell.
Does "collect all the membrane currents" mean that you integrated all membrane currents over the entire surface of your model cell? Because that would be necessary to check for conservation of charge (and conservation of charge is what we're discussing).
Also, you had to deal with the fact that currents generated by point processes (synaptic currents, currents injected by electrodes) are in nA (nanoamps), but membrane capacitive current and currents generated by "density mechanisms" (like the fast sodium and delayed rectifier potassium currents, H current, voltage- or ligand-gated Ca currents) are in mA/cm2. And you had to deal with the fact that NEURON's sign convention for point processes is that synaptic currents that depolarize a cell are negative, but electrode currents (currents generated by an IClamp or SEClamp) that depolarize a cell are positive.
And you had to decide what to do about the currents generated by point processes attached to "zero area nodes" (the 0 and 1 ends of sections). If no other section is attached to the same location, just add the point process's current to the sum of currents of the segment at the 0 or 1 end (and remember to scale for units: multiply nA by 100 and divide by the segment's area in square microns, and the result is the numerical value of the current in mA/cm2). If you're dealing with a current source that is attached to the junction between two or more sections, and you are particularly interested in the extracellular potential in the vicinity of this junction, you might want to apportion the current among them according to some rule that you'll have to be ready to explain to reviewers. I'd be tempted to take a "current divider" approach based on the input impedances of the joined sections.
Here is a possible problem you may not have considered: when NEURON advances a simulation from t to t+dt using its fixed time step methods, it starts by making sure that the currents and other assigned variables (conductances etc.) are consistent with the state variables (including v) at time t, then calculates what the state variables should be at t + dt -- good so far -- but then TO SAVE TIME it doesn't update the assigned variables (conductances, currents etc.) to be consistent with the new state variables. Consequently the assigned variables are always "a bit behind" and if you try to calculate the net current at the new t, you'll be using the old conductances with the new membrane potentials, and the currents won't add up to 0. You COULD eliminate this problem by executing fcurrent() (h.fcurrent() if you're using Python); read about h.fcurrent() here
https://nrn.readthedocs.io/en/latest/py ... l#fcurrent). Or you could eliminate the problem by using any of NEURON's adaptive integrators, because the states and assigned variables are consistent after each step of adaptive integration.
I have created a toy model that illustrates many of these points (a single compartment model cell with two AlphaSynapses--one attached to the 0 end and one attached to the 0.5 location of the soma--plus some informative graphs and a simple user interface for interactive usage) and demonstrates that NEURON handles conservation of charge correctly. I'll make it available online with a bit of documentation later today.