FireDynamics / fdsreader

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

Giving correct index of a parameter but receiving values of another parameter #39

Closed kamaliseresht closed 2 years ago

kamaliseresht commented 2 years ago

Hey there,

I encountered a problem wile reading pl3D data, I correctly identify the index of 'SOOT VISIBILITY' based on the quantity.name but what I read is values of other parameter. And every time I run it, it reads the values of different parameters!

JanVogelsang commented 2 years ago

Hello @kamaliseresht , Could you provide me with an example of the cases you tested this on as well as the actual code you run so I can easily identify the problem?

kamaliseresht commented 2 years ago

Hi Jan,

Here are the code and fds file:

################################## def find_sim3D_quantity_names(): sim3D_quantityNames_quantityIndex_dict = {} for i in range(len(sim.data_3d.quantities)): quantity_name = sim.data_3d.quantities[i].name sim3D_quantityNames_quantityIndex_dict[quantity_name] = i print("sim3D_quantityNames_auantityIndex_dict:", sim3D_quantityNames_quantityIndex_dict) return sim3D_quantityNames_quantityIndex_dict

def main(quantity_idx):

mesh = sim.meshes[1]
extent = mesh.extent
t = -1
pl_t1 = sim.data_3d[t]
quantity = pl_t1.quantities[quantity_idx]
color_data = pl_t1[mesh].data[5:6, 29:30, 10:11, quantity_idx][0][0][0]
print("color_data:",color_data)

if name == "main": path = 'C:/Users/FESG/Desktop/test/FDS/Reading PL3D' sim = fds.Simulation(path) preferred_quantity = 'TEMPERATURE' sim3D_quantityNames_quantityIndex_dict = find_sim3D_quantity_names() quantity_idx = sim3D_quantityNames_quantityIndex_dict[preferred_quantity] main(quantity_idx) #######################

&HEAD CHID='vort3d_80', TITLE='2D Vortex Simulation, Mesh Size = 80' /

&TIME T_END=50.0/

&MESH ID='Mesh1', IJK=24,36,12, XB=-1.0, 5.0,-1.0,8.0,0.0,3.0/ &MESH ID='Mesh2', IJK=24,36,12, XB= 5.0,11.0,-1.0,8.0,0.0,3.0/

&REAC ID='POLYURETHANE', FYI='NFPA Babrauskas', FUEL='REAC_FUEL', C=6.3, H=7.1, O=2.1, N=1.0, SOOT_YIELD=0.1/

&SURF ID='FIRE', COLOR='RED', HRRPUA=50.0/

&OBST XB=5.0,5.5,5.5,7.5,0.0,2.5, RGB=255,255,255, TRANSPARENCY=0.407843, SURF_ID='INERT'/ AcDb3dSolid - 14AD &OBST XB=-0.5,0.0,7.0,7.5,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 13D9 &OBST XB=-0.5,10.5,7.5,8.0,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 13D9 &OBST XB=10.0,10.5,7.0,7.5,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 13D9 &OBST XB=-0.5,0.0,0.0,5.0,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 16F9 &OBST XB=-0.5,0.0,5.5,6.0,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 16F9 &OBST XB=-0.5,1.5,5.0,5.5,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 16F9 &OBST XB=-0.5,10.5,-0.5,0.0,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 16F9 &OBST XB=8.5,10.5,5.0,5.5,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 16F9 &OBST XB=10.0,10.5,0.0,5.0,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 16F9 &OBST XB=10.0,10.5,5.5,6.0,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 16F9 &OBST XB=2.5,7.5,5.0,5.5,0.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 16FE &OBST XB=1.5,2.5,5.0,5.5,2.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 1445 &OBST XB=7.5,8.5,5.0,5.5,2.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 1452 &OBST XB=-0.5,0.0,6.0,7.0,2.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 1456 &OBST XB=10.0,10.5,6.0,7.0,2.0,2.5, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 1463 &OBST XB=-0.5,10.5,-0.5,8.0,2.5,2.75, RGB=91,91,91, SURF_ID='INERT'/ AcDb3dSolid - 1469

&VENT SURF_ID='FIRE', XB=9.5,10.0,6.0,6.5,0.0,0.0/ Vent &VENT SURF_ID='OPEN', XB=11.0,11.0,-1.0,8.0,0.0,3.0/ Mesh Vent: Mesh1 [XMAX] &VENT SURF_ID='OPEN', XB=-1.0,-1.0,-1.0,8.0,0.0,3.0/ Mesh Vent: Mesh1 [XMIN] &VENT SURF_ID='OPEN', XB=-1.0,11.0,8.0,8.0,0.0,3.0/ Mesh Vent: Mesh1 [YMAX] &VENT SURF_ID='OPEN', XB=-1.0,11.0,-1.0,-1.0,0.0,3.0/ Mesh Vent: Mesh1 [YMIN] &VENT SURF_ID='OPEN', XB=-1.0,11.0,-1.0,8.0,3.0,3.0 XYZ=5.0,4.5,3.0, RADIUS=0.5/ Mesh Vent: Mesh1 [ZMAX]

&DUMP DT_PL3D=10, PLOT3D_QUANTITY(1:5)='TEMPERATURE', 'U-VELOCITY','V-VELOCITY','W-VELOCITY','HRRPUV' /

&TAIL /

####################### Many thanks!

JanVogelsang commented 2 years ago

The reason your approach doesn't work is because of the implementation of the data_3d.quantities attribute. Under the hood is uses a set to find all quantities that were output in the simulation, which do not have to be present on every single Plot3D instance as you can specify the quantities in the "DUMP" namelist. Your approach will also work if you use the quantities attribute of the individual Plot3D (after applying your indexing on data_3d pl_t1 = sim.data_3d[t]), as those will only contain the exact (sorted) quantities of the specific Plot3D instance.

To make life easier for you (and others with the same issue), I just added a new convenience method to get the index of the quantity: quantity_idx = pl_t1.get_quantity_index("Temperature")

Please update your fdsreader package to version 1.3.0 (or simply the newest version) and tell me if this works for you.

kamaliseresht commented 2 years ago

I updated the library to 1.3.0 but pl_t1.get_quantity_index("Temperature") doesn't seem to be a feature yet. However, I could resolve the issue based on your explanation. Thank you so much!

JanVogelsang commented 2 years ago

Strange, it should be. I am using it in the example as well which works just as expected. But anyway, great to hear we could solve the issue!