From 6aa27cac6ff6360cb29e1bb56da2aca765bfcb3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Asia=20J=C4=99drzejewska-Szmek?= <asia@in.waw.pl>
Date: Fri, 20 Jan 2017 15:49:32 -0500
Subject: [PATCH] Change order of operations to slightly improve accuracy

---
 moose-core/biophysics/DifBuffer.cpp | 4 ++--
 moose-core/biophysics/DifShell.cpp  | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/moose-core/biophysics/DifBuffer.cpp b/moose-core/biophysics/DifBuffer.cpp
index 666bc8d2..60763e82 100644
--- a/moose-core/biophysics/DifBuffer.cpp
+++ b/moose-core/biophysics/DifBuffer.cpp
@@ -454,14 +454,14 @@ void DifBuffer::vReinit( const Eref& e, ProcPtr p )
 
 void DifBuffer::vFluxFromIn(const Eref& e,double innerC, double innerThickness)
 {
-  double dif = 2 * D_ * innerArea_ / (thickness_ + innerThickness)/ volume_;
+  double dif = 2 * D_  / volume_* innerArea_ / (thickness_ + innerThickness);
   Af_ += dif * innerC;
   Bf_ += dif;
 }
 
 void DifBuffer::vFluxFromOut(const Eref& e,double outerC, double outerThickness)
 {
-  double dif = 2 * D_ * outerArea_ / (thickness_ + outerThickness) / volume_;
+  double dif = 2 * D_  / volume_* outerArea_ / (thickness_ + outerThickness);
   Af_ += dif * outerC;
   Bf_ += dif;
 }
diff --git a/moose-core/biophysics/DifShell.cpp b/moose-core/biophysics/DifShell.cpp
index bc893d76..35368325 100644
--- a/moose-core/biophysics/DifShell.cpp
+++ b/moose-core/biophysics/DifShell.cpp
@@ -371,7 +371,7 @@ void DifShell::vBuffer(const Eref& e,
 
 void DifShell::vFluxFromOut(const Eref& e, double outerC, double outerThickness )
 {
-  double diff =2.*  D_  *  outerArea_ / (outerThickness + thickness_) /volume_;
+  double diff =2.*  D_ /volume_ *  outerArea_ / (outerThickness + thickness_) ;
   //influx from outer shell
   /**
    * We could pre-compute ( D / Volume ), but let us leave the optimizations
@@ -386,8 +386,7 @@ void DifShell::vFluxFromIn(const Eref& e, double innerC, double innerThickness )
 {
   //influx from inner shell
   //double dx = ( innerThickness + thickness_ ) / 2.0;
-  double diff = 2.* D_ * innerArea_ / (innerThickness + thickness_) /volume_;
-  //cout << "FluxFromIn "<<innerC<<" "<<innerThickness;
+  double diff = 2.* D_/volume_ * innerArea_ / (innerThickness + thickness_);
   dCbyDt_ +=  diff *  innerC ;
   Cmultiplier_ += diff ;
 }
-- 
GitLab