예제 #1
0
def test():

    sim = Simulation()  # Create a simulation object

    # Geometry and Model Equations
    sim.geomx = 'walls'
    sim.geomy = 'walls'
    sim.stepper = Step.AB3
    sim.method = 'Spectral'
    sim.dynamics = 'Nonlinear'
    sim.flux_method = Flux.spectral_sw

    # Specify paramters
    sim.Lx = 4000e3
    sim.Ly = 4000e3
    sim.Nx = 128
    sim.Ny = 128
    sim.Nz = 1
    sim.g = 9.81
    sim.f0 = 1.e-4
    sim.beta = 0e-11
    sim.cfl = 0.1
    sim.Hs = [100.]
    sim.rho = [1025.]
    sim.end_time = 5. * minute

    sim.animate = 'None'
    sim.output = False
    sim.diagnose = False

    # Initialize the grid and zero solutions
    sim.initialize()

    for ii in range(sim.Nz):  # Set mean depths
        sim.soln.h[:, :, ii] = sim.Hs[ii]

    # Gaussian initial conditions
    W = 200.e3  # Width
    amp = 1.  # Amplitude
    sim.soln.h[:, :, 0] += amp * np.exp(-(sim.X / W)**2 - (sim.Y / W)**2)

    # Run the simulation
    sim.run()
예제 #2
0
import numpy as np
import matplotlib.pyplot as plt
import sys

# Add the PyRsw tools to the path
# At the moment it is given explicitely.
# In the future, it could also be added to the
# pythonpath environment variable
sys.path.append('../src')

import Steppers as Step
import Fluxes as Flux
from PyRsw import Simulation
from constants import minute, hour, day

sim = Simulation()  # Create a simulation object
sim.run_name = '2D GeoAdjust'

# Geometry and Model Equations
sim.geomx       = 'periodic'       # Geometry Types: 'periodic' or 'walls'
sim.geomy       = 'periodic'
sim.stepper     = Step.AB3         # Time-stepping algorithm: Euler, AB2, RK4
sim.method      = 'Spectral'       # Numerical method: 'Spectral'
sim.dynamics    = 'Nonlinear'      # Dynamics: 'Nonlinear' or 'Linear'
sim.flux_method = Flux.spectral_sw # Flux method: spectral_sw is only option currently

# Specify paramters
sim.Lx  = 4000e3          # Domain extent               (m)
sim.Ly  = 3000e3          # Domain extent               (m)
sim.Nx  = 128               # Grid points in x
sim.Ny  = 128             # Grid points in y
예제 #3
0
import numpy as np
import matplotlib.pyplot as plt
import sys

# Add the PyRsw tools to the path
# At the moment it is given explicitely.
# In the future, it could also be added to the
# pythonpath environment variable
sys.path.append('../src')

import Steppers as Step
import Fluxes as Flux
from PyRsw import Simulation
from constants import minute, hour, day

sim = Simulation()  # Create a simulation object
sim.run_name = '1D GeoAdjust'

# Geometry and Model Equations
sim.geomy       = 'periodic'       # Geometry Types: 'periodic' or 'walls'
sim.stepper     = Step.AB3         # Time-stepping algorithm: Euler, AB2, RK4
sim.method      = 'Spectral'       # Numerical method: 'Spectral'
sim.dynamics    = 'Nonlinear'      # Dynamics: 'Nonlinear' or 'Linear'
sim.flux_method = Flux.spectral_sw # Flux method: spectral_sw is only option currently

# Specify paramters
sim.Ly  = 4000e3          # Domain extent               (m)
sim.Nx  = 1               # Grid points in x
sim.Ny  = 1024             # Grid points in y
sim.Nz  = 1               # Number of layers
sim.g   = 9.81            # Gravity                     (m/sec^2)
예제 #4
0
import numpy as np
import matplotlib.pyplot as plt
import sys

# Add the PyRsw tools to the path
# At the moment it is given explicitely.
# In the future, it could also be added to the
# pythonpath environment variable
sys.path.append('../src')

