brechtm / rinohtype

The Python document processor
http://www.mos6581.org/rinohtype
GNU Affero General Public License v3.0
499 stars 59 forks source link

AttributeError: 'GroupedFlowablesState' object has no attribute 'column_widths' #233

Open mwm126 opened 3 years ago

mwm126 commented 3 years ago

Observed the bug with both master and 0.5.2 on Elementary OS Linux with Python 3.8.5 and Sphinx 3.5.1.

adding column_widths = 0 in the constructor of GroupedFlowablesState is a workaround for avoiding the exception.

(I could add the rst source if required, but it's extra work to find a small test case, if the stack trace itself is insufficient.)

rinohtype 0.5.3 (in development)  Copyright (c) Brecht Machiels and contributors
This program comes with ABSOLUTELY NO WARRANTY. Its use is subject
to the terms of the GNU Affero General Public License version 3.
rendering... 
TeX Gyre Pagella does not include a normal medium upright font. Falling back to normal regular upright
TeX Gyre Cursor does not include a normal medium upright font. Falling back to normal regular upright
The 'math' role is not yet supported (page 3) ] ETA 00:01 (00:01) page 3
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:119 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:131 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:137 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:143 <math_block>] The 'math' directive is not yet supported (page 4)
The 'math' role is not yet supported (page 4) ] ETA 00:01 (00:01) page 4
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:150 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:157 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:169 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:177 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:186 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:195 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:203 <math_block>] The 'math' directive is not yet supported (page 4)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:211 <math_block>] The 'math' directive is not yet supported (page 5)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:223 <math_block>] The 'math' directive is not yet supported (page 5)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:229 <math_block>] The 'math' directive is not yet supported (page 5)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:236 <math_block>] The 'math' directive is not yet supported (page 5)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:243 <math_block>] The 'math' directive is not yet supported (page 5)
[/home/mark/repos/mfix/doc/user_manual/model_setup/monitor.rst:251 <math_block>] The 'math' directive is not yet supported (page 5)
The 'math' role is not yet supported (page 5) ] ETA 00:00 (00:02) page 5

Exception occurred:
  File "/home/mark/.cache/pypoetry/virtualenvs/mfix-TSdb6oU_-py3.8/lib/python3.8/site-packages/rinoh/table.py", line 151, in render
    if state.column_widths is None:
AttributeError: 'GroupedFlowablesState' object has no attribute 'column_widths'
mwm126 commented 3 years ago

monitor.rst:

Monitors
^^^^^^^^

A Monitor is a tool for capturing data from the solver about the model.

.. figure:: /../srs/images/monitors.png
   :scale: 75 %
   :align: center

   Monitor pane

.. _monitor_region:

Region Selection
----------------

To define a monitor, there must be a region already defined in the :ref:`Regions
Pane <regions>`. Click the |add| button at the top, which will open a popup
window for selecting the region. A Monitor region is a single point, plane, or
volume. Multiple regions cannot be combined for a monitor, and STL regions
cannot be used for monitors.

.. _monitor_filename:

Monitor Output
--------------

Filename
   The monitor output file will have a default name based on the name of the
   monitor's region. You can edit the filename of a monitor by selecting the
   monitor from the list of monitors and changing "Filename base". The monitor data
   will be output to the Filename base with the extension ``.csv``.

   The monitor output file is in Comma Separated Value (CSV) format. The first line
   of the file provides header information. For example, running the Silane
   Pyrolysis tutorial (SP2D) will generate a file ``PROBE_SPECIES.csv``:

   .. code:: text

       #
       # Run type: NEW
       # "Time","x_g(1)","x_g(2)","x_g(3)","x_g(4)","x_g(5)","x_s(1,1)","x_s(1,2)"
           0.0000000    ,    0.0000000    ,    0.0000000    ,    0.0000000    ,    0.0000000    ,    1.0000000    ,    0.0000000    ,    1.0000000

Write Interval
   The write interval defines how frequently the monitor data will be written to
   the output file. It has a default value of 0.05 seconds of simulation time.

After creating a monitor, use the menus and check boxes to select one or more variables.

Eulerian Monitors
-----------------

The monitor variables available for the fluid phase are:

   -  Volume fraction (of all fluid species)
   -  Fluid Pressure
   -  Fluid Velocity
   -  Fluid Temperature
   -  Turbulent Kinetic Energy
   -  Turbulent Dissipation
   -  Volume fraction of each individual fluid species

