Skip to content

[Bug]: Index error when finding the cell centered coordinates of a slice #103

@wk9874

Description

@wk9874

What happened?

When attempting to get the global values of a slice using to_global, I get the following error:

  File "test.py", line 5, in <module>
    sim.slices[1].to_global()
  File "lib/python3.10/site-packages/fdsreader/slcf/slice.py", line 537, in to_global
    base_coord = next(iter(self._subslices.values())).get_coordinates(ignore_cell_centered=False)[dimension][0]
  File "lib/python3.10/site-packages/fdsreader/slcf/slice.py", line 66, in get_coordinates
    co += abs(co[1] - co[0]) / 2
IndexError: index 1 is out of bounds for axis 0 with size 1

I think this is due to the mesh along one axis only having one coordinate in the FDS file:

&MULT ID='m1', DX=1.25,DZ=0.5 I_UPPER=7,K_UPPER=1/ 16 mesh
&MESH IJK=100,1,40, XB=0,1.25,-0.1,0.1,0,0.5, MULT_ID='m1'/

And the last coordinate being removed in get_coordinates before the shift is performed:

            if self.cell_centered and not ignore_cell_centered:
                co = co[:-1]
                co += abs(co[1] - co[0]) / 2

Steps to reproduce

  1. Run the Pohlhausen validation case: https://github.com/firemodels/fds/blob/master/Validation/Convection/FDS_Input_Files/Pohlhausen_Pr_1.fds
  2. Try to load the temperature slice from the results:
import fdsreader

sim = fdsreader.Simulation("pohl_results")

temp_slice = [slice for slice in sim.slices if slice.quantity.quantity == "TEMPERATURE"][0]

values = temp_slice.to_global()

FDS version used

6.9.1

fdsreader version used

1.11.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions