Skip to content

Commit

Permalink
Add tests (#5)
Browse files Browse the repository at this point in the history
Authored-by: AndreaQuerio <andrea.querio96@gmail.com>
Authored-by: AndreaQuerio <82167142+AndreaQuerio@users.noreply.github.com>
  • Loading branch information
AndreaQuerio authored Jan 27, 2023
1 parent 3aec036 commit a30c4eb
Show file tree
Hide file tree
Showing 193 changed files with 7,997,339 additions and 736 deletions.
4 changes: 1 addition & 3 deletions examples/cfd_pbe_precNMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ def main(argv):
session.run()

pretty_print(wrapper.get(oclass=wet_synthesis.SizeDistribution)[0])

plot_size_dist(
wrapper.get(oclass=wet_synthesis.SizeDistribution)[0])
plot_size_dist(wrapper.get(oclass=wet_synthesis.SizeDistribution)[0])

except Exception as e:
print(e)
Expand Down
8 changes: 7 additions & 1 deletion examples/compartment_precNMC.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Example to use CFD-PBE wrapper
# Example to use compartment wrapper
import sys
import traceback
import argparse
Expand Down Expand Up @@ -101,15 +101,21 @@ def main(argv):

Cuds2dot(wrapper).render()

sizeDistribution = wet_synthesis.SizeDistribution()
wrapper.add(sizeDistribution)
compartmentNetwork = wet_synthesis.CompartmentNetwork()
wrapper.add(compartmentNetwork)

pretty_print(wrapper.get(oclass=wet_synthesis.SizeDistribution)[0])
pretty_print(wrapper.get(oclass=wet_synthesis.CompartmentNetwork)[0])

try:
# run the session
session.run()

pretty_print(wrapper.get(oclass=wet_synthesis.SizeDistribution)[0])
plot_size_dist(wrapper.get(oclass=wet_synthesis.SizeDistribution)[0])

pretty_print(wrapper.get(oclass=wet_synthesis.CompartmentNetwork)[0])

except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion osp/wrappers/wet_synthesis_wrappers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .cfd_pbe_session import CfdPbeSession
from .compartment_session import CompartmentSession
from .compartment_session import CompartmentSession
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ fi

if [ $1 -eq 1 ]; then
echo "Running $application on $PWD"
./runApp $1 > log.txt
./runApp $1 > log_cfd.txt
cp system/updatingFiles/controlDict.1 system/controlDict
cp system/updatingFiles/fvSolution.1 system/fvSolution
cp system/updatingFiles/fvSchemes.mix system/fvSchemes
cp 0.bkp/p_env* 60/
./runApp $1 > log_mixing.txt
else
m4 -D NUM=$1 < system/decomposeParDict.m4 > system/decomposeParDict

Expand All @@ -39,7 +44,29 @@ else
fi

echo "Running $application in parallel on $PWD using $1 processes"
mpirun -np $1 --output-filename log ./runApp $1 # > /dev/null 2>&1
mpirun -np $1 --output-filename log_cfd ./runApp $1 > /dev/null 2>&1
cp system/updatingFiles/controlDict.1 system/controlDict
cp system/updatingFiles/fvSolution.1 system/fvSolution
cp system/updatingFiles/fvSchemes.mix system/fvSchemes

if [ $? -eq 0 ]; then
./reconstruct

if [ $? -eq 0 ]; then
rm -rf processor*
fi
fi

cp 0.bkp/p_env* 60/

./decompose

ERROR_CODE=$?
if [ $ERROR_CODE -ne 0 ]; then
exit $ERROR_CODE
fi

mpirun -np $1 --output-filename log_mixing ./runApp $1 > /dev/null 2>&1

if [ $? -eq 0 ]; then
./reconstruct
Expand All @@ -49,3 +76,5 @@ else
fi
fi
fi

postProcess -func writeCellVolumes -latestTime
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ FoamFile

#include "$FOAM_CASE/include/input"

application simpleEnvMixing;
application pisoFoam;

startFrom latestTime;

startTime 0;

stopAt endTime;

endTime $end_time;
endTime $t2;

deltaT 1e-4;

Expand Down Expand Up @@ -79,29 +79,29 @@ functions
// );
// }

timeStepUpdate
{
type timeActivatedFileUpdate;
libs ("libutilityFunctionObjects.so");
fileToUpdate "$FOAM_CASE/system/controlDict";
timeVsFile
(
(-1 "$FOAM_CASE/system/updatingFiles/controlDict.0")
($t2 "$FOAM_CASE/system/updatingFiles/controlDict.1")
);
}
// timeStepUpdate
// {
// type timeActivatedFileUpdate;
// libs ("libutilityFunctionObjects.so");
// fileToUpdate "$FOAM_CASE/system/controlDict";
// timeVsFile
// (
// (-1 "$FOAM_CASE/system/updatingFiles/controlDict.0")
// ($t2 "$FOAM_CASE/system/updatingFiles/controlDict.1")
// );
// }

fvSolutionUpdate
{
type timeActivatedFileUpdate;
libs ("libutilityFunctionObjects.so");
fileToUpdate "$FOAM_CASE/constant/odeSolver";
timeVsFile
(
(-1 "$FOAM_CASE/constant/updatingFiles/fvSolution.0") // 1e-6
($t2 "$FOAM_CASE/constant/updatingFiles/fvSolution.1") // 5e-6
);
}
// fvSolutionUpdate
// {
// type timeActivatedFileUpdate;
// libs ("libutilityFunctionObjects.so");
// fileToUpdate "$FOAM_CASE/constant/odeSolver";
// timeVsFile
// (
// (-1 "$FOAM_CASE/constant/updatingFiles/fvSolution.0") // 1e-6
// ($t2 "$FOAM_CASE/constant/updatingFiles/fvSolution.1") // 5e-6
// );
// }

schemeChange
{
Expand All @@ -113,7 +113,7 @@ functions
(-1 "$FOAM_CASE/system/updatingFiles/fvSchemes.0")
($t0 "$FOAM_CASE/system/updatingFiles/fvSchemes.1")
($t1 "$FOAM_CASE/system/updatingFiles/fvSchemes.2")
($t3 "$FOAM_CASE/system/updatingFiles/fvSchemes.3")
// ($t3 "$FOAM_CASE/system/updatingFiles/fvSchemes.3")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FoamFile

ddtSchemes
{
default steadyState;
default Euler;
}

gradSchemes
Expand All @@ -27,7 +27,6 @@ gradSchemes
grad(U) Gauss linear;
grad(k) Gauss linear;
grad(epsilon) Gauss linear;
"grad\(p_env[1-3]\)" Gauss linear;
}

divSchemes
Expand All @@ -38,8 +37,6 @@ divSchemes
div(phi,k) Gauss upwind; // vanLeer
div(phi,epsilon) Gauss upwind; // vanLeer

"div\(phi,p_env[1-3]\)" Gauss upwind;

div((nuEff*dev2(T(grad(U))))) Gauss linear;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ solvers
nCellsInCoarsestLevel 500;
}

