Vector Calculus with Python - Gradient, Div, Curl, Stokes, Divergence

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 8

  • @aryan5015
    @aryan5015 2 года назад +6

    You are doing amazing work sirrr.... Please keep it up...

  • @johnjohn-ed9qt
    @johnjohn-ed9qt 2 года назад

    Nice. I have been using your Python/Vpython vids for several years with my students, and this will definitely be added o the list. Side note: nabla was chosen as the formal name for the symbol (typesetting, 'del' being the operator name, in the same sense as octothorpe is the name for symbol '#', though it has many names in application) due to the resemblance to a form of phoenician harp. Yes, I know this due to one of my undergrad profs. Yes, I make sure my student know it. And, yes, I read it as 'del dot F' and 'del cross F'. The same prof was a pedant about the dot and cross product forms for divergence and curl. 'It is not a full-fledged vector! You can not treat it as one!'

  • @johnh.g.weisenfeld1112
    @johnh.g.weisenfeld1112 2 года назад +2

    I put something like this in every time you do 3D visualizations to indicate axes.
    #put arrows for the axes...as a reference.
    axisscale = 0.1
    xaxis = arrow(pos=vector(0,0,0),shaftwidth=.1*axisscale,
    axis=axisscale*vector(1,0,0),label="x",color=color.purple)
    yaxis = arrow(pos=vector(0,0,0),shaftwidth=.1*axisscale,
    axis=axisscale*vector(0,1,0),label="y",color=color.red)
    zaxis = arrow(pos=vector(0,0,0),shaftwidth=.1*axisscale,
    axis=axisscale*vector(0,0,1),label="z",color=color.green)

  • @TadThurston
    @TadThurston 2 года назад +1

    Nice job! Great visualization.

  • @HH-mw4sq
    @HH-mw4sq 2 года назад

    Could you please post the full code for the Path Integral, Flux, Stokes theorem, hemisphere, volume integral, and divergence theorem?

  • @러블리민희
    @러블리민희 Год назад +3

    if 'I' wanna implement this on Python, you have to use np.array([x, y, z]) not using vector(x, y, z)
    The following code is the gradient code on Python:
    # Gradient
    # g(x, y, z) = y * z^2 * sin(x)
    from math import sin
    import numpy as np
    def g(p):
    return p[1] * p[2]**2 * sin(p[0])
    def gradg(p):
    ds = 0.001
    dx = np.array([ds, 0, 0])
    dy = np.array([0, ds, 0])
    dz = np.array([0, 0, ds])
    # dg/dx, dg/dy, dg/dz
    # dg/dx = (g(x+Δx) - g(x-Δx)) / 2Δx
    # dg/dy = (g(y+Δz) - g(y-Δz)) / 2Δy
    # dg/dz = (g(y+Δz) - g(y-Δz)) / 2Δz
    # Δx = Δx = Δx = ds = 0.001 --> very small
    gx = (g(p + dx) - g(p - dx)) / (2*ds)
    gy = (g(p + dy) - g(p - dy)) / (2*ds)
    gz = (g(p + dz) - g(p - dz)) / (2*ds)
    return np.array([gx, gy, gz])
    rt = np.array([1,1,1])
    print("g(1,1,) = ", g(rt))
    print("Delg(1,1,1) = ", gradg(rt))
    # Divergence
    def F(p):
    return np.array([p[0]**2 * p[1], 2**p[0] * p[2], p[2]**2 - 2*p[1]])
    def divF(p):
    ds = 0.001
    dx = np.array([ds, 0, 0])
    dy = np.array([0, ds, 0])
    dz = np.array([0, 0, ds])

    tempx = (F(p+dx)[0] - F(p-dx)[0]) / (2*ds)
    tempy = (F(p+dy)[1] - F(p-dy)[1]) / (2*ds)
    tempz = (F(p+dz)[2] - F(p-dz)[2]) / (2*ds)
    return tempx + tempy + tempz
    rt = np.array([1,1,1])
    print("F(1,1,-1) = ", F(rt))
    print("DelF(1,1,1) = ", divF(rt))

    • @DotPhysics
      @DotPhysics  Год назад

      it's way more awkward using vectors in normal python. You could also just do from vpython import vector (and mag and norm and stuff like that). I should work.

  • @HH-mw4sq
    @HH-mw4sq 2 года назад

    Could you please post the full code for the Path Integral, Flux, Stokes theorem, hemisphere, volume integral, and divergence theorem?