View Issue Details

IDProjectCategoryView StatusLast Update
0000960OpenFOAMBugpublic2013-08-14 10:22
Reporterdkxls Assigned Touser2 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinux x86_64OSopenSUSEOS Version12.2
Summary0000960: [ReactingParcel]: Mass losses due to incorrect handeling of parcels below min mass
DescriptionWhen the parcels below minimum threshold are removed from the system, the whole parcel mass (i.e. mass0) has to be added to the carrier phase.
In the current implementation only the mass1 = mass0 - dMassPC is added to the carrier phase. This results in loosing all the evaporated mass (dMassPC).

The bug has been there earlier, but got triggered severely when using this mechanism to remove the critical mass from the liquid phase.

I attached a patch that should fix the bug.
Additional InformationThere also seems to be an unnecessary variable 'dmass', which is just a duplication of 'dMassPC'.
This could be cleaned up at the same time, but is not included in the patch to avoid confusion.
TagsNo tags attached.

Activities

dkxls

2013-08-13 21:50

reporter  

0001-Fix-mass-losses.patch (1,539 bytes)   
From 21afa958a4cbf02f69421a725b2f065b5d05b4da Mon Sep 17 00:00:00 2001
From: Armin Wehrfritz <armin.wehrfritz@aalto.fi>
Date: Tue, 13 Aug 2013 23:25:40 +0300
Subject: [PATCH] Fix mass losses

---
 .../parcels/Templates/ReactingParcel/ReactingParcel.C            |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C
index 29e0940..1e68dc1 100644
--- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C
+++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C
@@ -371,13 +371,13 @@ void Foam::ReactingParcel<ParcelType>::calc
     }
 
     // Remove the particle when mass falls below minimum threshold
-    if (np0*mass1 < td.cloud().constProps().minParticleMass())
+    if (mag(np0*mass1 - td.cloud().constProps().minParticleMass()) < SMALL)
     {
         td.keepParticle = false;
 
         if (td.cloud().solution().coupled())
         {
-            scalar dm = np0*mass1;
+            scalar dm = np0*mass0;
 
             // Absorb parcel into carrier phase
             forAll(Y_, i)
@@ -391,7 +391,7 @@ void Foam::ReactingParcel<ParcelType>::calc
             }
             td.cloud().UTrans()[cellI] += dm*U0;
 
-            td.cloud().phaseChange().addToPhaseChangeMass(dm);
+            td.cloud().phaseChange().addToPhaseChangeMass(np0*mass1);
         }
 
         return;
-- 
1.7.10.4

0001-Fix-mass-losses.patch (1,539 bytes)   

dkxls

2013-08-13 22:10

reporter   ~0002402

It should be mentioned that the mass loss was initially discovered by Kalle!
(http://www.cfd-online.com/Forums/members/kalle.html)

dkxls

2013-08-14 10:13

reporter   ~0002404

Now I would have almost introduced a bug myself. The new if statement only works sufficient when minParticleMass is 1e-15. I uploaded a revised patch (0001-Fix-mass-losses_v1.patch).

dkxls

2013-08-14 10:13

reporter  

0001-Fix-mass-losses_v1.patch (1,196 bytes)   
diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C
index 29e0940..d3dbe8a 100644
--- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C
+++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C
@@ -371,13 +371,13 @@ void Foam::ReactingParcel<ParcelType>::calc
     }
 
     // Remove the particle when mass falls below minimum threshold
-    if (np0*mass1 < td.cloud().constProps().minParticleMass())
+    if ((np0*mass1 - td.cloud().constProps().minParticleMass()) < SMALL)
     {
         td.keepParticle = false;
 
         if (td.cloud().solution().coupled())
         {
-            scalar dm = np0*mass1;
+            scalar dm = np0*mass0;
 
             // Absorb parcel into carrier phase
             forAll(Y_, i)
@@ -391,7 +391,7 @@ void Foam::ReactingParcel<ParcelType>::calc
             }
             td.cloud().UTrans()[cellI] += dm*U0;
 
-            td.cloud().phaseChange().addToPhaseChangeMass(dm);
+            td.cloud().phaseChange().addToPhaseChangeMass(np0*mass1);
         }
 
         return;
0001-Fix-mass-losses_v1.patch (1,196 bytes)   

user2

2013-08-14 10:22

  ~0002405

Thanks for the report - fixed by commit 17a7659

Issue History

Date Modified Username Field Change
2013-08-13 21:49 dkxls New Issue
2013-08-13 21:50 dkxls File Added: 0001-Fix-mass-losses.patch
2013-08-13 22:10 dkxls Note Added: 0002402
2013-08-14 10:13 dkxls Note Added: 0002404
2013-08-14 10:13 dkxls File Added: 0001-Fix-mass-losses_v1.patch
2013-08-14 10:21 user2 Priority immediate => normal
2013-08-14 10:21 user2 Severity crash => major
2013-08-14 10:22 user2 Note Added: 0002405
2013-08-14 10:22 user2 Status new => resolved
2013-08-14 10:22 user2 Fixed in Version => 2.2.x
2013-08-14 10:22 user2 Resolution open => fixed
2013-08-14 10:22 user2 Assigned To => user2