Python scripts documentation

Vreeman et al. (2002)

blockMeshDict writer

Writes a blockMeshDict file for an axisymmetric case. This script writes a blockMeshDict file for an axisymmetric case in the system directory.

Refer to https://doc.cfd.direct/openfoam/user-guide-v6/blockmesh for the official blockMesh utility documentation.

Example:
Run python script in case system directory:

$ cd system $ python convert_vtk.py

Todo:
  • None

Vreeman2002.system.cylinder.write_blockMeshDict(angle=2.5, diameter=155.0, z_points=(-250.0, -50.0, 0.0, 50.0), rmesh=1.0, zmesh=1.0)

Assembles the blockMeshDict file contents

Parameters
  • angle (float) – Angle of the axisymmetric slice.

  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

  • rmesh (float) – Radial mesh adjustment parameter.

  • zmesh (float) – Vertical mesh adjustment parameter.

Returns

string containing the blockMeshDict file contents

Return type

string

Vreeman2002.system.cylinder.write_blocks(diameter=155.0, z_points=(-250.0, -50.0, 0.0, 50.0), rmesh=1.0, zmesh=1.0)

Writes the blocks entry

Parameters
  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

  • rmesh (float) – Radial mesh adjustment parameter.

  • zmesh (float) – Vertical mesh adjustment parameter.

Returns

string containing the blockMeshDict blocks entry

Return type

string

Vreeman2002.system.cylinder.write_boundary(z_points=(-250.0, -50.0, 0.0, 50.0))

Writes the boundary entry

Parameters

z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict boundary entry

Return type

string

Vreeman2002.system.cylinder.write_edges(angle=2.5, diameter=155.0, z_points=(-250.0, -50.0, 0.0, 50.0))

Writes the edges entry

Parameters
  • angle (float) – Angle of the axisymmetric slice.

  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict edges entry

Return type

string

Vreeman2002.system.cylinder.write_vertices(angle=2.5, diameter=155.0, z_points=(-250.0, -50.0, 0.0, 50.0))

Writes the vertices entry

Parameters
  • angle (float) – Angle of the axisymmetric slice.

  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict vertices entry

Return type

string

VTK conversion

Converts all .vtk files to .vtp.

This script converts all VTK files in the postProcessing directory.

Example:

Run python script in case root directory:

$ python convert_vtk.py

Todo:
  • None

Vreeman2002.convert_vtk.convert_surfaces(vtkFile)

Converts a vtk file to vtp format if it does not exist. Deletes the vtk file upon successful conversion or if vtp file exists.

Parameters

vtkFile (str) – VTK file path and name.

Returns

0 if successful.

Return type

int

Vreeman2002.convert_vtk.vtk2vtp(invtkfile, outvtpfile)

Converts a vtk file to vtp format.

Parameters
  • invtkfile (str) – VTK file path and name.

  • outvtpfile (str) – VTP file path and name.

Returns

0 if successful.

Return type

int

PVD generation

Generates a .pvd XML file to post-process surfaces function objects.

This script assembles the VTK files in separate time directories.

Example:

Run python script in case root directory:

$ python generate_pvd.py

Todo:
  • None

Vreeman2002.generate_pvd.create_xml(variable='U', surface='yNormal', file_format='vtp')

Create <variable>.pvd file with existing VTK files.

Parameters
  • variable (str) – Name of field.

  • surface (str) – Surface of vtk/vtp files.

  • file_format (str) – vtp or vtk.

Returns

0 if successful.

Return type

int

Vreeman2002.generate_pvd.write_pvd(variables=['grad(T)', 'C.Cu', 'melt1_alpha1', 'T', 'U'], surfaces=['yNormal'])

Write PVD files for requested slices.

HTC file creation

Writes HTC table file in foam format.

This script computes the HTC for the water film, including the effect of nucleate boiling. Outputs the HTC table in foam format in constant/HTC_T.

Example:

Run python script in case root directory:

$ python3 write_htc.py

Todo:
  • None

Vreeman2002.write_htc.rohsenhow(T=930, n=1.0, g0=1.0, q_water=90.0, D=0.255, T_water=372.8, T_amb=328.5)

Rohsenhow correlation.

