Package: pylevis
pyLEVIS<<<<<<< HEAD
!!! THIS README AND PACKAGE IS STILL INCOMPLETE !!!Python implementation of the VENUS-LEVIS MATLAB routines. Most of the routines have the same names so the functions should be familiar.You should be in the direction in which your runs are located to read them in, for instancepath/to/levis/runs.Python implementation of the VENUS-LEVIS matlab routines.setupInstallation<<<<<<< HEADExamplesExample: Reading in a simulation and plotting=======
Can be download from PyPI bysetuppip3installpylevis<<<<<<< HEAD
Reading the simulation is similar to the old scripts, except we no longer useMercuryto read data in, also that reading in the simulation will still work if we append "prob" to the name, or we can choose to omit it:# Read in some simulationsim=pylevis.simulation("probSPEC.0")# which is equivalent tosim=pylevis.simulation("SPEC.0")A warning that if you have two runs, one called "probSPEC" and another called "SPEC", this may cause issues reading them in.Retrieving the particles data is the same as with the matlab routines:sim.GetParticle()although we can now also choose to read in only certain particles (indexed from 1, since that's how the file naming convention is):sim.GetParticle(parts=[1,5,6])note that to access the particles the indexing starts from 0 as per python, sosim.sp[0]is particle 1.Plotting the energy/momentum conservation is also the same as with the MATLAB routines:sim.plot_spconservation()Note: If a particle number does not exist insim.spit will be skipped and the user will be warned that some were not plotted, rather than returning an error like in MATLAB.Example: Creating a new simulation (experimental)This is experimental at the moment, but a new simulation can be initialised by calling:importpylevisf=pylevis.new_simulation('SimulationName',nparts,eqfile="path/to/equilibrium",eqtype="spec",exedir="path/to/mercuryandpostprocessing.x",machine="local")The equilibrium type can be changed by specifyingeqtype=""(default and only supported at the moment is"spec"), the machine you are running the simulation on should be set withmachine=,if this is your own computer, it should be"local"(more info below). By default,new_simulationwill set up default simulation settings innew_simulation.data, you can check the current config with,f.data.properties()All properties are stored in dictionaries, for instance if we wanted to change the simulation duration we would setf.data["tfin"]=1e-5(do not changef.data["nparts"]as this isn't actually used except to generate the data file and will be overwritten upon write).
A distribution (only uniformly sampled at the moment) of particles withf.npartsnumber of particles and and by specifying the range or value of input values can be generated, for instance the following:f.generate_particles([0.1,1.9],0,0,1,[5e2,2e3],1,1,1)will generate particles, with $s\in[0.1,1.9]$ and $E\in[5e2,2e3]$ randomly generated, and all other values set as given. The required simulation files can then all be created at the location set byf.simdirby calling,f.create_simulation()If the location already exists you will be prompted to provide the optional inputoverwrite=True, this will delete existing files and remake them. Finally, we can run the simulation from the python tools as well,f.run_simulation()How the simulation is called depends on the value off.machine=""(default is"local") (your local machine).ConfigCurrent machine configslocal (calls./mercury.x < data)
=======UsageYou can load the package the usual way (for python packages) by runningimportpylevisExamples for running the code can be found in ./docs on the github page (see link below).Developer(s)Dean MuirsetupGithub<<<<<<< HEADProgressTO DOFunctionPurposeGet_DiffusivityDecryptEquilibriumCalls UnfoldEquilibrium?UnfoldEquilibriumReads in equilibrium?Equilibrium reconstruction interface for many equilibrium codesGetParScenicReads inscenic.infileGetBGGets background profilesGetLostParticlesWhat a poorly written fileGet_MomentsGets moments(?) and trapped(?) informationIncompleteFunctionSubfunctionsGetParGet_Diffusivity_ParamsGet_Dist -> Get_ParticleDistCompletedOriginalNewGet_Particle=======
The source code can be found athttps://github.com/Spiffmeister/pyLEVISsetup