Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • wdata wdata
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4
    • Issues 4
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • wtools
  • wdatawdata
  • Wiki
    • Examples
  • Python examples

Python examples · Changes

Page history
Update Python examples authored Jan 19, 2022 by Gabriel Wlazłowski's avatar Gabriel Wlazłowski
Hide whitespace changes
Inline Side-by-side
Examples/Python-examples.md
View page @ 6717793e
......@@ -81,4 +81,55 @@ fig.savefig("rho_a.png")
plt.show()
```
The result of this example:
![rho_a](uploads/af555a49c8279e60d1ca1186af98ff9b/rho_a.png)
\ No newline at end of file
![rho_a](uploads/af555a49c8279e60d1ca1186af98ff9b/rho_a.png)
# Cross section of velocity field for quantum vortex
```python
#!/usr/bin/python3
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from scipy.interpolate import interp1d
from wdata.io import WData, Var
# This data set contains vortex solution of SLADE functional.
# It is provided as supplementary material of publication:
# todo
fwtxt="/home/gabrielw/Desktop/st-vortex/sv-ddcc05p00-T0p05.wtxt"
data = WData.load(fwtxt)
j_a = data.j_a[-1] # last frame
rho_a = data.rho_a[-1] # last frame
x = data.xyz[0]
sec=int(data.Nxyz[0]/2)
j_a = j_a[0,sec,:] # extract x component of j_a along y axis for x=Nx/2 (center of box)
rho_a = rho_a[sec,:] # extract rho_a along y axis for x=Nx/2 (center of box)
vs = np.abs(j_a/rho_a) # computer velocity (absolute value)
# interpolate data
vs_int = interp1d(x[:,0], vs, kind='quadratic')
newx=np.linspace(-20,20,200)
# flow for ideal vortex
r = np.linspace(3,40,100) # take range [3-40]
vs_ideal = 0.5 / r # vs=1/2r (m=hbar=1, and factor 2 accounts for Cooper pairs)
# plot
fig, ax = plt.subplots()
ax.plot(x, vs, 'bo', markersize=3, label='data')
ax.plot(newx, vs_int(newx), 'b', linestyle="-")
ax.plot(r, vs_ideal, color="k", linestyle="--", label=r'$\sim 1/r$')
ax.plot(r*(-1.0), vs_ideal, color="k", linestyle="--")
ax.set(xlabel='y', ylabel=r'$v(0,y)$')
ax.set_xlim([-20,20])
ax.grid()
plt.legend(loc='upper right')
fig.savefig("velocity.png")
plt.show()
```
Output
![velocity](uploads/a7f74f745d9abda5630bac010ca1b666/velocity.png)
\ No newline at end of file
Clone repository
  • Data types
  • Examples
    • C examples
    • Python examples
  • Tags
  • VisIt plugin compilation
  • Visit integration
  • Home
  • wdata format concept