pFinal
{
$p;
// tolerance 1e-08;
// relTol 0;
}

"(U|k|epsilon|omega)"
{
solver smoothSolver;
Expand All @@ -34,41 +41,21 @@ solvers
tolerance 1e-07;
relTol 0.01;
}

"p_env[1-3]"
{
solver GAMG;
smoother GaussSeidel;
tolerance 1e-8; // 1e-6 (last attempt to do)
relTol 0.0; // check it for steady-state solver
nCellsInCoarsestLevel 500;
minIter 1;
// solver smoothSolver;
// smoother symGaussSeidel;
// tolerance 1e-10;
// relTol 0;
// minIter 1;
}
}


SIMPLE
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 2;
consistent no;

// pRefPoint (0.05 0.05 0.149);
// pRefValue 0;

CFD true;
micromixing false;
pRefCell 0;
pRefValue 0;

residualControl
{
// p 1e-6;
// U 1e-6;
// "(k|epsilon|omega)" 1e-6;
"p_env[1-3]" 1e-15;
p 1e-6;
U 1e-6;
"(k|epsilon|omega)" 1e-6;
}
}

Expand All @@ -83,8 +70,6 @@ relaxationFactors
U 0.5; // 0.9 is more stable but 0.95 more convergent
k 0.5;
epsilon 0.5;

