Skip to content

Instantly share code, notes, and snippets.

@doble-d
Created January 13, 2021 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doble-d/c51dcbecc586f469d3e47cd936dad7fd to your computer and use it in GitHub Desktop.
Save doble-d/c51dcbecc586f469d3e47cd936dad7fd to your computer and use it in GitHub Desktop.
Goldman-Hodgkin-Katz equation in dart lang.
import 'dart:math' as math;
// Temperatures should be in Kelvin
// pK, pNa, and pCl refer to the permeability. (e.g. If the channels for Na are closed, Na permeability is 0 (zero))
// Everything In or Out is in mM
// Membrane potential (voltage) is returned as mV
double ghkCalculator(double temperature,
double pK, double pNa, double pCl,
double kIn, double kOut,
double naIn, double naOut,
double clIn, double clOut) {
const double universalGasConstant = 8.314;
const double faradayConstant = 96485.0;
double voltage;
voltage = ((universalGasConstant * temperature) / faradayConstant) * math.log(((pK*kOut) + (pNa*naOut) + (pCl*clIn)) / ((pK*kIn) + (pNa*naIn) + (pCl*clOut)));
return voltage / 1e-3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment