Skip to content

Instantly share code, notes, and snippets.

@doble-d
Last active January 12, 2021 06:20
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/df8bc7ccbfd311d35228bac004f06bcd to your computer and use it in GitHub Desktop.
Save doble-d/df8bc7ccbfd311d35228bac004f06bcd to your computer and use it in GitHub Desktop.
Nernst equation in dart lang
import 'dart:math' as math;
// Temperature should be in Kelvin
// Valence is just the valence. -1 for Cl- or +1 for Na+
// xOut and xIn are in mM
// Voltage returns as mV
double nernsCalculator(double temperature, double valence, double xOut, double xIn) {
double voltage;
const double faradayConstant = 96485.0;
const double universalGasConstant = 8.314;
voltage = ((universalGasConstant*temperature) / (valence*faradayConstant)) * math.log(xOut / xIn);
return voltage / 1e-3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment