sfepy.discrete.dg.dg_1D_vizualizer module¶
Module for animating solutions in 1D. Can also save them but requieres ffmpeg package see save_animation method.
- sfepy.discrete.dg.dg_1D_vizualizer.animate1D_dgsol(Y, X, T, ax=None, fig=None, ylims=None, labs=None, plott=None, delay=None)[source]¶
Animates solution of 1D problem into current figure. Keep reference to returned animation object otherwise it is discarded
- Parameters:
- Y
solution, array |T| x |X| x n, where n is dimension of the solution
- X
space interval discetization
- T
time interval discretization
- ax
specify axes to plot to (Default value = None)
- fig
specifiy figure to plot to (Default value = None)
- ylims
limits for y axis, default are 10% offsets of Y extremes
- labs
labels to use for parts of the solution (Default value = None)
- plott
plot type - how to plot data: tested plot, step (Default value = None)
- delay
(Default value = None)
- Returns:
- anim
the animation object, keep it to see the animation, used for savig too
- sfepy.discrete.dg.dg_1D_vizualizer.animate_1D_DG_sol(coors, t0, t1, u, tn=None, dt=None, ic=<function <lambda>>, exact=<function <lambda>>, delay=None, polar=False)[source]¶
- Animates solution to 1D problem produced by DG:
animates DOF values in elements as steps
animates reconstructed solution with discontinuities
- Parameters:
- coors
coordinates of the mesh
- t0float
starting time
- t1float
final time
- u
vectors of DOFs, for each order one, shape(u) = (order, nspace_steps, ntime_steps, 1)
- ic
analytical initial condition, optional (Default value = lambda x: 0.0)
- tn
number of time steps to plot, starting at 0, if None and dt is not None run animation through all time steps, spaced dt within [t0, tn] (Default value = None)
- dt
time step size, if None and tn is not None computed as (t1- t0) / tn otherwise set to 1 if dt and tn are both None, t0 and t1 are ignored and solution is animated as if in time 0 … ntime_steps (Default value = None)
- exact
(Default value = lambda x)
- t: 0
- delay
(Default value = None)
- polar
(Default value = False)
- Returns:
- anim_dofsanimation object of DOFs,
- anim_reconanimation object of reconstructed solution
- sfepy.discrete.dg.dg_1D_vizualizer.head(l)[source]¶
Maybe get head of the list.
- Parameters:
- lindexable
- Returns:
- headfirst element in l or None is l is empty
- sfepy.discrete.dg.dg_1D_vizualizer.load_1D_vtks(fold, name)[source]¶
Reads series of .vtk files and crunches them into form suitable for plot10_DG_sol.
Attempts to read modal cell data for variable mod_data. i.e.
?_modal{i}
, where i is number of modal DOFResulting solution data have shape:
(order, nspace_steps, ntime_steps, 1)
- Parameters:
- fold
folder where to look for files
- name
used in
{name}.i.vtk, i = 0,1, ... tns - 1
- Returns:
- coorsndarray
- mod_datandarray
solution data
- sfepy.discrete.dg.dg_1D_vizualizer.load_state_1D_vtk(name)[source]¶
Load one VTK file containing state in time
- Parameters:
- namestr
- Returns:
- coorsndarray
- undarray
- sfepy.discrete.dg.dg_1D_vizualizer.plot1D_legendre_dofs(coors, dofss, fun=None)[source]¶
Plots values of DOFs as steps
- Parameters:
- coors
coordinates of nodes of the mesh
- dofss
iterable of different projections’ DOFs into legendre space
- fun
analytical function to plot (Default value = None)
- sfepy.discrete.dg.dg_1D_vizualizer.plotsXT(Y1, Y2, YE, extent, lab1=None, lab2=None, lab3=None)[source]¶
Plots Y1 and Y2 to one axes and YE to the second axes, Y1 and Y2 are presumed to be two solutions and YE their error
- Parameters:
- Y1
solution 1, shape = (space nodes, time nodes)
- Y2
solution 2, shape = (space nodes, time nodes)
- YE
soulutio 1 - soulution 2||
- extent
imshow extent
- lab1
(Default value = None)
- lab2
(Default value = None)
- lab3
(Default value = None)
- sfepy.discrete.dg.dg_1D_vizualizer.reconstruct_legendre_dofs(coors, tn, u)[source]¶
Creates solution and coordinates vector which when plotted as
plot(xx, ww)
represent solution reconstructed from DOFs in Legendre poly space at cell borders.
Works only as linear interpolation between cell boundary points
- Parameters:
- coors
coors of nodes of the mesh
- u
vectors of DOFs, for each order one, shape(u) = (order, nspace_steps, ntime_steps, 1)
- tn
number of time steps to reconstruct, if None all steps are reconstructed
- Returns:
- wwndarray
solution values vector, shape is (3 * nspace_steps - 1, ntime_steps, 1),
- xxndarray
corresponding coordinates vector, shape is (3 * nspace_steps - 1, 1)
- sfepy.discrete.dg.dg_1D_vizualizer.save_animation(anim, filename)[source]¶
Saves animation as .mp4, requires ffmeg package
- Parameters:
- anim
animation object
- filename
name of the file, without the .mp4 ending
- sfepy.discrete.dg.dg_1D_vizualizer.save_sol_snap(Y, X, T, t0=0.5, filename=None, name=None, ylims=None, labs=None, plott=None)[source]¶
Wrapper for sol_frame, saves the frame to file specified.
- Parameters:
- name
name of the solution e.g. name of the solver used (Default value = None)
- filename
name of the file, overrides automatic generation (Default value = None)
- Y
solution, array |T| x |X| x n, where n is dimension of the solution
- X
space interval discetization
- T
time interval discretization
- t0
time to take snap at (Default value = .5)
- ylims
limits for y axis, default are 10% offsets of Y extremes
- labs
labels to use for parts of the solution (Default value = None)
- plott
plot type - how to plot data: tested plot, step (Default value = None)
- Returns:
- fig
- sfepy.discrete.dg.dg_1D_vizualizer.setup_axis(X, Y, ax=None, fig=None, ylims=None)[source]¶
Setup axis, including timer for animation or snaps
- Parameters:
- X
space disctretization to get limits
- Y
solution to get limits
- ax
ax where to put everything, if None current axes are used (Default value = None)
- fig
fig where to put everything, if None current figure is used (Default value = None)
- ylims
custom ylims, if None y axis limits are calculated from Y (Default value = None)
- Returns:
- ax
- fig
- time_text
object to fill in text
- sfepy.discrete.dg.dg_1D_vizualizer.setup_lines(ax, Yshape, labs, plott)[source]¶
Sets up artist for animation or solution snaps
- Parameters:
- ax
axes to use for artist
- Yshapetuple
shape of the solution array
- labslist
labels for the solution
- plottstr (“steps” or “plot”)
type of plot to use
- Returns:
- lines
- sfepy.discrete.dg.dg_1D_vizualizer.sol_frame(Y, X, T, t0=0.5, ax=None, fig=None, ylims=None, labs=None, plott=None)[source]¶
Creates snap of solution at specified time frame t0, basically gets one frame from animate1D_dgsol, but colors wont be the same :-(
- Parameters:
- Y
solution, array |T| x |X| x n, where n is dimension of the solution
- X
space interval discetization
- T
time interval discretization
- t0
time to take snap at (Default value = .5)
- ax
specify axes to plot to (Default value = None)
- fig
specifiy figure to plot to (Default value = None)
- ylims
limits for y axis, default are 10% offsets of Y extremes
- labs
labels to use for parts of the solution (Default value = None)
- plott
plot type - how to plot data: tested plot, step (Default value = None)
- Returns:
- fig