The variables available for TFM solids include:

   -  Velocity of this solid phase
   -  Bulk Density of this solid phase
   -  Temperature of this solid phase
   -  Granular Temperature of this solid phase
   -  Pressure (total for all solid species for this solid phase)
   -  Mass fraction of each individual species of this solid phase

There is a monitor variable available for each scalar defined on
the :ref:`scalar_pane` tab.

There is a monitor variable available for each reaction defined on
the :ref:`chemical_reactions` tab.

There are different types of monitors available. A monitor type applies an operator
(for example a sum, an area integral or a volume integral) to the variable.
The dimensionality of the region determines which operators can be applied.

The table below summarizes the nomenclature used to describe the monitor operators:

========================= ========================================
Symbol                     Description
========================= ========================================
:math:`\phi_{ijk}`        Variable value at indexed cell
:math:`\varepsilon_{ijk}` Phase **volume fraction** at indexed cell
:math:`\rho_{jk}`         Phase **density** at indexed cell
:math:`\vec{v}_{jk}`      Phase **velocity** at indexed cell
:math:`A_{ijk}`           Cross-sectional area of cell
:math:`V_{ijk}`           Volume of indexed cell
========================= ========================================

Point Region
~~~~~~~~~~~~

For a point region, the monitor data value is simply the value of the variable at that point:

Value
   Returns the value of the field quantity in
   the selected region.

   .. math:: \phi_{ijk}

Area or Volume Region
~~~~~~~~~~~~~~~~~~~~~

The following  monitor types are valid for area and volume regions:

Sum
   The sum is computed by summing all values of
   the field quantity in the selected region.

   .. math:: \sum_{ijk}\phi_{ijk}

Min
   Minimum value of the field quantity in the
   selected region.

   .. math:: \min_{ijk} \phi_{ijk}

Max
   Maximum value of the field quantity in the
   selected region.

   .. math:: \max_{ijk} \phi_{ijk}

Average
   Average value of the field quantity in the selected
   region where :math:`N` is the total number of observations (cells)
   in the selected region.

   .. math:: \phi_0 = \frac{\sum_{ijk} \phi_{ijk}}{N}

Standard Deviation
   The standard deviation of the field quantity in the
   selected region where :math:`\phi_0` is the average of the variable in
   the selected region.

   .. math:: \sigma_{\phi} = \sqrt{\frac{ \sum_{ijk} (\phi_{ijk}-\phi_{0})^2 }{N}}

Surface Integrals
~~~~~~~~~~~~~~~~~

The following types are only valid for area regions:

Area
   Area of selected region is computed by summing the
   areas of the facets that define the surface.

   .. math:: \int dA = \sum_{ijk} \lvert A_{ijk} \rvert

Area-Weighted Average
   The area-weighted average is computed by dividing
   the summation of the product of the selected variable and facet
   area by the total area of the region.

   .. math:: \frac{\int\phi dA}{A} = \frac{\sum_{ijk}{\phi_{ijk} \lvert A_{ijk} \rvert}}{\sum_{ijk}{\lvert A_{ijk} \rvert}}

Flow Rate
   The flow rate of a field variable through a surface
   is computed by summing the product of the phase volume fraction,
   density, the selected field variable, phase velocity normal to
   the facet :math:`v_n`, and the facet area.

   .. math:: \int\varepsilon\rho\phi{v_n}dA = \sum_{ijk}\varepsilon_{ijk}\rho_{ijk}\phi_{ijk} {v}_{n,ijk} \lvert A_{ijk} \rvert

Mass Flow Rate
   The mass flow rate through a surface is computed
   by summing the product of the phase volume fraction, density,
   phase velocity normal to the facet :math:`v_n`, and the facet
   area.

   .. math:: \int\varepsilon\rho{v_n} dA = \sum_{ijk}\varepsilon_{ijk}\rho_{ijk}{v}_{n,ijk}  \lvert A_{ijk} \rvert

Mass-Weighted Average
   **FIXME** The mass flow rate through a surface is computed
   by summing the product of the phase volume fraction, density,
   phase velocity normal to the facet, and the facet area.

   .. math:: \frac{\int\varepsilon\rho\phi\lvert{v_n}dA\rvert}{\int\varepsilon\rho\lvert{v_n}dA\rvert} = \frac{\sum_{ijk}\varepsilon_{ijk}\rho_{ijk}\phi_{ijk}\lvert {v}_{n,ijk} A_{ijk} \rvert}{\sum_{ijk}\varepsilon_{ijk}\rho_{ijk} \lvert {v}_{n,ijk} A_{ijk} \rvert}

