Molarity model ported from Java to JS