Saving data from different time steps for plotting
Hi-
What is the best way to save data created in different time steps for plotting after the program has run? This is especially applicable for models with time dependent material properties as discussed in the "linear and power law viscous flow" question. I have tried to extract this data:
viscosity = pb.evaluate('ev_integrate_mat.2.Omega(nonlinear.mu, u)',mode='el_avg', copy_materials=False, verbose=False) out['viscosity'] = Struct(name='vis', mode='cell', data=vis, dofs=None)
or even:
for i in range (0,pb.ts.n_step-1): out_test['vis %s' % pb.ts.step] = Struct(name='vis', mode='cell', data=vis, dofs=None)
but it is overwritten in each time step. I am attempting to plot the mean viscosity over the entire model for each time step. An alternative question might be, can we create a time sensitive probe plot?
A secondary question: I notice that the values on the legend in each plot vary through different time steps. Is it possible to hold the legend values fixed and only change the colors of the corresponding figures?
Thanks
Hi Ben,
I hopefully have an answer to your first question. I did such thing recently in the example [1] - the approach therein was adviced to me by Robert. It relies on passing a mutable variable (e.g. list) to your postprocessing function (stress_strain
in the mentioned example) from the outer scope. The result at each time step is appended to the list and may be plotted/saved/whatever after the main loop of the script is finished.
Jan
[1] http://sfepy.org/doc-devel/examples/large_deformation/hyperelastic_tl_up_int...
Hi Ben,
(see also Jan's response)
On 03/21/2018 10:23 PM, Ben Melosh wrote:
Hi-
What is the best way to save data created in different time steps for plotting after the program has run? This is especially applicable for models with time dependent material properties as discussed in the "linear and power law viscous flow" question. I have tried to extract this data:
viscosity = pb.evaluate('ev_integrate_mat.2.Omega(nonlinear.mu, u)',mode='el_avg', copy_materials=False, verbose=False) out['viscosity'] = Struct(name='vis', mode='cell', data=vis, dofs=None)
or even:
for i in range (0,pb.ts.n_step-1): out_test['vis %s' % pb.ts.step] = Struct(name='vis', mode='cell', data=vis, dofs=None)
but it is overwritten in each time step. I am attempting to plot the mean viscosity over the entire model for each time step. An alternative question might be, can we create a time sensitive probe plot?
You store the results in the VTK format, right? For time-dependent problems, it might be better to use the HDF5 format (see [1] - set output_format to 'h5'). Then there are some tools to work with that, and also to extract time histories, see main() in [2], and the extractor.py script.
It would be nice to have a standard way of probing time-dependent results, but it is not implemented.
[1] http://sfepy.org/doc-devel/users_guide.html?highlight=output_format#miscella... [2] http://sfepy.org/doc-devel/examples/linear_elasticity/linear_viscoelastic.ht...
A secondary question: I notice that the values on the legend in each plot vary through different time steps. Is it possible to hold the legend values fixed and only change the colors of the corresponding figures?
Do you mean the legens shown by the postproc.py script? It is possible to fix the data ranges using the --ranges option, check also --list-ranges
r.
participants (3)
-
Ben Melosh
-
Jan Heczko
-
Robert Cimrman