Parameters
  • T (float) – Billet temperature [K].

  • n (float) – Experimental constant equal to 1 for water and 1.7 for other fluids.

  • g0 (float) – Force conversion factor [kg m/N s^2].

  • q_water (float) – Water flow rate [L/min].

  • D (float) – Diameter [m].

  • T_water (float) – Temperature of water jet [K].

  • T_amb (float) – Temperature of the lab [K].

Returns

0 if successful.

Return type

int

Vreeman2002.write_htc.weckmann_niessen(T, q_water=90.0, D=0.255, T_water=372.8)

Weckmann-Niessen correlation.

Parameters
  • T (float) – Billet temperature [K].

  • q_water (float) – Water flow rate [L/min].

  • D (float) – Diameter [m].

  • T_water (float) – Temperature of water jet [K].

Returns

0 if successful.

Return type

int

Vreeman2002.write_htc.write_HTC_T(htc_file='constant/HTC_T', func=<function rohsenhow>, T_water=372.8)

Writes the temperature-HTC foam file using the prescribed formula.

Parameters
  • htc_file (str) – Relative path of HTC foam file.

  • func (function) – HTC function (Rohsenhow or Weckmann-Niessen).

  • T_water (float) – Temperature of water jet [K].

Returns

0 if successful.

Return type

int

Temperature validation

Plots the temperature profiles at prescribed locations.

This script plots the comparison between numerical and experimental data. Experimental data in system/validation.dat. Numerical data in postProcessing directory.

Example:

Run python script in case root directory:

$ python3 plot_line.py

Todo:
  • None

Vreeman2002.plot_line.get_last_time()

Get the last time for the current case.

Vreeman2002.plot_line.plot_line(plot_time, Experimental, Image_Path='.')

Plots temperature graphs at plot_time.

Parameters
  • plot_time (str) – Time at which to plot the temperatures.

  • Experimental (pandas.Dataframe) – Dataframe containing experimental data.

  • Image_Path (str) – Absolute path of line plot.

Returns

0 if successful.

Return type

int

Vreeman2002.plot_line.read_numerical_dataframe(plot_time, probe_position='centreline', temperature_column_name='tcK')

Read temperature at plot_time and return as dataframe.

Sump contour

Plots the sump profile.

This script plots the sump profile using the output in the postProcessing directory.

Example:

Run python script in case root directory:

$ python3 plot_sump.py

Todo:
  • None

Vreeman2002.plot_sump.load_slice(filename)

Read field from .vtp file.

Parameters

filename (str) – Filename of .vtp file, including path.

Returns

A tuple containing points, triangulation and scalar field.

Return type

tuple[numpy.array]

Vreeman2002.plot_sump.plot_sump(image_name='sump.png', cmap='jet')

Plots sump contour.

Parameters
  • image_name (str) – Filename of image, including path.

  • cmap (str or matplotlib.colormaps) – Color map for plotting contour.

Returns

0 if successful.

Return type

int

Lebon et al. (2020)

blockMeshDict writer

Writes a blockMeshDict file for a three-dimensional case. This script writes a blockMeshDict file for a three-dimensional case in the system directory.

Refer to https://doc.cfd.direct/openfoam/user-guide-v6/blockmesh for the official blockMesh utility documentation.

Example:
Run python script in case system directory:

$ cd system $ python convert_vtk.py

Todo:
  • None

Lebon2020.system.cylinder.write_blockMeshDict(diameter=155.0, z_points=(-300.0, -57.0, -40.0, 0.0, 170.0), zmesh=1.0)

Assembles the blockMeshDict file contents

Parameters
  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

  • zmesh (float) – Vertical mesh adjustment parameter.

Returns

string containing the blockMeshDict file contents

Return type

string

Lebon2020.system.cylinder.write_blocks(z_points=(-300.0, -57.0, -40.0, 0.0, 170.0), zmesh=1.0)

Writes the blocks entry

Parameters
  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

  • zmesh (float) – Vertical mesh adjustment parameter.

Returns

string containing the blockMeshDict blocks entry

Return type

string

Lebon2020.system.cylinder.write_boundary(z_points=(-300.0, -57.0, -40.0, 0.0, 170.0))

Writes the boundary entry

Parameters

z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict boundary entry

Return type

string

Lebon2020.system.cylinder.write_edges(square_rad=20.0, diameter=155.0, z_points=(-300.0, -57.0, -40.0, 0.0, 170.0))

