Example #1
0
def wvfaxs(): 
    """
    Plot axis for wavefunction.
    """
    wvfax = vp.curve(pos = [(-200, -155), (800, -155)], vp.display = wvgraph, color=color.cyan)
    vp.curve(pos=[(-200, -150), (-200, 400)], color=color.cyan, vp.display=wvgraph)
    vp.label(pos=(-70, 420), text="Probability", box = 0, vp.display=wvgraph)
    vp.label(pos=(-200, -220), text="0", box = 0, vp.display=wvgraph)
    vp.label(pos=(600, -220), text="x", box = 0, vp.display=wvgraph)
Example #2
0
def wvfaxs() :     
    """
    Axis for probability plot.
    """
    wvfax = vp.curve(pos =[(−600,−155),(800,−155)], vp.display=wvgraph,color=color.cyan)
    vp.curve(pos = [(0,−150), (0,400)], vp.display=wvgraph, color=color.cyan)
    vp.label(pos = (−80,450), text="Probability", box = 0, vp.display = wvgraph)
    vp.label(pos = (600,−220) , text="x", box=0, vp.display=wvgraph)
    vp.label(pos = (0, -220), text="0", box=0, vp.display=wvgraph)
Example #3
0
def trjaxs(): 
    """
    Plot trajectory axes.
    """
    trax = vp.curve(pos=[(-97, 100), (100, -100)], color=color.cyan, vp.display=trajec)
    vp.curve(pos=[(-65, -100), (-65, 100)], color=color.cyan, vp.display=trajec)
    vp.label(pos=(-65, 110), text="t", box = 0, vp.display=trajec)
    vp.label(pos=(-85, -100), text="0", box = 0, vp.display=trajec)
    vp.label(pos=(60, -110), text="x", box = 0, vp.display=trajec)
Example #4
0
def plotfunction(): # Plot the function and the box
    inc = 2*np.pi/N
    for i in range(0, N):
        xx = i*incr
        xsinx.x[i] = ((80/np.pi)*xx-80)
        xsinx.y[i] = 20*fx(xx)-50
        box = curve(pos=[(-80, -50), (-80, 50), (80, 50), (80, -50), (-80, -50)], color=color.white)
Example #5
0
def trjaxs():
    trax = vp.curve(pos=[(-97, -100), (100, -100)], color=color.cyan, vp.display = trajec)
    vp.label(pos = (0,−110), text = "0", box = 0, vp.display = trajec)
    vp.label(pos = (60,−110), text = "x", box = 0, vp.display = trajec)
Example #6
0
import numpy as np
import vpython.graph as vp

"""
Determine the ground-state probabilty via a Feynman path integration
using the Metropolis algorithm to simulate variations about the classical trajectory
"""

N = 100
M = 101
xscale = 10
path = np.zeros([M], float)
prob = np.zeros([M], float)

trajec = vp.display(width=300, height=500, title="Spacetime Trajectories")
trplot = vp.curve(y=range(0, 100), color=color.magenta, vp.display=trajec)

def trjaxs():
    trax = vp.curve(pos=[(-97, -100), (100, -100)], color=color.cyan, vp.display = trajec)
    vp.label(pos = (0,−110), text = "0", box = 0, vp.display = trajec)
    vp.label(pos = (60,−110), text = "x", box = 0, vp.display = trajec)

wvgraph = vp.display(x=340,y=150,width=500,height=300, title="Ground State")
wvplot = vp.curve(x = range(0, 100), vp.display = wvgraph)
wvfax = vp.curve(color = color.cyan)

def wvfaxs() :     
    """
    Axis for probability plot.
    """
    wvfax = vp.curve(pos =[(−600,−155),(800,−155)], vp.display=wvgraph,color=color.cyan)
Example #7
0
import random
import numpy as np

from vpython.graph import curve, display, label

"""
Monte Carlo integration via stone throwing. A classical example 
of the Monte Carlo integration approach is to determine the area 
of a circular "pond" by throwing stones into it. 
"""

N = 100 # points to plot the function
graph = display(width=500, height=500, title="vonNeumann Rejection Int")
xsinx = curve(x=list(range(0,N)) color=color.yellow, radius=.5) # generate sine curve
pts = label(pos=(-60, -60), text="points=", box=0) # graphics
pts2 = label(pos=(-30, -60), box=0)
inside = label(pos=(30, -60), text="accepted=", box=0)
inside2 = label(pos=(60, -60), box=0)
arealbl = label(pos=(-65,60), text="area=", box=0)
arealbl2 = label(pos=(-35, 60), box=0)
areanal = label(pos(30, 60), text="analytical=", box=0)
zero = label(pos=(-85, -48), text="0", box=0)
five = label(pos=(-85, 50), text="5", box=0)
twopi = label(pos=(90, -48), text="2pi", box=0)

def fx(x): 
    """
    Integrand over which we integrate.
    """
    return x*np.sin(x)*np.sin(x)