run.py 2.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import slim3d
from slimPre import make_directory
import shutil

output_dir = 'output/'
data_dir = './data/'
make_directory(output_dir)
shutil.copyfile(data_dir+'tanga2dxz.msh', output_dir+'mesh2dxz.msh')
shutil.copyfile(data_dir+'tanga2dxz_show.msh', output_dir+'mesh2dxz_show.msh')


domain = slim3d.Domain(data_dir+'tanga2dxz.msh', data_dir+'periodicMesh.txt', reference_density=997.22441884)

equations = slim3d.Slim3d_equations(domain, temperature=True)
equations.set_implicit_vertical_diffusion(True)
#equations.set_implicit_vertical_advection(True)
equations.set_vertical_viscosity('gotm')
equations.set_vertical_diffusivity('gotm')
equations.set_horizontal_viscosity('smagorinsky')
equations.set_additional_artificial_horizontal_shear(data_dir+'additional_shear/additional_shear.idx')
#equations.set_horizontal_diffusivity('okubo')
#equations.set_lax_friedrichs(.1)
equations.set_bottom_friction(True, z0B=0.005, z0S=0.02)
equations.set_limiter(False)
equations.set_initial_temperature('netcdf', (data_dir+'initial_temperature.nc','T_init'))
equations.set_initial_salinity('vertical_gradient', None, 0, 0.)
equations.set_wind_stress('stress', (data_dir+'windStress.nc','u'), (data_dir+'windStress.nc','v') )
equations.set_coriolis((data_dir+'coriolis.nc', 'coriolis'))
equations.set_boundary_coast('coast')
equations.set_conservative_ale(False)#True)


time_loop = slim3d.Loop(equations, 
        time_step=600,#1800,
        export_time_step=3600,#86400, 
        final_time=86400*50, 
        output_directory=output_dir)
time_loop.export_elevation()
time_loop.export_temperature()
time_loop.export_z_coordinate()
time_loop.export_uv(False)
time_loop.export_uv2d(False)
time_loop.export_w()
time_loop.export_rho()

#time_loop.loop()
time_loop.setup()
while time_loop.get_time() < time_loop.final_time:
    time_loop.advance_one_time_step()
    time_loop.check_sanity()
    #print('******************')
    #print(time_loop.equations._slimSolver.getUseConservativeALE())
    if time_loop.check_export():
        time_loop.print_iter_info()
        [relVolErr, relSErr, relTErr] = time_loop.check_mass_conservation()
        [absSDev, absTDev] = time_loop.check_tracer_consistency()
        time_loop.export_fields()
time_loop.terminate()