Last active
January 12, 2021 06:20
-
-
Save doble-d/df8bc7ccbfd311d35228bac004f06bcd to your computer and use it in GitHub Desktop.
Nernst equation in dart lang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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