Skip to content
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Analysis & Postprocessing
  4. Calculate Divergence of B field

Calculate Divergence of B field

Scheduled Pinned Locked Moved Analysis & Postprocessing
1 Posts 1 Posters 701 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tiwwexx
    wrote on last edited by
    #1

    Hello! I'm trying to compute the divergence of the B field in a simulation to double check that it is 0.
    To do this I export out an overall field sensor B(x,y,z,f0) to matlab, read it in, use the cell centers convention
    (axis_n(1)+axis_n(2))/2
    to reshape the data into an ndgrid

    x_pos= (a.Axis0(1:end-1)+a.Axis0(2:end))/2;
    y_pos= (a.Axis1(1:end-1)+a.Axis1(2:end))/2;
    z_pos= (a.Axis2(1:end-1)+a.Axis2(2:end))/2;
    [x,y,z] = ndgrid(x_pos,y_pos,z_pos);
    

    and a 4D array (x,y,z,3) where the 4th dimension is the Bx,By,Bz components.

    B_field =  reshape(a.Snapshot0,numel(x_pos),numel(y_pos),numel(z_pos),[]);
    

    I then get the divergence of my b field as

    div_b = divergence(y,x,z,B_field(:,:,:,1),B_field(:,:,:,2),B_field(:,:,:,3))
    

    When looking at this field (shown below) it is clearly not 0 everywhere which somewhat confused me. I verified that my B_flux through different square and spherical surfaces was equal to 0 in the analysis tab which I thought should directly translate to div_b ~ 0 everywhere.

    Any suggestions on why this didn't work would be much appreciated!
    b0fb234b-8d80-4980-937e-3967b6e82d6c-image.png
    0ec7867c-8831-4e92-882b-15d004d1b125-image.png

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Search