pencil.diag =========== .. py:module:: pencil.diag .. autoapi-nested-parse:: Diagnostic scripts and functions Submodules ---------- .. toctree:: :maxdepth: 1 /code/sourcePython/pencil/diag/fixed_points/index /code/sourcePython/pencil/diag/gas_alpha/index /code/sourcePython/pencil/diag/particle/index /code/sourcePython/pencil/diag/tracers/index Classes ------- .. autoapisummary:: pencil.diag.Tracers pencil.diag.TracersParameterClass pencil.diag.FixedPoint pencil.diag.DiffusionData Functions --------- .. autoapisummary:: pencil.diag.diffusion pencil.diag.dispersion_and_drift pencil.diag.gas_velo_at_particle_pos pencil.diag.gas_alpha Package Contents ---------------- .. py:class:: Tracers Bases: :py:obj:`object` Tracers -- Holds the traced tracer object with the field line integrated quantities and the mapping. Fill members with default values. .. py:attribute:: params .. py:attribute:: x0 :value: None .. py:attribute:: y0 :value: None .. py:attribute:: x1 :value: None .. py:attribute:: y1 :value: None .. py:attribute:: z1 :value: None .. py:attribute:: l :value: None .. py:attribute:: tracers :value: None .. py:attribute:: mapping :value: None .. py:attribute:: t :value: None .. py:attribute:: aa :value: None .. py:attribute:: ee :value: None .. py:attribute:: curly_A :value: None .. py:attribute:: splines :value: None .. py:method:: find_tracers(var_file='VAR0', datadir='data', trace_field='bb', ti=-1, tf=-1) Trace streamlines of the vectofield 'field' from z = z0 to z = z1 and integrate quantities 'int_q' along the lines. Creates a 2d mapping as in 'streamlines.f90'. call signature: find_tracers(var_file='VAR0', datadir='data', trace_field='bb', ti=-1, tf=-1) Keyword arguments: *var_file*: Varfile to be read. *datadir*: Directory where the data is stored. *trace_field*: Vector field used for the streamline tracing. *ti*: Initial VAR file index for tracer time sequences. Overrides 'var_file'. *tf*: Final VAR file index for tracer time sequences. Overrides 'var_file'. .. py:method:: write(datadir='data', destination='tracers.hdf5') Write the tracers into a file. call signature:: write(self, datadir='data', destination='tracers.hdf5') Keyword arguments: *datadir*: Directory where the data is stored. *destination*: Destination file. .. py:method:: read(datadir='data', file_name='tracers.hdf5') Read the tracers from a file. call signature: read(self, datadir='data', file_name='tracers.hdf5') Keyword arguments: *datadir*: Directory where the data is stored. *file_name*: File with the tracer data. .. py:class:: TracersParameterClass Bases: :py:obj:`object` __TracersParameterClass -- Holds the simulation and tracing parameters. Initialize the parameters. .. py:attribute:: dx :value: 0 .. py:attribute:: dy :value: 0 .. py:attribute:: dz :value: 0 .. py:attribute:: Ox :value: 0 .. py:attribute:: Oy :value: 0 .. py:attribute:: Oz :value: 0 .. py:attribute:: Lx :value: 0 .. py:attribute:: Ly :value: 0 .. py:attribute:: Lz :value: 0 .. py:attribute:: nx :value: 0 .. py:attribute:: ny :value: 0 .. py:attribute:: nz :value: 0 .. py:attribute:: trace_field :value: '' .. py:attribute:: rtol :value: 1e-08 .. py:attribute:: atol :value: 1e-08 .. py:attribute:: periodic_x :value: False .. py:attribute:: periodic_y :value: False .. py:attribute:: periodic_z :value: False .. py:attribute:: interpolation :value: 'trilinear' .. py:attribute:: method :value: 'RK45' .. py:attribute:: trace_sub :value: 1 .. py:attribute:: int_q :value: '' .. py:attribute:: var_file :value: 'VAR0' .. py:attribute:: ti :value: -1 .. py:attribute:: tf :value: -1 .. py:attribute:: datadir :value: 'data' .. py:attribute:: destination :value: 'tracers.hdf5' .. py:attribute:: n_proc :value: 1 .. py:class:: FixedPoint Bases: :py:obj:`object` FixedPoint -- Holds the fixed points and additional integrated quantities. Fill members with default values. .. py:attribute:: params .. py:attribute:: t :value: None .. py:attribute:: fixed_index :value: None .. py:attribute:: fixed_points :value: None .. py:attribute:: fixed_tracers :value: None .. py:attribute:: fixed_sign :value: None .. py:attribute:: poincare :value: None .. py:attribute:: tracers :value: None .. py:method:: find_fixed(datadir='data', var_file='VAR0', trace_field='bb', ti=-1, tf=-1, tracer_file_name=None) Find the fixed points to a snapshot or existing tracer file. call signature:: find_fixed(datadir='data', var_file='VAR0', trace_field='bb', ti=-1, tf=-1, tracer_file_name=None): :keyword \*datadir*: Data directory. *var_file*: Varfile to be read. *trace_field*: Vector field used for the streamline tracing. *ti*: Initial VAR file index for tracer time sequences. Overrides 'var_file'. *tf*: Final VAR file index for tracer time sequences. Overrides 'var_file'. *tracer_file_name* Name of the tracer file to be read. If 'None' compute the tracers. .. py:method:: write(datadir='data', destination='fixed_points.hdf5') Write the fixed points into a file. call signature:: write(self, datadir='data', destination='fixed_points.hdf5') Keyword arguments: *datadir*: Directory where the data is stored. *destination*: Destination file. .. py:method:: read(datadir='data', file_name='fixed_points.hdf5', quiet=True) Read the fixed points from a file. call signature:: read(self, datadir='data', file_name='fixed_points.hdf5') Keyword arguments: *datadir*: Directory where the data is stored. *file_name*: File with the tracer data. *quiet*: Suppress warnings. .. py:function:: diffusion(directions=['x'], trange=[0, -1], sim='.', OVERWRITE=False, quiet=True, jump_distance=0.5, use_existing_pstalk_sav=False) Calculate particle diffusion via stalked particles: PSTALK Therefore, it read PSTALK files from Pencil Code using IDL by using the IDL<->Python Bridge. It may be activated manually! Generated DiffusionData object will be stored in: sim.pc_datadir/particle/diffusion/_: and be reloaded and returned if already existing and OVERWRITE=False! :param - sim: simulation object, but also simulations object or list of simulations or path of simulation, default ='.' :param - directions list or directions to calculate diffusion for: default =['x'] :param e.g. ['x': default =['x'] :param 'y': default =['x'] :param 'z']: default =['x'] :param : default =['x'] :param - trange range in code time for which diffusion shall be calc.: default =[0, -1] :param - jump_distance expressed in L_: half the domain size :type - jump_distance expressed in L_: x,y,z :param - OVERWRITE previously calculated diffusions shall be overwritten: default =False :param - quiet verbosity: :param default =False: :param - use_existing_pstalk_sav: use existing /data/pc/tmp/pstalk.sav for speed up :returns: diffusion object for simulation, if function is called for a set of simulations, a dictionary with all diffusion objects and simulation-name as key is returned .. py:class:: DiffusionData(direction='x', trange=[0, -1], sim='.', OVERWRITE=False, quiet=True, jump_distance=0.5, use_existing_pstalk_sav=False) Bases: :py:obj:`object` DiffusionData -- holds diffusion data for particles. .. py:function:: dispersion_and_drift(sim=False, OVERWRITE=False, GLOBAL=True, LOCAL=True, use_IDL=False, recalculate_gas_velo_at_particle_pos=False) This calculates the dispersion (sigma) and drift (zeta) locally and globally by using the gas_velo_at_particle_pos script and dataset for all particles. With sigma = sqrt( 1/N_par * sum_i^N_par( (v_par(i) - )^2 ) ) and zeta = sqrt( 1/N_par * sum_i^N_par( (v_par(i) - u(xp_i))^2 ) ) Arg: OVERWRITE: set to True to overwrite already calculated results GLOBAL: Calculate drift and dispersion globally, i.e. whole simulation domain LOCAL: Calculate drift and dispersion locally, i.e. grid cell wise recalculate_gas_velo_at_particle_pos: if the dataset shall be recalcualted use_IDL: use backup solution of IDL script and sav files returns True if successfull .. py:function:: gas_velo_at_particle_pos(varfiles='last4', sim=False, scheme='tsc', use_IDL=False, OVERWRITE=False) This script calulates the gas velocity at the particle position and stores this together with particle position, containing grid cell idicies, particle velocities, and particle index in a gas_velo_at_particle_pos file. :param varfiles: specifiy varfiles for calculation, e.g. 'last', 'first', 'all', 'VAR###', 'last4', 'first3' :param scheme: possible are: - ngp: nearest grid point - cic: cloud in cell - tsc: triangular shaped cloud :param OVERWRITE: set to True to overwrite already calculated results .. py:function:: gas_alpha(sim=False, t_range=[0, -1], OVERWRITE=False) This calculates the global alpha-value from ts object via alphah=(2./3.)*(ts3.uxuym)/(ts3.rhom*ts3.csm**2) for the lastNentries of the time series. Input: t_range use this time range of the timeseries OVERWRITE overwrite alpha file in sim.pc_datadir/alpha_ :returns: alpha dictionary