FireDynamics / fdsreader

Python reader for FDS data
GNU General Public License v3.0
44 stars 18 forks source link

A code problem about "pl3d_example.py" #69

Closed zhang-zhen-project closed 5 months ago

zhang-zhen-project commented 8 months ago

Dear Author: I'm very appreciate your program, and I'm sorry bother you, but this question confuzed me a while, which located follwing code, "# Select the last available timestep t = -1", does t represent the time dimension? If I want to read all the plot3d data, do I have to change the source code because I tried to set t for more than 5 seconds, and the index out of bounds exception was displayed. Thank you~Here is original code:

import pyvista as pv
import numpy as np
import fdsreader as fds

      def main():
          sim = fds.Simulation(r"D:\fds\fdsreader-master\examples\pl3d\fds_data\t_c_v_my_vort_3d\my_vort_3d")

          # Load temperature 3D data
          quantity = "Temperature"
          pl_t1 = sim.data_3d.get_by_quantity(quantity)
          data, coordinates = pl_t1.to_global(masked=True, return_coordinates=True, fill=np.nan)

          # Select the last available timestep
          t = -1

          # Create 3D grid
          x_ = np.linspace(coordinates['x'][0], coordinates['x'][-1], len(coordinates['x']))
          y_ = np.linspace(coordinates['y'][0], coordinates['y'][-1], len(coordinates['y']))  # y_ = np.array([29])  # when using a slice
          z_ = np.linspace(coordinates['z'][0], coordinates['z'][-1], len(coordinates['z']))
          x, y, z = np.meshgrid(x_, y_, z_, indexing='ij')
          points = np.stack((x.flatten(), y.flatten(), z.flatten()), axis=1)

          color_data = data[t, :, :, :]
JanVogelsang commented 8 months ago

Yes, t represents time and the first dimension of data is indeed the time dimension. Calling data = sim.data_3d.get_by_quantity("Temparature").to_global() returns a four-dimensional array with time on the first dimension. data[-1] or data[-1, :, :, :] (which is equivalent in this case) should give the three-dimensional data output at the very last timestep. As long as there is any data output by your simulation, an "Out of bounds"-Exception should never occur.

Please send me the stacktrace (detailed error message) so I can see at which location your error occurred. In case this is a bug in the fdsreader, I will also need your FDS-case (probably my_vort_3d.fds), as this helps me to fix the bug.

zhang-zhen-project commented 8 months ago

"I encountered a system problem, 'cannot reshape array of size 185920 into shape (10, 176, 14, 8),' in 'plot3D.py' when using my fds file. After investigating, I found that the following code is intended to combine the data and its coordinates. However, it confuses me as it doesn't seem to be for each mesh group. I have attached my fds file. I'm looking forward to your response. Thank you very much!"

if `masked:`
                subplot_data = np.where(mask, subplot_data, fill)
            grid[:, start_idx['x']: end_idx['x'], start_idx['y']: end_idx['y'],
            start_idx['z']: end_idx['z']] = subplot_data.reshape(
                (self.n_t, end_idx['x'] - start_idx['x'], end_idx['y'] - start_idx['y'],
                 end_idx['z'] - start_idx['z']))

[Uploading bls_no_sf.zip…]()

zhang-zhen-project commented 8 months ago

[Uploading bls_no_sf.zip…]()

JanVogelsang commented 8 months ago

@zhang-zhen-project It doesn't seem like the upload worked, it's just a link to this page with no file attached.

JanVogelsang commented 8 months ago

Which version of the FDSreader are you using and which FDS version?

zhang-zhen-project commented 5 months ago

Does pl3 currently only support 3d temperature data export? as follow:

Load temperature 3D data

quantity = "CARBON MONOXIDE"
pl_t1 = sim.data_3d.get_by_quantity(quantity)

My personal understanding is that for example, CARBON MONOXIDE concentration, write the following in the dump line of fds:

&DUMP DT_PL3D=10, PLOT3D_QUANTITY(1:3)='TEMPERATURE', 'VOLUME FRACTION', 'HRRPUV' PLOT3D_SPEC_ID(2)='CARBON MONOXIDE' /

I noticed that if we want to derive 3d data of co concentration, the quantity here should be two parameters, namely 'VOLUME FRACTION' and 'CARBON MONOXIDE',

Thanks for your guidance!

JanVogelsang commented 5 months ago

Dear @zhang-zhen-project. Please as that question in the FDS-forum, as this question is not related to the fdsreader directly.

JanVogelsang commented 5 months ago

Closing this issue as no further help seems to be required.