import Steppers as Step
import Fluxes as Flux
from PyRsw import Simulation
from constants import minute, hour, day

sim = Simulation()  # Create a simulation object
sim.run_name = '2D_Bickley_Jet_H500'

# Geometry and Model Equations
sim.geomx = 'periodic'  # Geometry Types: 'periodic' or 'walls'
sim.geomy = 'walls'
sim.stepper = Step.AB3  # Time-stepping algorithm: Euler, AB2, RK4
sim.method = 'Spectral'  # Numerical method: 'Spectral'
sim.dynamics = 'Nonlinear'  # Dynamics: 'Nonlinear' or 'Linear'
sim.flux_method = Flux.spectral_sw  # Flux method: spectral_sw is only option currently

# Specify paramters
sim.Lx = 200e3  # Domain extent               (m)
sim.Ly = 200e3  # Domain extent               (m)
sim.Nx = 128  # Grid points in x
sim.Ny = 128  # Grid points in y
예제 #5
0
import numpy as np
import matplotlib.pyplot as plt
import sys

# Add the PyRsw tools to the path
# At the moment it is given explicitely.
# In the future, it could also be added to the
# pythonpath environment variable
sys.path.append("../src")

import Steppers as Step
import Fluxes as Flux
from PyRsw import Simulation
from constants import minute, hour, day

sim = Simulation()  # Create a simulation object

# Geometry and Model Equations
sim.geomy = "walls"  # Geometry Types: 'periodic' or 'walls'
sim.stepper = Step.AB3  # Time-stepping algorithm: Euler, AB2, RK4
sim.method = "Spectral"  # Numerical method: 'Spectral'
sim.dynamics = "Nonlinear"  # Dynamics: 'Nonlinear' or 'Linear'
sim.flux_method = Flux.spectral_sw  # Flux method: spectral_sw is only option currently

# Specify paramters
sim.Ly = 4000e3  # Domain extent               (m)
sim.Nx = 1  # Grid points in x
sim.Ny = 512  # Grid points in y
sim.Nz = 1  # Number of layers
sim.g = 9.81  # Gravity                     (m/sec^2)
sim.f0 = 1.0e-4  # Coriolis                    (1/sec)
예제 #6
0
import numpy as np
import matplotlib.pyplot as plt
import sys

# Add the PyRsw tools to the path
# At the moment it is given explicitely.
# In the future, it could also be added to the
# pythonpath environment variable
sys.path.append('../src')

import Steppers as Step
import Fluxes as Flux
from PyRsw import Simulation
from constants import minute, hour, day

sim = Simulation()  # Create a simulation object
sim.run_name = '1D GeoAdjust'

# Geometry and Model Equations
sim.geomy       = 'periodic'       # Geometry Types: 'periodic' or 'walls'
sim.stepper     = Step.AB3         # Time-stepping algorithm: Euler, AB2, RK4
sim.dynamics    = 'Linear'      # Dynamics: 'Nonlinear' or 'Linear'
sim.method      = 'Sadourny'       # Numerical method: 'Sadourny'
sim.flux_method = Flux.sadourny_sw # Flux method: 

# Specify paramters
sim.Lx  = 4000e3          # Domain extent               (m)
sim.Ly  = 4000e3          # Domain extent               (m)
sim.Nx  = 128               # Grid points in x
sim.Ny  = 128               # Grid points in y
sim.Nz  = 1               # Number of layers
예제 #7
0
# Add the PyRsw tools to the path
# At the moment it is given explicitely.
# In the future, it could also be added to the
# pythonpath environment variable
sys.path.append("../src")

import Steppers as Step
import Fluxes as Flux
from PyRsw import Simulation
from constants import minute, hour, day

from Stability_tools import cheb
from Stability_tools import stability_sw

sim = Simulation()  # Create a simulation object

# Geometry and Model Equations
sim.geomx = "periodic"  # Geometry Types: 'periodic' or 'walls'
sim.geomy = "walls"
sim.stepper = Step.AB3  # Time-stepping algorithm: Euler, AB2, RK4
sim.method = "Spectral"  # Numerical method: 'Spectral'
sim.dynamics = "Nonlinear"  # Dynamics: 'Nonlinear' or 'Linear'
sim.flux_method = Flux.spectral_sw  # Flux method: spectral_sw is only option currently

