<commit_before>/*jslint browser: true */
/*global ode: true, graph: true, simcontrols: true, electrophys: true, 
   componentModel: true */

// wait until the document has loaded
window.addEventListener('load', function () {
    'use strict';

    var params, layout, controlsPanel, controls, tMax = 1000e-3, plotHandles = []; 

    // set up the controls for the voltage clamp simulation
    params = { 
        g_leak_uS: { label: 'Leak conductance', units: '\u00B5S', 
            defaultVal: 0.3, minVal: 0.001, maxVal: 100 }, 
        E_leak_mV: { label: 'Leak potential', units: 'mV',
            defaultVal: -54.4, minVal: -1000, maxVal: 1000 }, 
        g_Na_uS: { label: 'Fast transient sodium conductance', 
            units: '\u00B5S', defaultVal: 120, minVal: 0.01, maxVal: 1000 }, 
        E_Na_mV: { label: 'Sodium Nernst potential', units: 'mV',
            defaultVal: 55, minVal: -1000, maxVal: 1000 }, 
        g_K_uS: { label: 'Delayed rectifier potassium conductance', 
            units: '\u00B5S', defaultVal: 36, minVal: 0.01, maxVal: 1000 }, 
        E_K_mV: { label: 'Potassium Nernst potential', units: 'mV',
            defaultVal: -77, minVal: -1000, maxVal: 1000 }, 
        holdingPotential_mV: { label: 'Holding potential', units: 'mV', 
            defaultVal: -70, minVal: -1000, maxVal: 1000 },
        stepPotential_mV: { label: 'First step potential', units: 'mV', 
            defaultVal: 0, minVal: -1000, maxVal: 1000 },
        subsequentStepPotential_mV: { label: 'Subsequent step potential', units: 'mV', 
            defaultVal: 0, minVal: -1000, maxVal: 1000 },
        stepStart_ms: { label: 'Step delay', units: 'ms', 
            defaultVal: 10, minVal: 0, maxVal: tMax / 1e-3 },
        stepWidth_ms: { label: 'Step duration', units: 'ms', 
            defaultVal: 4, minVal: 0, maxVal: tMax / 1e-3 },
        isi_ms: { label: 'Inter-step interval', units: 'ms', 
            defaultVal: 10, minVal: 0, maxVal: tMax / 1e-3 },
        numPulses: { label: 'Number of pulses', units: '', 
            defaultVal: 1, minVal: 0, maxVal: 100 },
        totalDuration_ms: { label: 'Total duration', units: 'ms', 
            defaultVal: 40, minVal: 0, maxVal: tMax / 1e-3 }
    };
    layout = [
        ['Cell Properties', ['g_leak_uS', 'E_leak_mV',
            'g_Na_uS', 'E_Na_mV', 'g_K_uS', 'E_K_mV']],
        ['Voltage Clamp', ['holdingPotential_mV', 'stepPotential_mV',
            'subsequentStepPotential_mV', 'stepStart_ms', 'stepWidth_ms',
            'isi_ms', 'numPulses']],
        ['Simulation Settings', ['totalDuration_ms']]
    ];
    controlsPanel = document.getElementById('VoltageClampControls');

    // simulate and plot an hh neuron with a pulse
    function runSimulation() {
        var model, neuron, pulseTrain, hhNaCurrent, hhKCurrent, leakCurrent,
            result, v, gNa, gK, iNa, iK, iLeak, mGate, hGate, nGate,
            v_mV, gNa_uS, gK_uS, iNa_nA, iK_nA, iLeak_nA, params,
            plotPanel, plot, plotDefaultOptions, j, prerun, y0; 
        
        // create the clamped membrane
        params = controls.values;
        model = componentModel.componentModel();

        pulseTrain = electrophys.pulseTrain({
            start: params.stepStart_ms * 1e-3, 
            width: params.stepWidth_ms * 1e-3, 
            baseline: params.holdingPotential_mV * 1e-3,
            height: (params.stepPotential_mV - params.holdingPotential_mV) * 1e-3,
            subsequentHeight: params.subsequentStepPotential_mV * 1e-3,
            gap: params.isi_ms * 1e-3,
            num_pulses: params.numPulses
        });<commit_msg>Fix for subsequent step potentials in simple_voltageclamp<commit_after>/*jslint browser: true */
/*global ode: true, graph: true, simcontrols: true, electrophys: true, 
   componentModel: true */

// wait until the document has loaded
window.addEventListener('load', function () {
    'use strict';

    var params, layout, controlsPanel, controls, tMax = 1000e-3, plotHandles = []; 

    // set up the controls for the voltage clamp simulation
    params = { 
        g_leak_uS: { label: 'Leak conductance', units: '\u00B5S', 
            defaultVal: 0.3, minVal: 0.001, maxVal: 100 }, 
        E_leak_mV: { label: 'Leak potential', units: 'mV',
            defaultVal: -54.4, minVal: -1000, maxVal: 1000 }, 
        g_Na_uS: { label: 'Fast transient sodium conductance', 
            units: '\u00B5S', defaultVal: 120, minVal: 0.01, maxVal: 1000 }, 
        E_Na_mV: { label: 'Sodium Nernst potential', units: 'mV',
            defaultVal: 55, minVal: -1000, maxVal: 1000 }, 
        g_K_uS: { label: 'Delayed rectifier potassium conductance', 
            units: '\u00B5S', defaultVal: 36, minVal: 0.01, maxVal: 1000 }, 
        E_K_mV: { label: 'Potassium Nernst potential', units: 'mV',
            defaultVal: -77, minVal: -1000, maxVal: 1000 }, 
        holdingPotential_mV: { label: 'Holding potential', units: 'mV', 
            defaultVal: -70, minVal: -1000, maxVal: 1000 },
        stepPotential_mV: { label: 'First step potential', units: 'mV', 
            defaultVal: 0, minVal: -1000, maxVal: 1000 },
        subsequentStepPotential_mV: { label: 'Subsequent step potential', units: 'mV', 
            defaultVal: 0, minVal: -1000, maxVal: 1000 },
        stepStart_ms: { label: 'Step delay', units: 'ms', 
            defaultVal: 10, minVal: 0, maxVal: tMax / 1e-3 },
        stepWidth_ms: { label: 'Step duration', units: 'ms', 
            defaultVal: 4, minVal: 0, maxVal: tMax / 1e-3 },
        isi_ms: { label: 'Inter-step interval', units: 'ms', 
            defaultVal: 10, minVal: 0, maxVal: tMax / 1e-3 },
        numPulses: { label: 'Number of pulses', units: '', 
            defaultVal: 1, minVal: 0, maxVal: 100 },
        totalDuration_ms: { label: 'Total duration', units: 'ms', 
            defaultVal: 40, minVal: 0, maxVal: tMax / 1e-3 }
    };
    layout = [
        ['Cell Properties', ['g_leak_uS', 'E_leak_mV',
            'g_Na_uS', 'E_Na_mV', 'g_K_uS', 'E_K_mV']],
        ['Voltage Clamp', ['holdingPotential_mV', 'stepPotential_mV',
            'subsequentStepPotential_mV', 'stepStart_ms', 'stepWidth_ms',
            'isi_ms', 'numPulses']],
        ['Simulation Settings', ['totalDuration_ms']]
    ];
    controlsPanel = document.getElementById('VoltageClampControls');

    // simulate and plot an hh neuron with a pulse
    function runSimulation() {
        var model, neuron, pulseTrain, hhNaCurrent, hhKCurrent, leakCurrent,
            result, v, gNa, gK, iNa, iK, iLeak, mGate, hGate, nGate,
            v_mV, gNa_uS, gK_uS, iNa_nA, iK_nA, iLeak_nA, params,
            plotPanel, plot, plotDefaultOptions, j, prerun, y0; 
        
        // create the clamped membrane
        params = controls.values;
        model = componentModel.componentModel();

        pulseTrain = electrophys.pulseTrain({
            start: params.stepStart_ms * 1e-3, 
            width: params.stepWidth_ms * 1e-3, 
            baseline: params.holdingPotential_mV * 1e-3,
            height: (params.stepPotential_mV - params.holdingPotential_mV) * 1e-3,
            subsequentHeight: (params.subsequentStepPotential_mV - params.holdingPotential_mV) * 1e-3,
            gap: params.isi_ms * 1e-3,
            num_pulses: params.numPulses
        });
{'fraction_non_alphanumeric': 0.13053613053613053, 'fraction_numerical': 0.03784450843274373, 'mean_word_length': 2.5356277266117306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5514199', 'n_tokens_mistral': 2738, 'n_tokens_neox': 2338, 'n_words': 641}