How to use the underworld.function.math.sqrt function in underworld

To help you get started, we’ve selected a few underworld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github underworldcode / underworld2 / docs / examples / 1_03_BlankenbachBenchmark.py View on Github external
# In[20]:

figtemp = glucifer.Figure()
figtemp.append( glucifer.objects.Surface( mesh, pressureField ) )
figtemp.show()


# **Plot the velocity vector field**
# 
# For this example the velocity field is interesting to see. This is visualised in two ways, firstly plotting a surface colour map of the velocity magnitude, and secondly the velocity vectors at points on the mesh. For aesthetics the vector arrows are scaled by a little more than the maximum $v_{rms}$ value found in the time loop above.

# In[21]:

fig2 = glucifer.Figure()
velmagfield = uw.function.math.sqrt( uw.function.math.dot( velocityField, velocityField ) )
fig2.append( glucifer.objects.VectorArrows(mesh, velocityField/(2.5*velplotmax), arrowHead=0.2, scaling=0.1) )
fig2.append( glucifer.objects.Surface(mesh, temperatureField) )
fig2.show()


# Parallel friendly post analysis
# ----
# 
# When running underworld in parallel the data of each mesh variable is spread across all the processors. However often we will want to calculate a quantity based on data at specific points that may not all be on the same processor.
# 
# A solution is presented here which consists of saving the data from all processors to file, then reloading the mesh variable data using a new non-partitioned mesh. This enables all the data to be available to each processor. We will the carry out the post analysis using the first processor.

# **Save temperature, pressure and velocity data**
# 
# Save the basic mesh variable data to files using the HDF5 format. This is the same file type as is loaded above.
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_unitvec_tangent(self):
        # returns the radial position
        pos = fn.coord()
        centre = self._centroid
        r_vec = pos - centre
        theta = [-1.0*r_vec[1], r_vec[0]]
        mag = fn.math.sqrt(fn.math.dot( theta, theta ))
        theta = theta / mag
        return theta
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_unitvec_radial(self):
        # returns the radial position
        pos = fn.coord()
        centre = self._centroid
        r_vec = pos - centre
        mag = fn.math.sqrt(fn.math.dot( r_vec, r_vec ))
        r_vec = r_vec / mag
        return r_vec
github underworldcode / underworld2 / docs / examples / 1_05_StokesSinker.py View on Github external
# **Plot the final particle positions**

# In[18]:

fig1.show()


# **Plot velocity field**
# 
# Plot the velocity field in the fluid induced by the motion of the sinking ball.

# In[19]:

velplotmax=0.02
fig3 = glucifer.Figure( figsize=(800,400) )
velmagfield = uw.function.math.sqrt( uw.function.math.dot(velocityField,velocityField) )
fig3.append( glucifer.objects.VectorArrows(mesh, velocityField/(1.5*velplotmax), arrowHead=0.2, scaling=0.15) )
fig3.append( glucifer.objects.Surface(mesh, velmagfield) )
fig3.show()
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_r_theta(self):
        pos = fn.coord() - self._centroid
        rFn = fn.math.sqrt(pos[0]**2 + pos[1]**2)
        thetaFn = fn.math.atan2(pos[1],pos[0])
        return rFn, thetaFn
github underworldcode / underworld2 / unsupported / geodynamics / rheology.py View on Github external
def _get_yieldStress3D(self):
        f = self._friction
        C = self._cohesion
        P = self.pressureField
        self.yieldStress = 6.0*C*fn.math.cos(f) + 2.0*fn.math.sin(f)*fn.misc.max(P, 0.0) 
        self.yieldStress /= (fn.math.sqrt(3.0) * (3.0 + fn.math.sin(f)))
        return self.yieldStress
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_unitvec_lat(self):
        pos = fn.coord()
        # r = fn.math.sqrt(pos[0]**2 + pos[1]**2 + pos[2]**2)
        r = fn.math.sqrt(fn.math.dot( pos, pos ))
        colat = fn.math.acos(pos[0]/r)
        lon   = fn.math.atan2(pos[2],pos[1])

        vec  = -fn.math.cos(colat) * fn.math.cos(lon) * (0.0, 1.0, 0.0)
        vec += -fn.math.cos(colat) * fn.math.sin(lon) * (0.0, 0.0, 1.0)
        vec +=  fn.math.sin(colat) * (1.0, 0.0, 0.0)
        return vec
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_unitvec_r(self):
        pos = fn.coord()
        mag = fn.math.sqrt(fn.math.dot( pos, pos ))
        r_vec = pos / mag
        return r_vec