Writes the edges entry

Parameters
  • square_rad (float) – Radius of inner section curvature.

  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict edges entry

Return type

string

Lebon2020.system.cylinder.write_vertices(square=16, diameter=155.0, z_points=(-300.0, -57.0, -40.0, 0.0, 170.0))

Writes the vertices entry

Parameters
  • square – Length of inner square section of mesh.

  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict vertices entry

Return type

string

VTK conversion

Converts all .vtk files to .vtp.

This script converts all VTK files in the postProcessing directory.

Example:

Run python script in case root directory:

$ python convert_vtk.py

Todo:
  • None

Lebon2020.convert_vtk.convert_surfaces(vtkFile)

Converts a vtk file to vtp format if it does not exist. Deletes the vtk file upon successful conversion or if vtp file exists.

Parameters

vtkFile (str) – VTK file path and name.

Returns

0 if successful.

Return type

int

Lebon2020.convert_vtk.vtk2vtp(invtkfile, outvtpfile)

Converts a vtk file to vtp format.

Parameters
  • invtkfile (str) – VTK file path and name.

  • outvtpfile (str) – VTP file path and name.

Returns

0 if successful.

Return type

int

PVD generation

Generates a .pvd XML file to post-process surfaces function objects.

This script assembles the VTK files in separate time directories.

Example:

Run python script in case root directory:

$ python generate_pvd.py

Todo:
  • None

Lebon2020.generate_pvd.create_xml(variable='U', surface='yNormal', file_format='vtp')

Create <variable>.pvd file with existing VTK files.

Parameters
  • variable (str) – Name of field.

  • surface (str) – Surface of vtk/vtp files.

  • file_format (str) – vtp or vtk.

Returns

0 if successful.

Return type

int

Lebon2020.generate_pvd.write_pvd(variables=['grad(T)', 'C.Si', 'C.Mg', 'melt1_alpha1', 'T', 'U'], surfaces=['yNormal'])

Write PVD files for requested slices.

HTC file creation

Writes HTC table file in foam format.

This script computes the HTC for the water film, including the effect of nucleate boiling. Outputs the HTC table in foam format in constant/HTC_T.

Example:

Run python script in case root directory:

$ python3 write_htc.py

Todo:
  • None

Lebon2020.write_htc.rohsenhow(T=930, n=1.0, g0=1.0, q_water=90.0, D=0.255, T_water=372.8, T_amb=328.5)

Rohsenhow correlation.

Parameters
  • T (float) – Billet temperature [K].

  • n (float) – Experimental constant equal to 1 for water and 1.7 for other fluids.

  • g0 (float) – Force conversion factor [kg m/N s^2].

  • q_water (float) – Water flow rate [L/min].

  • D (float) – Diameter [m].

  • T_water (float) – Temperature of water jet [K].

  • T_amb (float) – Temperature of the lab [K].

Returns

0 if successful.

Return type

int

Lebon2020.write_htc.weckmann_niessen(T, q_water=90.0, D=0.255, T_water=372.8)

Weckmann-Niessen correlation.

Parameters
  • T (float) – Billet temperature [K].

  • q_water (float) – Water flow rate [L/min].

  • D (float) – Diameter [m].

  • T_water (float) – Temperature of water jet [K].

Returns

0 if successful.

Return type

int

Lebon2020.write_htc.write_HTC_T(htc_file='constant/HTC_T', func=<function rohsenhow>, T_water=372.8)

Writes the temperature-HTC foam file using the prescribed formula.

Parameters
  • htc_file (str) – Relative path of HTC foam file.

  • func (function) – HTC function (Rohsenhow or Weckmann-Niessen).

  • T_water (float) – Temperature of water jet [K].

Returns

0 if successful.

Return type

int

Temperature validation

Plots the temperature profiles at prescribed locations.

This script plots the comparison between numerical and experimental data. Experimental data in system/validation.dat. Numerical data in postProcessing directory.

Example:

Run python script in case root directory:

$ python3 plot_line.py

Todo:
  • None

Lebon2020.plot_line.get_last_time()

Get the last time for the current case.

Lebon2020.plot_line.plot_line(plot_time, Experimental, Image_Path='.', offset=-0.01)

Plots temperature graphs at plot_time.