# Specify paramters
sim.Lx = 200e3  # Domain extent               (m)
sim.Ly = 200e3  # Domain extent               (m)
# sim.Nx  = 128             # Grid points in x
sim.Ny = 128  # Grid points in y
sim.Nz = 1  # Number of layers
예제 #8
0
def test():

    sim = Simulation()

    # Geometry and Model Equations
    sim.geomy = 'periodic'
    sim.stepper = Step.AB2
    sim.method = 'Spectral'
    sim.dynamics = 'Nonlinear'
    sim.flux_method = Flux.spectral_sw

    # Specify paramters
    sim.Ly = 4000e3
    sim.Ny = 128
    sim.cfl = 0.5
    sim.Hs = [100.]
    sim.rho = [1025.]
    sim.end_time = 5. * minute

    # Plotting parameters
    sim.animate = 'None'
    sim.output = False
    sim.diagnose = False

    # Initialize the grid and zero solutions
    sim.initialize()

    for ii in range(sim.Nz):
        sim.soln.h[:, :, ii] = sim.Hs[ii]

    # Gaussian initial conditions
    x0 = 1. * sim.Lx / 2.
    W = 200.e3
    amp = 1.
    sim.soln.h[:, :, 0] += amp * np.exp(-(sim.Y)**2 / (W**2))

    sim.run()
예제 #9
0
def test():

    sim = Simulation()  # Create a simulation object

    # Geometry and Model Equations
    sim.geomx       = 'periodic'
    sim.geomy       = 'periodic'
    sim.stepper     = Step.AB3      
    sim.method      = 'Spectral'    
    sim.dynamics    = 'Nonlinear'  
    sim.flux_method = Flux.spectral_sw 

    # Specify paramters
    sim.Lx  = 4000e3  
    sim.Ly  = 4000e3   
    sim.Nx  = 128       
    sim.Ny  = 128      
    sim.Nz  = 1         
    sim.g   = 9.81       
    sim.f0  = 1.e-4       
    sim.beta = 0e-11       
    sim.cfl = 0.1           
    sim.Hs  = [100.]         
    sim.rho = [1025.]         
    sim.end_time = 5.*minute 

    sim.animate = 'None'    
    sim.output = False       
    sim.diagnose = False

    # Initialize the grid and zero solutions
    sim.initialize()

    for ii in range(sim.Nz):  # Set mean depths
        sim.soln.h[:,:,ii] = sim.Hs[ii]

    # Gaussian initial conditions
    W  = 200.e3                # Width
    amp = 1.                  # Amplitude
    sim.soln.h[:,:,0] += amp*np.exp(-(sim.X/W)**2 - (sim.Y/W)**2)

    # Run the simulation
    sim.run() 
예제 #10
0
파일: test_Euler.py 프로젝트: PyRsw/PyRsw
def test():

    sim = Simulation() 

    # Geometry and Model Equations
    sim.geomy       = 'periodic'  
    sim.stepper     = Step.Euler   
    sim.method      = 'Spectral'     
    sim.dynamics    = 'Nonlinear'     
    sim.flux_method = Flux.spectral_sw 

    # Specify paramters
    sim.Ly  = 4000e3   
    sim.Ny  = 128       
    sim.cfl = 0.5        
    sim.Hs  = [100.]      
    sim.rho = [1025.]      
    sim.end_time = 5.*minute

    # Plotting parameters
    sim.animate = 'None'  
    sim.output = False   
    sim.diagnose = False 

    # Initialize the grid and zero solutions
    sim.initialize()

    for ii in range(sim.Nz): 
        sim.soln.h[:,:,ii] = sim.Hs[ii]

    # Gaussian initial conditions
    x0 = 1.*sim.Lx/2.     
    W  = 200.e3          
    amp = 1.            
    sim.soln.h[:,:,0] += amp*np.exp(-(sim.Y)**2/(W**2))

    sim.run()      
