Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions bird/preprocess/dynamic_mixer/io_fvModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,34 @@ def write_preamble(output_folder):
f.write("\t\tconst volVectorField& UL =\n")
f.write('\t\t\tmesh().lookupObject<volVectorField>("U.liquid");\n')
f.write("\t\tdouble pi=3.141592654;\n")
f.write(f"\t\tdouble source_pt_x;\n")
f.write(f"\t\tdouble source_pt_y;\n")
f.write(f"\t\tdouble source_pt_z;\n")
f.write(f"\t\tdouble disk_rad;\n")
f.write("\t\tdouble disk_area;\n")
f.write(f"\t\tdouble power;\n")
f.write(f"\t\tdouble smear_factor;\n")
f.write(f"\t\tdouble startTime;\n")


def write_mixer(mixer, output_folder):
with open(os.path.join(output_folder, "fvModels"), "a+") as f:
f.write(f"\t\tdouble source_pt_x={mixer.x};\n")
f.write(f"\t\tdouble source_pt_y={mixer.y};\n")
f.write(f"\t\tdouble source_pt_z={mixer.z};\n")
f.write(f"\t\tdouble disk_rad={mixer.rad};\n")
f.write("\t\tdouble disk_area=pi*disk_rad*disk_rad;\n")
f.write(f"\t\tdouble power={mixer.power};\n")
f.write(f"\t\tdouble smear_factor={float(mixer.smear)};\n")
f.write(f"\t\tconst scalar startTime = {mixer.start_time};\n")
f.write(f"\t\tsource_pt_x={mixer.x};\n")
f.write(f"\t\tsource_pt_y={mixer.y};\n")
f.write(f"\t\tsource_pt_z={mixer.z};\n")
f.write(f"\t\tdisk_rad={mixer.rad};\n")
f.write("\t\tdisk_area=pi*disk_rad*disk_rad;\n")
f.write(f"\t\tpower={mixer.power};\n")
f.write(f"\t\tsmear_factor={float(mixer.smear)};\n")
f.write(f"\t\tstartTime = {mixer.start_time};\n")
f.write("\t\tif (time.value() > startTime)\n")
f.write("\t\t{\n")
f.write("\t\t\t// Get V1\n")
f.write("\t\t\tdouble source_sign_factor = 1.0;\n")
f.write("\t\t\tdouble V1 = 0;\n")
f.write("\t\t\tdouble V2 = 0;\n")
f.write("\t\t\tdouble rhoV;\n")
f.write("\t\t\tdouble dist_tol = disk_rad*5;\n")
f.write("\t\t\tdouble dist_tol = disk_rad*3;\n")
f.write("\n")
f.write("\t\t\tdouble dist_n;\n")
f.write("\t\t\tdouble upV = 0;\n")
Expand Down
12 changes: 9 additions & 3 deletions bird/preprocess/dynamic_mixer/mixing_fvModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def check_input(input_dict):
return mix_type


def write_fvModel(input_dict, output_folder="."):
def write_fvModel(input_dict, output_folder=".", force_sign=False):
mix_type = check_input(input_dict)
write_preamble(output_folder)
if "loop" in mix_type:
Expand All @@ -39,13 +39,19 @@ def write_fvModel(input_dict, output_folder="."):
if mtype == "expl":
mixer.update_from_expl_dict(input_dict["mixers"][imix])
if mixer.ready:
write_mixer(mixer, output_folder)
if force_sign:
write_mixer_force_sign(mixer, output_folder)
else:
write_mixer(mixer, output_folder)
elif mtype == "loop":
mixer.update_from_loop_dict(
input_dict["mixers"][imix], geom_dict, mesh_dict
)
if mixer.ready:
write_mixer(mixer, output_folder)
if force_sign:
write_mixer_force_sign(mixer, output_folder)
else:
write_mixer(mixer, output_folder)

write_end(output_folder)

Expand Down
2 changes: 1 addition & 1 deletion bird/preprocess/stl_patch/stl_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def check_input(input_dict):
assert isinstance(input_dict, dict)
need_geom = False
for bound in input_dict:
if not bound == "Geometry":
if not bound == "Geometry" and not bound == "Meshing":
assert isinstance(input_dict[bound], list)
for patch in input_dict[bound]:
assert isinstance(patch, dict)
Expand Down
5 changes: 4 additions & 1 deletion bird/utilities/ofio.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,16 @@ def readSizeGroups(file):
return sizeGroup, binGroup