"p_env[1-3]" 0.3;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,29 @@ functions
// );
// }

timeStepUpdate
{
type timeActivatedFileUpdate;
libs ("libutilityFunctionObjects.so");
fileToUpdate "$FOAM_CASE/system/controlDict";
timeVsFile
(
(-1 "$FOAM_CASE/system/updatingFiles/controlDict.0")
($t2 "$FOAM_CASE/system/updatingFiles/controlDict.1")
);
}
// timeStepUpdate
// {
// type timeActivatedFileUpdate;
// libs ("libutilityFunctionObjects.so");
// fileToUpdate "$FOAM_CASE/system/controlDict";
// timeVsFile
// (
// (-1 "$FOAM_CASE/system/updatingFiles/controlDict.0")
// ($t2 "$FOAM_CASE/system/updatingFiles/controlDict.1")
// );
// }

fvSolutionUpdate
{
type timeActivatedFileUpdate;
libs ("libutilityFunctionObjects.so");
fileToUpdate "$FOAM_CASE/constant/odeSolver";
timeVsFile
(
(-1 "$FOAM_CASE/constant/updatingFiles/fvSolution.0") // 1e-6
($t2 "$FOAM_CASE/constant/updatingFiles/fvSolution.1") // 5e-6
);
}
// fvSolutionUpdate
// {
// type timeActivatedFileUpdate;
// libs ("libutilityFunctionObjects.so");
// fileToUpdate "$FOAM_CASE/constant/odeSolver";
// timeVsFile
// (
// (-1 "$FOAM_CASE/constant/updatingFiles/fvSolution.0") // 1e-6
// ($t2 "$FOAM_CASE/constant/updatingFiles/fvSolution.1") // 5e-6
// );
// }

schemeChange
{
Expand All @@ -104,9 +104,9 @@ functions
fileToUpdate "$FOAM_CASE/system/fvSchemes";
timeVsFile
(
(-1 "$FOAM_CASE/system/updatingFiles/fvSchemes.0")
($t0 "$FOAM_CASE/system/updatingFiles/fvSchemes.1")
($t1 "$FOAM_CASE/system/updatingFiles/fvSchemes.2")
// (-1 "$FOAM_CASE/system/updatingFiles/fvSchemes.0")
// ($t0 "$FOAM_CASE/system/updatingFiles/fvSchemes.1")
(-1 "$FOAM_CASE/system/updatingFiles/fvSchemes.mix")
($t3 "$FOAM_CASE/system/updatingFiles/fvSchemes.3")
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FoamFile

ddtSchemes
{
default steadyState;
default Euler;
}

gradSchemes
Expand All @@ -27,7 +27,6 @@ gradSchemes
grad(U) Gauss linear;
grad(k) Gauss linear;
grad(epsilon) Gauss linear;
"grad\(p_env[1-3]\)" Gauss linear;
}

divSchemes
Expand All @@ -38,8 +37,6 @@ divSchemes
div(phi,k) Gauss upwind; // vanLeer
div(phi,epsilon) Gauss upwind; // vanLeer

"div\(phi,p_env[1-3]\)" Gauss upwind;

div((nuEff*dev2(T(grad(U))))) Gauss linear;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FoamFile

ddtSchemes
{
default steadyState;
default Euler;
}

gradSchemes
Expand All @@ -27,7 +27,6 @@ gradSchemes
grad(U) Gauss linear;
grad(k) Gauss linear;
grad(epsilon) Gauss linear;
"grad\(p_env[1-3]\)" Gauss linear;
}

divSchemes
Expand All @@ -38,8 +37,6 @@ divSchemes
div(phi,k) Gauss vanLeer; // vanLeer
div(phi,epsilon) Gauss vanLeer; // vanLeer

"div\(phi,p_env[1-3]\)" Gauss upwind;

div((nuEff*dev2(T(grad(U))))) Gauss linear;
}

Expand Down
Loading

0 comments on commit a30c4eb

Please sign in to comment.