Parameters
  • plot_time (str) – Time at which to plot the temperatures.

  • Experimental (pandas.Dataframe) – Dataframe containing experimental data.

  • Image_Path (str) – Absolute path of line plot.

  • offset (float) – Offset position of mould bottom in experiment.

Returns

0 if successful.

Return type

int

Lebon2020.plot_line.read_numerical_dataframe(plot_time, probe_position='centreline', temperature_column_name='tcK')

Read temperature at plot_time and return as dataframe.

Sump contour

Plots the sump profile.

This script plots the sump profile using the output in the postProcessing directory.

Example:

Run python script in case root directory:

$ python3 plot_sump.py

Todo:
  • None

Lebon2020.plot_sump.load_slice(filename)

Read field from .vtp file.

Parameters

filename (str) – Filename of .vtp file, including path.

Returns

A tuple containing points, triangulation and scalar field.

Return type

tuple[numpy.array]

Lebon2020.plot_sump.plot_sump(image_name='sump.png', cmap='jet')

Plots sump contour.

Parameters
  • image_name (str) – Filename of image, including path.

  • cmap (str or matplotlib.colormaps) – Color map for plotting contour.

Returns

0 if successful.

Return type

int

Subroto et al. (2021)

blockMeshDict writer

Writes a blockMeshDict file for an axisymmetric case. This script writes a blockMeshDict file for an axisymmetric case in the system directory.

Refer to https://doc.cfd.direct/openfoam/user-guide-v6/blockmesh for the official blockMesh utility documentation.

Example:
Run python script in case system directory:

$ cd system $ python convert_vtk.py

Todo:
  • None

Subroto2021.system.cylinder.write_blockMeshDict(angle=2.5, diameter=155.0, z_points=(-250.0, -50.0, 0.0, 50.0), rmesh=1.0, zmesh=1.0)

Assembles the blockMeshDict file contents

Parameters
  • angle (float) – Angle of the axisymmetric slice.

  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

  • rmesh (float) – Radial mesh adjustment parameter.

  • zmesh (float) – Vertical mesh adjustment parameter.

Returns

string containing the blockMeshDict file contents

Return type

string

Subroto2021.system.cylinder.write_blocks(diameter=155.0, z_points=(-250.0, -50.0, 0.0, 50.0), rmesh=1.0, zmesh=1.0)

Writes the blocks entry

Parameters
  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

  • rmesh (float) – Radial mesh adjustment parameter.

  • zmesh (float) – Vertical mesh adjustment parameter.

Returns

string containing the blockMeshDict blocks entry

Return type

string

Subroto2021.system.cylinder.write_boundary(z_points=(-250.0, -50.0, 0.0, 50.0))

Writes the boundary entry

Parameters

z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict boundary entry

Return type

string

Subroto2021.system.cylinder.write_edges(angle=2.5, diameter=155.0, z_points=(-250.0, -50.0, 0.0, 50.0))

Writes the edges entry

Parameters
  • angle (float) – Angle of the axisymmetric slice.

  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict edges entry

Return type

string

Subroto2021.system.cylinder.write_vertices(angle=2.5, diameter=155.0, z_points=(-250.0, -50.0, 0.0, 50.0))

Writes the vertices entry

Parameters
  • angle (float) – Angle of the axisymmetric slice.

  • diameter (float) – Diameter of the cast billet (mm).

  • z_points (tuple) – z coordinates of the boundaries of the billet and mould sections.

Returns

string containing the blockMeshDict vertices entry

Return type

string

VTK conversion

Converts all .vtk files to .vtp.

This script converts all VTK files in the postProcessing directory.

Example:

Run python script in case root directory:

$ python convert_vtk.py

Todo:
  • None

Subroto2021.convert_vtk.convert_surfaces(vtkFile)

Converts a vtk file to vtp format if it does not exist. Deletes the vtk file upon successful conversion or if vtp file exists.

Parameters

vtkFile (str) – VTK file path and name.

Returns

0 if successful.

Return type

int

Subroto2021.convert_vtk.vtk2vtp(invtkfile, outvtpfile)

Converts a vtk file to vtp format.

Parameters
  • invtkfile (str) – VTK file path and name.

  • outvtpfile (str) – VTP file path and name.

Returns

0 if successful.

