openfoam/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/createGraphs
Andrew Heather 2af8d38827 ENH: Added new Joule Heating fvOption and test case
Evolves an electrical potential equation

    \f[
        \grad \left( \sigma \grad V \right)
    \f]

    where \f$ V \f$ is electrical potential and \f$\sigma\f$ is the
    electrical current

    To provide a Joule heating contribution according to:

    Differential form of Joule heating - power per unit volume:

    \f[
        \frac{d(P)}{d(V)} = J \cdot E
    \f]

    where \f$ J \f$ is the current density and \f$ E \f$ the electric
field.
    If no magnetic field is present:

    \f[
        J = \sigma E
    \f]

    The electric field given by

    \f[
        E = \grad V
    \f]

    Therefore:

    \f[
        \frac{d(P)}{d(V)} = J \cdot E
                          = (sigma E) \cdot E
                          = (sigma \grad V) \cdot \grad V
    \f]

Usage
    Isotropic (scalar) electrical conductivity
    \verbatim
    jouleHeatingSourceCoeffs
    {
        anisotropicElectricalConductivity no;

        // Optionally specify the conductivity as a function of
        // temperature
        // Note: if not supplied, this will be read from the time
        // directory
        sigma           table
        (
            (273        1e5)
            (1000       1e5)
        );
    }
    \endverbatim

    Anisotropic (vectorial) electrical conductivity
    jouleHeatingSourceCoeffs
    {
        anisotropicElectricalConductivity yes;

        coordinateSystem
        {
            type        cartesian;
            origin      (0 0 0);

            coordinateRotation
            {
                type        axesRotation;
                e1          (1 0 0);
                e3          (0 0 1);
            }
        }

        // Optionally specify sigma as a function of temperature
        //sigma           (31900 63800 127600);
        //
        //sigma           table
        //(
        //    (0      (0 0 0))
        //    (1000   (127600 127600 127600))
        //);
    }

    Where:
    \table
        Property     | Description               | Required  | Default
value
        T            | Name of temperature field | no        | T
        sigma        | Electrical conductivity as a function of
temperature |no|
        anisotropicElectricalConductivity | Anisotropic flag | yes |
    \endtable

    The electrical conductivity can be specified using either:
    - If the \c sigma entry is present the electrical conductivity is
      specified
      as a function of temperature using a Function1 type
    - If not present the sigma field will be read from file
    - If the anisotropicElectricalConductivity flag is set to 'true',
      sigma
      should be specified as a vector quantity
2017-06-09 10:29:21 +01:00

88 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# createGraphs
#
# Description
# Creates .eps graph of OpenFOAM results vs analytical solution for the
# Joule heating case
#
#------------------------------------------------------------------------------
cd ${0%/*} || exit 1 # Run from this directory
# Stop on first error
set -e
# test if gnuplot exists on the system
if ! which gnuplot > /dev/null 2>&1
then
echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" >&2
exit 1
fi
echo "Creating graph"
OFDATA='postProcessing/sample1/solid/20000/centreLine_T_jouleHeatingSource:V_jouleHeatingSource:sigma.xy'
if [ ! -f "$OFDATA" ]
then
echo "FOAM FATAL ERROR: OpenFOAM results not available in $OFDATA" >&2
exit 1
fi
gnuplot<<EOF
set terminal postscript eps color enhanced
set output "OF_vs_ANALYTICAL.eps"
set xlabel "Length, x / [m]"
set ylabel "Temperature / [K]"
set grid
set key left top
rho = 7.837e-6
sigma = 1/rho
kappa = 200
L = 2.5
D = 0.1
H = 0.1
vol = 2.0*L*D*H
V = 1.5
R = rho*2*L/(D*H)
I = V/R
P = I*V
Q = P/vol
Ts = 500
T(x) = Q*L*L/(2*kappa)*(1-(x/L)*(x/L)) + Ts
plot \
"$OFDATA" u 1:2 w lines title "OpenFOAM", \
T(x) w linespoints lt 0 pt 6 pi 15 title "Analytical"
EOF
echo "End"
#------------------------------------------------------------------------------