def getCaseTimes(casePath):
def getCaseTimes(casePath, remove_zero=False):
# Read Time
times_tmp = os.listdir(casePath)
# remove non floats
for i, entry in reversed(list(enumerate(times_tmp))):
try:
a = float(entry)
if remove_zero:
if abs(a) < 1e-12:
_ = times_tmp.pop(i)
except ValueError:
print(f"{entry} not a time folder, removing")
a = times_tmp.pop(i)
Expand Down
2 changes: 1 addition & 1 deletion bird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Bio reactor design version"""

__version__ = "0.0.18"
__version__ = "0.0.19"
3 changes: 3 additions & 0 deletions docs/source/airlift.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Initial conditions
Setup the bubble model
------------

Turbulence model
------------

Run the solver
------------

Expand Down
14 changes: 11 additions & 3 deletions docs/source/bubbleColumn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This command generates the appropriate ``blockMeshDict``

Block geometry
~~~~~~~~~~~
BiRD uses a block cyclindral geometry description (:ref:`Block cylindrical meshing<block_cyl>`). The block description of the geometry is in ``${BCE_CASE}/system/mesh.json`` under the ``Geometry`` key
BiRD uses a block cylindral geometry description (:ref:`Block cylindrical meshing<block_cyl>`). The block description of the geometry is in ``${BCE_CASE}/system/mesh.json`` under the ``Geometry`` key

.. code-block:: json

Expand Down Expand Up @@ -67,7 +67,7 @@ Those numbers describes the coordinates of the cylindrical blocks. Using the blo

Note that the first radial number ``column_trans`` is special and results in 2 radial blocks. The first radial block is the square of the pillow-mesh where the edge is half of the first coordinate :math:`(275/2=137.5)`. The second radial block is the outer-shell of the pillow.

By default, the coordinates of the block cyclindrical geometry are in meters. In this case, the intention was to indicate milimeters instead. This will be handled during the :ref:`Mesh post-treatment<posttreat_bce>` below.
By default, the coordinates of the block cylindrical geometry are in meters. In this case, the intention was to indicate millimeters instead. This will be handled during the :ref:`Mesh post-treatment<posttreat_bce>` below.

Each one of the cylindrical blocks will be meshed because we are constructing a bubble column. So there is no need for defining one of the blocks as a wall (conversely to the example shown in :ref:`Block cylindrical meshing<block_cyl>`).

Expand Down Expand Up @@ -184,7 +184,7 @@ Inlet patch
------------

BiRD allows for the generation of complex patches through the generation of ``.stl`` files that describe the patch geometry.
Note that we could have generated the outlet patch with another stl file (we do it in the case of the loop reactor tutorial). Here, since the outlet can be simply defined as an entire block cyclindrical face, we prefer to define it that way. In the case of the inlet, only part of a block cyclindrical face is the inlet, and it is more convenient to use the ``.stl`` approach.
Note that we could have generated the outlet patch with another stl file (we do it in the case of the loop reactor tutorial). Here, since the outlet can be simply defined as an entire block cylindrical face, we prefer to define it that way. In the case of the inlet, only part of a block cylindrical face is the inlet, and it is more convenient to use the ``.stl`` approach.

Here, we would like to create a circular sparger centered on :math:`(x,y,z)=(0,0,0)`, and of radius :math:`0.2` m, with a normal face along the :math:`y`-direction
Recall that we scaled our mesh so the outer radius of the column is now :math:`0.360` m, and not :math:`360` m.
Expand Down Expand Up @@ -320,6 +320,14 @@ For example, one choose to use the constant diameter model and do
cd ${BCE_CASE}
cp constant/phaseProperties_constantd constant/phaseProperties

Turbulence model
------------

The turbulence model is set as :math:`k-\varepsilon` in the gas phase and the liquid phase. The turbulence model can be activated through ``${BCE_CASE}/constant/momentumTransport.gas`` for the gas phase and ``${BCE_CASE}/constant/momentumTransport.liquid`` for the liquid phase.

The boundary conditions for the turbulence model are set in ``0.orig/k.*``, ``0.orig/epsilon.*``, ``0.orig/nut.*``. The inlet boundary values are calculated from freestream turbulence correlations shown in ``constant/globalVars``. For example, ``k_inlet_liq #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)";``.


Run the solver
------------
The solver can be run by executing
Expand Down
3 changes: 3 additions & 0 deletions docs/source/loopReactor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Initial conditions
Setup the bubble model
------------

Turbulence model
------------

Run the solver
------------

Expand Down
3 changes: 3 additions & 0 deletions docs/source/side_sparger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Initial conditions
Setup the bubble model
------------

Turbulence model
------------

Run the solver
------------

Expand Down
3 changes: 3 additions & 0 deletions docs/source/stirred_tank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Initial conditions
Setup the bubble model
------------

Turbulence model
------------

Run the solver
------------

Expand Down
4 changes: 0 additions & 4 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ Tutorials
bubbleColumn.rst
calibration_normal_beta.rst
calibration_bsd.rst
loopReactor.rst
airlift.rst
stirred_tank.rst
side_sparger.rst
3 changes: 2 additions & 1 deletion tutorial_cases/bubble_column_20L/0.orig/epsilon.gas
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ boundaryField

defaultFaces
{
type zeroGradient;
type epsilonWallFunction;
value $internalField;
}

}
Expand Down
3 changes: 2 additions & 1 deletion tutorial_cases/bubble_column_20L/0.orig/k.gas
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ boundaryField

defaultFaces
{
type zeroGradient;
type kqRWallFunction;
value $internalField;
}
}

Expand Down
12 changes: 4 additions & 8 deletions tutorial_cases/bubble_column_20L/0.orig/nut.gas
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ FoamFile

dimensions [0 2 -1 0 0 0 0];

internalField uniform 1e-8;
#include "${FOAM_CASE}/constant/globalVars"

internalField uniform $nut_inlet_gas;

boundaryField
{
Expand All @@ -33,16 +35,10 @@ boundaryField

defaultFaces
{
//type nutkWallFunction;
//value $internalField;
type calculated;
type nutkWallFunction;
value $internalField;
}

// defaultFaces
// {
// type empty;
// }
}

// ************************************************************************* //
4 changes: 3 additions & 1 deletion tutorial_cases/bubble_column_20L/0.orig/nut.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ FoamFile

dimensions [0 2 -1 0 0 0 0];

internalField uniform 1e-4;
#include "${FOAM_CASE}/constant/globalVars"

internalField uniform $nut_inlet_liq;

boundaryField
{
Expand Down
2 changes: 2 additions & 0 deletions tutorial_cases/bubble_column_20L/constant/globalVars
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ eps_inlet_gas #calc "pow(0.09,0.75) * Foam::pow($k_inlet_gas, 1.5) / ($l_scale *
eps_inlet_liq #calc "pow(0.09,0.75) * Foam::pow($k_inlet_liq, 1.5) / ($l_scale * 0.07)";
omega_inlet_gas #calc "pow(0.09,-0.25) * pow($k_inlet_gas,0.5) / ($l_scale * 0.07)";
omega_inlet_liq #calc "pow(0.09,-0.25) * pow($k_inlet_liq,0.5) / ($l_scale * 0.07)";
nut_inlet_gas #calc "0.09 * Foam::pow(($k_inlet_gas), 2) / $eps_inlet_gas";
nut_inlet_liq #calc "0.09 * Foam::pow(($k_inlet_liq), 2) / $eps_inlet_liq";
2 changes: 2 additions & 0 deletions tutorial_cases/bubble_column_20L/constant/globalVars_temp
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ eps_inlet_gas #calc "pow(0.09,0.75) * Foam::pow($k_inlet_gas, 1.5) / ($l_scale *
eps_inlet_liq #calc "pow(0.09,0.75) * Foam::pow($k_inlet_liq, 1.5) / ($l_scale * 0.07)";
omega_inlet_gas #calc "pow(0.09,-0.25) * pow($k_inlet_gas,0.5) / ($l_scale * 0.07)";
omega_inlet_liq #calc "pow(0.09,-0.25) * pow($k_inlet_liq,0.5) / ($l_scale * 0.07)";
nut_inlet_gas #calc "0.09 * Foam::pow(($k_inlet_gas), 2) / $eps_inlet_gas";
nut_inlet_liq #calc "0.09 * Foam::pow(($k_inlet_liq), 2) / $eps_inlet_liq";