Return type

int

PVD generation

Generates a .pvd XML file to post-process surfaces function objects.

This script assembles the VTK files in separate time directories.

Example:

Run python script in case root directory:

$ python generate_pvd.py

Todo:
  • None

Subroto2021.generate_pvd.create_xml(variable='U', surface='yNormal', file_format='vtp')

Create <variable>.pvd file with existing VTK files.

Parameters
  • variable (str) – Name of field.

  • surface (str) – Surface of vtk/vtp files.

  • file_format (str) – vtp or vtk.

Returns

0 if successful.

Return type

int

Subroto2021.generate_pvd.write_pvd(variables=['grad(T)', 'C.Si', 'C.Mg', 'melt1_alpha1', 'T', 'U'], surfaces=['yNormal'])

Write PVD files for requested slices.

HTC file creation

Writes HTC table file in foam format.

This script computes the HTC for the water film, including the effect of nucleate boiling. Outputs the HTC table in foam format in constant/HTC_T.

Example:

Run python script in case root directory:

$ python3 write_htc.py

Todo:
  • None

Subroto2021.write_htc.rohsenhow(T=930, n=1.0, g0=1.0, q_water=90.0, D=0.255, T_water=372.8, T_amb=328.5)

Rohsenhow correlation.

Parameters
  • T (float) – Billet temperature [K].

  • n (float) – Experimental constant equal to 1 for water and 1.7 for other fluids.

  • g0 (float) – Force conversion factor [kg m/N s^2].

  • q_water (float) – Water flow rate [L/min].

  • D (float) – Diameter [m].

  • T_water (float) – Temperature of water jet [K].

  • T_amb (float) – Temperature of the lab [K].

Returns

0 if successful.

Return type

int

Subroto2021.write_htc.weckmann_niessen(T, q_water=90.0, D=0.255, T_water=372.8)

Weckmann-Niessen correlation.

Parameters
  • T (float) – Billet temperature [K].

  • q_water (float) – Water flow rate [L/min].

  • D (float) – Diameter [m].

  • T_water (float) – Temperature of water jet [K].

Returns

0 if successful.

Return type

int

Subroto2021.write_htc.write_HTC_T(htc_file='constant/HTC_T', func=<function rohsenhow>, T_water=372.8)

Writes the temperature-HTC foam file using the prescribed formula.

Parameters
  • htc_file (str) – Relative path of HTC foam file.

  • func (function) – HTC function (Rohsenhow or Weckmann-Niessen).

  • T_water (float) – Temperature of water jet [K].

Returns

0 if successful.

Return type

int

Temperature validation

Plots the temperature profiles at prescribed locations.

This script plots the comparison between numerical and experimental data. Experimental data in system/validation.dat. Numerical data in postProcessing directory.

Example:

Run python script in case root directory:

$ python3 plot_line.py

Todo:
  • None

Subroto2021.plot_line.get_last_time()

Get the last time for the current case.

Subroto2021.plot_line.plot_line(plot_time, Experimental, Image_Path='.', offset=-0.01)

Plots temperature graphs at plot_time.

Parameters
  • plot_time (str) – Time at which to plot the temperatures.

  • Experimental (pandas.Dataframe) – Dataframe containing experimental data.

  • Image_Path (str) – Absolute path of line plot.

  • offset (float) – Offset position of mould bottom in experiment.

Returns

0 if successful.

Return type

int

Subroto2021.plot_line.read_numerical_dataframe(plot_time, probe_position='centreline', temperature_column_name='tcK')

Read temperature at plot_time and return as dataframe.

Sump contour

Plots the sump profile.

This script plots the sump profile using the output in the postProcessing directory.

Example:

Run python script in case root directory:

$ python3 plot_sump.py

Todo:
  • None

Subroto2021.plot_sump.load_slice(filename)

Read field from .vtp file.

Parameters

filename (str) – Filename of .vtp file, including path.

Returns

A tuple containing points, triangulation and scalar field.

Return type

tuple[numpy.array]

Subroto2021.plot_sump.plot_sump(image_name='sump.png', cmap='jet')

Plots sump contour.

Parameters
  • image_name (str) – Filename of image, including path.

  • cmap (str or matplotlib.colormaps) – Color map for plotting contour.

Returns

0 if successful.

Return type

int