Volume Flow Rate
   The volume flow rate through a surface is computed
   by summing the product of the phase volume fraction, phase velocity
   normal to the facet :math:`v_n`, and the facet area.

   .. math:: \int\varepsilon{v_n}dA = \sum_{ijk}\varepsilon_{ijk}{v}_{n,ijk} \lvert A_{ijk} \rvert

Volume Integrals
~~~~~~~~~~~~~~~~

The following types are only valid for volume regions:

Volume
   The volume is computed by summing all of the cell
   volumes in the selected region.

   .. math:: \int  dV = \sum_{ijk}{ \lvert V_{ijk}} \rvert

Volume Integral
   The volume integral is computed by summing the product
   of the selected field variable and the cell volume.

   .. math:: \int \phi dV = \sum_{ijk}{\phi_{ijk} \lvert V_{ijk}} \rvert

Volume-Weighted Average
   The volume-weighted average is computed by dividing
   the summation of the product of the selected field variable and
   cell volume by the sum of the cell volumes.

    .. math:: \frac{\int\phi dV}{V} = \frac{\sum_{ijk}{\phi_{ijk} \lvert V_{ijk} \rvert}}{\sum_{ijk}{\lvert V_{ijk} \rvert}}

Mass-Weighted Integral
   The mass-weighted integral is computed by summing
   the product of phase volume fraction, density, selected field
   variable, and cell volume.

   .. math:: \int \varepsilon\rho\phi dV = \sum_{ijk}\varepsilon_{ijk}\rho_{ijk}\phi_{ijk} \lvert V_{ijk}\rvert

Mass-Weighted Average
   The mass-weighted average is computed by dividing the
   sum of the product of phase volume fraction, density, selected field
   variable, and cell volume by the summation of the product of the
   phase volume fraction, density, and cell volume.

   .. math:: \frac{\int\phi\rho\varepsilon dV}{\int\rho\varepsilon dV} = \frac{\sum_{ijk}\varepsilon_{ijk}\rho_{ijk}\phi_{ijk} \lvert V_{ijk}\rvert}{\sum_{ijk}\varepsilon_{ijk}\rho_{ijk} \lvert V_{ijk}\rvert}

Lagrangian Monitors
-------------------

The variables available for DEM and PIC solids are:

   -  Radius
   -  Mass
   -  Volume
   -  Density
   -  Translational velocity components
   -  Rotational velocity components (DEM only)
   -  Temperature
   -  Mass fraction of each individual species
   -  DES user variable (DES_USR_VAR)

There are different types of monitors available. A monitor type applies an operator
(for example a sum, an area integral or a volume integral) to the variable.
The dimensionality of the region determines which operators can be applied.

The table below summarizes the nomenclature used to describe the monitor operators:

========================= ====================================================
Symbol                     Description
========================= ====================================================
:math:`\phi_p`            Variable value of the indexed particle
:math:`m_p`               **Mass** of the indexed particle
:math:`V_p`               **Volume** of the indexed particle
:math:`\mathcal{w}_p`     **Statistical weight** of the indexed particle [#]_
========================= ====================================================

.. [#] *The statistical weight is one for DEM simulations.*
brechtm commented 3 years ago

I'm not able to reproduce the issue with the file you pasted. You can try rendering individual rst files using rinoh to find the culprit.

I see that your document contains a lot of maths. I hope you are aware that rinohtype at present does not support maths rendering?

mwm126 commented 3 years ago

Yes; I saw the error about :math: not supported, but was not sure if that was a warning or error though. I was hoping that rendering a document using unsupported math would render what it could, rendering the maths blank (ignore math elements and succeed.). But I understand, it is also reasonable to exit with failure, rather than render a document incorrectly with a successful exit status.

brechtm commented 3 years ago

I think you misunderstood me. The 'math' warnings are not the reason rendering fails. rinohtype simply outputs the TeX code as-is and continues.

If you're still interested in finding the reStructuredText input that causes the AttributeError, you can try rendering individual rst files using the rinoh command line tool and share the file that causes the crash.