예제 #11
0
# Add the PyRsw tools to the path
# At the moment it is given explicitely.
# In the future, it could also be added to the
# pythonpath environment variable
sys.path.append('../src')

import Steppers as Step
import Fluxes as Flux
from PyRsw import Simulation
from constants import minute, hour, day

from Stability_tools import cheb
from Stability_tools import stability_sw

sim = Simulation()  # Create a simulation object

# Geometry and Model Equations
sim.geomx = 'periodic'  # Geometry Types: 'periodic' or 'walls'
sim.geomy = 'walls'
sim.stepper = Step.AB3  # Time-stepping algorithm: Euler, AB2, RK4
sim.method = 'Spectral'  # Numerical method: 'Spectral'
sim.dynamics = 'Nonlinear'  # Dynamics: 'Nonlinear' or 'Linear'
sim.flux_method = Flux.spectral_sw  # Flux method: spectral_sw is only option currently

# Specify paramters
sim.Lx = 200e3  # Domain extent               (m)
sim.Ly = 200e3  # Domain extent               (m)
#sim.Nx  = 128             # Grid points in x
sim.Ny = 128  # Grid points in y
sim.Nz = 1  # Number of layers
예제 #12
0
import numpy as np
import matplotlib.pyplot as plt
import sys

# Add the PyRsw tools to the path
# At the moment it is given explicitely.
# In the future, it could also be added to the
# pythonpath environment variable
sys.path.append('../src')

import Steppers as Step
#import Fluxes as Flux
from PyRsw import Simulation
from constants import minute, hour, day

sim = Simulation()  # Create a simulation object
sim.run_name = '2D_Bickley_Jet_Sadourny_N256'

# Geometry and Model Equations
sim.geomx       = 'periodic'       # Geometry Types: 'periodic' or 'walls'
sim.geomy       = 'walls'
sim.stepper     = Step.AB3         # Time-stepping algorithm: Euler, AB2, RK4
sim.method      = 'Sadourny'       # Numerical method: 'Spectral'
sim.dynamics    = 'Nonlinear'      # Dynamics: 'Nonlinear' or 'Linear'

# Specify paramters
sim.Lx  = 150e3           # Domain extent               (m)
sim.Ly  = 100e3           # Domain extent               (m)
sim.Nx  = 256             # Grid points in x
sim.Ny  = 256             # Grid points in y
sim.Nz  = 1               # Number of layers
예제 #13
0
def test():

    sim = Simulation() 

    # Geometry and Model Equations
    sim.geomy       = 'periodic'
    sim.stepper     = Step.AB3      
    sim.method      = 'Spectral'     
    sim.dynamics    = 'Linear'     
    sim.flux_method = Flux.spectral_sw 

    # Specify paramters
    sim.Ly  = 4000e3   
    sim.Ny  = 256       
    sim.f0  = 0.
    sim.Hs  = [100.]      
    sim.rho = [1025.]      
    sim.end_time = sim.Ly/(np.sqrt(sim.Hs[0]*sim.g))

    # Plotting parameters
    sim.animate = 'None'
    sim.output = False
    sim.diagnose = False 

    # Initialize the grid and zero solutions
    sim.initialize()

    for ii in range(sim.Nz): 
        sim.soln.h[:,:,ii] = sim.Hs[ii]

    # Gaussian initial conditions
    x0 = 1.*sim.Lx/2.     
    W  = 200.e3          
    amp = 1.            
    sim.soln.h[:,:,0] += amp*np.exp(-(sim.Y)**2/(W**2))
    IC = sim.soln.h[:,:,0].copy()

    sim.run()       

    # Compare final state to initial conditions
    # error_h is normalized using the triangle inequality
    error_h = np.linalg.norm(IC - sim.soln.h[:,:,0])/(np.linalg.norm(IC) + np.linalg.norm(sim.soln.h[:,:,0]))
    error_v = np.linalg.norm(sim.soln.v[:,:,0])
    assert (error_h < 1e-6) and (error_v < 5e-5)