diff --git a/GeophysicalFlows.jl/GeophysicalFlows_decaying2Dturbulence.jl b/GeophysicalFlows.jl/GeophysicalFlows_decaying2Dturbulence.jl index e5ce9ad..bde33a5 100644 --- a/GeophysicalFlows.jl/GeophysicalFlows_decaying2Dturbulence.jl +++ b/GeophysicalFlows.jl/GeophysicalFlows_decaying2Dturbulence.jl @@ -1,70 +1,64 @@ -using FourierFlows, Printf, Random, FFTW - -using Random: seed! +using FourierFlows, Printf import GeophysicalFlows.TwoDNavierStokes -import GeophysicalFlows.TwoDNavierStokes: energy, enstrophy -import GeophysicalFlows: peakedisotropicspectrum + +using Random: seed! +using Statistics: mean dev = CPU() # Device (CPU/GPU) # Parameters - n = 256 - L = 2π - nν = 2 - ν = 0.0 - dt = 1e-3 -nstepsjit = 10 # call stepforward for nstepsjit to force compilation + n = 256 + L = 2π + ν = 1e-4 +nν = 1 +dt = 1e-3 +nsteps_jit = 10 # call stepforward for nsteps_jit to force compilation nsteps = 5000 - nothingfunction(args...) = nothing - - -gr = TwoDGrid(dev, n, L, n, L; nthreads=1) -pr = TwoDNavierStokes.Params(ν, nν) -vs = TwoDNavierStokes.Vars(dev, gr) -eq = TwoDNavierStokes.Equation(pr, gr) - -prob = FourierFlows.Problem(eq, "FilteredAB3", dt, gr, vs, pr, dev) -filter = FourierFlows.makefilter(prob.eqn) +stepper = "AB3" +floattype = Float64 -# some aliases -sol, cl, vs, gr = prob.sol, prob.clock, prob.vars, prob.grid +grid2D = TwoDGrid(dev, n, L, n, L; nthreads=1, T=floattype) +params = TwoDNavierStokes.Params(ν, nν) +vars = TwoDNavierStokes.Vars(dev, grid2D) +equation = TwoDNavierStokes.Equation(params, grid2D) -x, y = gridpoints(gr) +prob = FourierFlows.Problem(equation, stepper, dt, grid2D, vars, params, dev) -# Initial condition closely following pyqg barotropic example -# that reproduces the results of the paper by McWilliams (1984) +# Random initial condition seed!(1234) -k0, E0 = 6, 0.5 -zetai = peakedisotropicspectrum(gr, k0, E0, mask=filter) -TwoDNavierStokes.set_zeta!(prob, zetai) +zeta_initial = randn(floattype, (n, n)) +zeta_initial = zeta_initial .- mean(zeta_initial) # make sure initial condition has zero mean +TwoDNavierStokes.set_zeta!(prob, zeta_initial) -for j=1:nstepsjit #just-in-time compilation +for j=1:nsteps_jit #just-in-time compilation stepforward!(prob) end -TwoDNavierStokes.set_zeta!(prob, zetai) +TwoDNavierStokes.set_zeta!(prob, zeta_initial) startwalltime = time() -while cl.step < nsteps +while prob.clock.step < nsteps stepforward!(prob) + dealias!(prob.sol, prob.grid) end println(round((time()-startwalltime)/(nsteps-1)*1000, digits=3), " ms per time-step") # using PyPlot +# x, y = gridpoints(prob.grid) # TwoDNavierStokes.updatevars!(prob) # figure(figsize=(10, 4)) # subplot(121) -# pcolormesh(x, y, zetai) +# pcolormesh(x, y, zeta_initial) # xlabel("x") # ylabel("y") # title("vorticity @ t=0") # axis("square") # subplot(122) -# pcolormesh(x, y, vs.zeta) +# pcolormesh(x, y, prob.vars.zeta) # axis("square") # xlabel("x") # ylabel("y") -# title("vorticity @ t="*string(round(cl.t, digits=2))) +# title("vorticity @ t="*string(round(prob.clock.t, digits=2))) # savefig("GeophysicalFlows_n"*string(n)*".png", dpi=400) diff --git a/GeophysicalFlows.jl/GeophysicalFlows_n256.png b/GeophysicalFlows.jl/GeophysicalFlows_n256.png index 601d532..573eb6e 100644 Binary files a/GeophysicalFlows.jl/GeophysicalFlows_n256.png and b/GeophysicalFlows.jl/GeophysicalFlows_n256.png differ diff --git a/GeophysicalFlows.jl/Manifest.toml b/GeophysicalFlows.jl/Manifest.toml index 9c2e7ff..19d728f 100644 --- a/GeophysicalFlows.jl/Manifest.toml +++ b/GeophysicalFlows.jl/Manifest.toml @@ -8,9 +8,9 @@ version = "0.5.0" [[Adapt]] deps = ["LinearAlgebra"] -git-tree-sha1 = "82dab828020b872fa9efd3abec1152b075bc7cbf" +git-tree-sha1 = "fd04049c7dd78cfef0b06cdc1f0f181467655712" uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -version = "1.0.0" +version = "1.1.0" [[AxisAlgorithms]] deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"] @@ -21,164 +21,170 @@ version = "1.0.0" [[Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -[[BinDeps]] -deps = ["Libdl", "Pkg", "SHA", "URIParser", "Unicode"] -git-tree-sha1 = "66158ad56b4bf6cc8413b37d0b7bc52402682764" -uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" -version = "1.0.0" - [[BinaryProvider]] -deps = ["Libdl", "SHA"] -git-tree-sha1 = "5b08ed6036d9d3f0ee6369410b830f8873d4024c" +deps = ["Libdl", "Logging", "SHA"] +git-tree-sha1 = "ecdec412a9abc8db54c0efc5548c64dfce072058" uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" -version = "0.5.8" +version = "0.5.10" [[CEnum]] -git-tree-sha1 = "62847acab40e6855a9b5905ccb99c2b5cf6b3ebb" +git-tree-sha1 = "1b77a77c3b28e0b3f413f7567c9bb8dd9bdccd14" uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" -version = "0.2.0" +version = "0.3.0" [[CUDAapi]] deps = ["Libdl", "Logging"] -git-tree-sha1 = "56a813440ac98a1aa64672ab460a1512552211a7" +git-tree-sha1 = "831b825d10104bd29e28f6da93312a976830717b" uuid = "3895d2a7-ec45-59b8-82bb-cfc6a382f9b3" -version = "2.1.0" +version = "4.0.0" [[CUDAdrv]] deps = ["CEnum", "CUDAapi", "Printf"] -git-tree-sha1 = "1fce616fa0806c67c133eb1d2f68f0f1a7504665" +git-tree-sha1 = "f56bbf18c86bcff7a961a32a4947a5abb2963a29" uuid = "c5f51814-7f29-56b8-a69c-e4d8f6be1fde" -version = "5.0.1" +version = "6.3.0" [[CUDAnative]] -deps = ["Adapt", "CEnum", "CUDAapi", "CUDAdrv", "DataStructures", "InteractiveUtils", "LLVM", "Libdl", "Printf", "TimerOutputs"] -git-tree-sha1 = "ba0725f487fb4a6c63efad7890a659659b6a6754" +deps = ["Adapt", "BinaryProvider", "CEnum", "CUDAapi", "CUDAdrv", "ExprTools", "GPUCompiler", "LLVM", "Libdl", "Pkg", "Printf"] +git-tree-sha1 = "ac86db2b05fdfec96b011e25a504ffe7476e8a68" uuid = "be33ccc6-a3ff-5ff2-a52e-74243cff1e17" -version = "2.8.1" +version = "3.1.0" + +[[CodeTracking]] +deps = ["InteractiveUtils", "UUIDs"] +git-tree-sha1 = "cab4da992adc0a64f63fa30d2db2fd8bec40cab4" +uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" +version = "0.5.11" [[CodecZlib]] -deps = ["BinaryProvider", "Libdl", "TranscodingStreams"] -git-tree-sha1 = "05916673a2627dd91b4969ff8ba6941bc85a960e" +deps = ["TranscodingStreams", "Zlib_jll"] +git-tree-sha1 = "ded953804d019afa9a3f98981d99b33e3db7b6da" uuid = "944b1d66-785c-5afd-91f1-9de20f533193" -version = "0.6.0" +version = "0.7.0" [[ColorTypes]] deps = ["FixedPointNumbers", "Random"] -git-tree-sha1 = "b41d0f666d46ba128c6a0fc632d6e33fbfc03604" +git-tree-sha1 = "c73d9cfc2a9d8433dc77f5bff4bddf46b1d78c20" uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" -version = "0.9.0" +version = "0.10.3" [[Colors]] -deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Printf", "Reexport"] -git-tree-sha1 = "288e7a907bd993d50f5664e8e4fcddb9a3107039" +deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Reexport"] +git-tree-sha1 = "db9c215e2d92379d341e40dd1d5be893af2bfeb2" uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" -version = "0.11.1" +version = "0.12.1" -[[Compat]] -deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "ed2c4abadf84c53d9e58510b5fc48912c2336fbb" -uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "2.2.0" +[[CompilerSupportLibraries_jll]] +deps = ["Libdl", "Pkg"] +git-tree-sha1 = "7c4f882c41faa72118841185afc58a2eb00ef612" +uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" +version = "0.3.3+0" [[Conda]] deps = ["JSON", "VersionParsing"] -git-tree-sha1 = "9a11d428dcdc425072af4aea19ab1e8c3e01c032" +git-tree-sha1 = "7a58bb32ce5d85f8bf7559aa7c2842f9aecf52fc" uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" -version = "1.3.0" +version = "1.4.1" -[[Coverage]] -deps = ["CoverageTools", "HTTP", "JSON", "LibGit2", "MbedTLS"] -git-tree-sha1 = "540c90d34374c82bbb12c4e06df1ef246a81ace2" -uuid = "a2441757-f6aa-5fb2-8edb-039e3f45d037" -version = "1.0.0" - -[[CoverageTools]] -deps = ["LibGit2"] -git-tree-sha1 = "542c90fb36c426891cd7a82924337530453df38f" -uuid = "c36e975a-824b-4404-a568-ef97ca766997" -version = "1.0.0" +[[Cthulhu]] +deps = ["CodeTracking", "InteractiveUtils", "REPL", "UUIDs", "Unicode"] +git-tree-sha1 = "f3643e78353199d3097821e806348bd83f364155" +uuid = "f68482b8-f384-11e8-15f7-abe071a5a75f" +version = "1.1.1" [[CuArrays]] -deps = ["AbstractFFTs", "Adapt", "CEnum", "CUDAapi", "CUDAdrv", "CUDAnative", "DataStructures", "GPUArrays", "Libdl", "LinearAlgebra", "MacroTools", "NNlib", "Printf", "Random", "Requires", "SparseArrays", "TimerOutputs"] -git-tree-sha1 = "51fbe053dea29ed2513e02d38380007310cf4c4b" +deps = ["AbstractFFTs", "Adapt", "CEnum", "CUDAapi", "CUDAdrv", "CUDAnative", "DataStructures", "GPUArrays", "Libdl", "LinearAlgebra", "MacroTools", "NNlib", "Pkg", "Printf", "Random", "Reexport", "Requires", "SparseArrays", "Statistics", "TimerOutputs"] +git-tree-sha1 = "870a4ac61e99c36f42d15e496fd290c841541d90" uuid = "3a865a2d-5b23-5a0f-bc46-62713ec82fae" -version = "1.6.0" +version = "2.2.0" [[DataStructures]] deps = ["InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "b7720de347734f4716d1815b00ce5664ed6bbfd4" +git-tree-sha1 = "af6d9c86e191c917c2276fbede1137e8ea20157f" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.17.9" +version = "0.17.17" [[Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" -[[DelimitedFiles]] -deps = ["Mmap"] -uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" - [[Distributed]] deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +[[ExprTools]] +git-tree-sha1 = "6f0517056812fd6aa3af23d4b70d5325a2ae4e95" +uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" +version = "0.1.1" + [[FFTW]] -deps = ["AbstractFFTs", "BinaryProvider", "Conda", "Libdl", "LinearAlgebra", "Reexport"] -git-tree-sha1 = "4cfd3d43819228b9e73ab46600d0af0aa5cedceb" +deps = ["AbstractFFTs", "FFTW_jll", "IntelOpenMP_jll", "Libdl", "LinearAlgebra", "MKL_jll", "Reexport"] +git-tree-sha1 = "14536c95939aadcee44014728a459d2fe3ca9acf" uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" -version = "1.1.0" +version = "1.2.2" + +[[FFTW_jll]] +deps = ["Libdl", "Pkg"] +git-tree-sha1 = "6c975cd606128d45d1df432fb812d6eb10fee00b" +uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a" +version = "3.3.9+5" [[FileIO]] deps = ["Pkg"] -git-tree-sha1 = "74585bf1f7ed7259e166011e89f49363d7fa89a6" +git-tree-sha1 = "202335fd24c2776493e198d6c66a6d910400a895" uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.2.1" +version = "1.3.0" + +[[FixedPointNumbers]] +git-tree-sha1 = "3ba9ea634d4c8b289d590403b4a06f8e227a6238" +uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" +version = "0.8.0" [[FourierFlows]] -deps = ["CUDAapi", "Coverage", "CuArrays", "FFTW", "Interpolations", "JLD2", "LinearAlgebra", "Printf", "Random", "Reexport", "Requires", "Statistics"] -git-tree-sha1 = "153b295514c016e30b300b9e65b0615061976166" +deps = ["CUDAapi", "CuArrays", "FFTW", "Interpolations", "JLD2", "LinearAlgebra", "Random", "Reexport", "Requires", "Statistics"] +git-tree-sha1 = "af1d7dd410e51ee8b58a8542208abf670180aab5" uuid = "2aec4490-903f-5c70-9b11-9bed06a700e1" -version = "0.3.2" +version = "0.4.5" [[GPUArrays]] deps = ["AbstractFFTs", "Adapt", "LinearAlgebra", "Printf", "Random", "Serialization"] -git-tree-sha1 = "e756da6cee76a5f1436a05827fa8fdf3badc577f" +git-tree-sha1 = "d887693eb1bd5e1fd573262a978745481895ec7d" uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" -version = "2.0.1" +version = "3.4.1" + +[[GPUCompiler]] +deps = ["Cthulhu", "DataStructures", "InteractiveUtils", "LLVM", "Libdl", "TimerOutputs"] +git-tree-sha1 = "5275aa268ecd09640b32560e1eae90c78816e4d1" +uuid = "61eb1bfa-7361-4325-ad38-22787b887f55" +version = "0.2.0" [[GeophysicalFlows]] deps = ["CuArrays", "FFTW", "FourierFlows", "JLD2", "LinearAlgebra", "Random", "Reexport", "SpecialFunctions", "Statistics"] -git-tree-sha1 = "c7b2d8e2fac9a023d7dd12c9551f6a607d208aae" +git-tree-sha1 = "af97c086df798baaea1488923b7b46a47a284b39" uuid = "44ee3b1c-bc02-53fa-8355-8e347616e15e" -version = "0.3.1" - -[[HTTP]] -deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"] -git-tree-sha1 = "5c49dab19938b119fe204fd7d7e8e174f4e9c68b" -uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "0.8.8" - -[[IniFile]] -deps = ["Test"] -git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" -uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" version = "0.5.0" +[[IntelOpenMP_jll]] +deps = ["Libdl", "Pkg"] +git-tree-sha1 = "fb8e1c7a5594ba56f9011310790e03b5384998d6" +uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0" +version = "2018.0.3+0" + [[InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" [[Interpolations]] deps = ["AxisAlgorithms", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"] -git-tree-sha1 = "96b16bb44b1037f42a50e3fa9ba38dd78c9c1a3e" +git-tree-sha1 = "2b7d4e9be8b74f03115e64cf36ed2f48ae83d946" uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" -version = "0.12.7" +version = "0.12.10" [[JLD2]] deps = ["CodecZlib", "DataStructures", "FileIO", "Mmap", "Pkg", "Printf", "UUIDs"] -git-tree-sha1 = "5deae9f0745ef505ed155a0029629cf08502ccab" +git-tree-sha1 = "e03e697cf84c275ece9cbefd1eabaf49bf5e7254" uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819" -version = "0.1.11" +version = "0.1.13" [[JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] @@ -188,11 +194,17 @@ version = "0.21.0" [[LLVM]] deps = ["CEnum", "Libdl", "Printf", "Unicode"] -git-tree-sha1 = "1d08d7e4250f452f6cb20e4574daaebfdbee0ff7" +git-tree-sha1 = "dd3f584c3dbefe39b2a8fbafa1a3b77e31e21255" uuid = "929cbde3-209d-540e-8aea-75f648917ca0" -version = "1.3.3" +version = "1.5.1" + +[[LaTeXStrings]] +git-tree-sha1 = "de44b395389b84fd681394d4e8d39ef14e3a2ea8" +uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" +version = "1.1.0" [[LibGit2]] +deps = ["Printf"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[Libdl]] @@ -205,56 +217,73 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +[[MKL_jll]] +deps = ["IntelOpenMP_jll", "Libdl", "Pkg"] +git-tree-sha1 = "0ce9a7fa68c70cf83c49d05d2c04d91b47404b08" +uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7" +version = "2020.1.216+0" + [[MacroTools]] -deps = ["DataStructures", "Markdown", "Random"] -git-tree-sha1 = "e2fc7a55bb2224e203bbd8b59f72b91323233458" +deps = ["Markdown", "Random"] +git-tree-sha1 = "f7d2e3f654af75f01ec49be82c231c382214223a" uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -version = "0.5.3" +version = "0.5.5" [[Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" -[[MbedTLS]] -deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets"] -git-tree-sha1 = "85f5947b53c8cfd53ccfa3f4abae31faa22c2181" -uuid = "739be429-bea8-5141-9913-cc70e7f3736d" -version = "0.7.0" - [[Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[NNlib]] deps = ["BinaryProvider", "Libdl", "LinearAlgebra", "Requires", "Statistics"] -git-tree-sha1 = "755c0bab3912ff782167e1b4b774b833f8a0e550" +git-tree-sha1 = "d9f196d911f55aeaff11b11f681b135980783824" uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" -version = "0.6.4" +version = "0.6.6" [[OffsetArrays]] -git-tree-sha1 = "fcfb0d1acd89dd37bbfce2873c8401713a855f80" +git-tree-sha1 = "930db8ef90483570107f2396b1ffc6680f08e8b7" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.0.1" +version = "1.0.4" + +[[OpenSpecFun_jll]] +deps = ["CompilerSupportLibraries_jll", "Libdl", "Pkg"] +git-tree-sha1 = "d51c416559217d974a1113522d5919235ae67a87" +uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" +version = "0.5.3+3" [[OrderedCollections]] -deps = ["Random", "Serialization", "Test"] -git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1" +git-tree-sha1 = "12ce190210d278e12644bcadf5b21cbdcf225cd3" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.1.0" +version = "1.2.0" [[Parsers]] deps = ["Dates", "Test"] -git-tree-sha1 = "0139ba59ce9bc680e2925aec5b7db79065d60556" +git-tree-sha1 = "eb3e09940c0d7ae01b01d9291ebad7b081c844d3" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "0.3.10" +version = "1.0.5" [[Pkg]] -deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"] +deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [[Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +[[PyCall]] +deps = ["Conda", "Dates", "Libdl", "LinearAlgebra", "MacroTools", "Serialization", "VersionParsing"] +git-tree-sha1 = "3a3fdb9000d35958c9ba2323ca7c4958901f115d" +uuid = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" +version = "1.91.4" + +[[PyPlot]] +deps = ["Colors", "LaTeXStrings", "PyCall", "Sockets", "Test", "VersionParsing"] +git-tree-sha1 = "67dde2482fe1a72ef62ed93f8c239f947638e5a2" +uuid = "d330b81b-6aea-500a-939a-2ce795aea3ee" +version = "2.9.0" + [[REPL]] deps = ["InteractiveUtils", "Markdown", "Sockets"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" @@ -264,10 +293,9 @@ deps = ["Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[Ratios]] -deps = ["Compat"] -git-tree-sha1 = "cdbbe0f350581296f3a2e3e7a91b214121934407" +git-tree-sha1 = "37d210f612d70f3f7d57d488cb3b6eff56ad4e41" uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439" -version = "0.3.1" +version = "0.4.0" [[Reexport]] deps = ["Pkg"] @@ -277,9 +305,9 @@ version = "0.2.0" [[Requires]] deps = ["UUIDs"] -git-tree-sha1 = "999513b7dea8ac17359ed50ae8ea089e4464e35e" +git-tree-sha1 = "d37400976e98018ee840e0ca4f9d20baa231dc6b" uuid = "ae029012-a4dd-5104-9daa-d747884805df" -version = "1.0.0" +version = "1.0.1" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" @@ -299,16 +327,16 @@ deps = ["LinearAlgebra", "Random"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[SpecialFunctions]] -deps = ["BinDeps", "BinaryProvider", "Libdl"] -git-tree-sha1 = "3bdd374b6fd78faf0119b8c5d538788dbf910c6e" +deps = ["OpenSpecFun_jll"] +git-tree-sha1 = "d8d8b8a9f4119829410ecd706da4cc8594a1e020" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "0.8.0" +version = "0.10.3" [[StaticArrays]] deps = ["LinearAlgebra", "Random", "Statistics"] -git-tree-sha1 = "5a3bcb6233adabde68ebc97be66e95dcb787424c" +git-tree-sha1 = "5c06c0aeb81bef54aed4b3f446847905eb6cbda0" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "0.12.1" +version = "0.12.3" [[Statistics]] deps = ["LinearAlgebra", "SparseArrays"] @@ -320,9 +348,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[TimerOutputs]] deps = ["Printf"] -git-tree-sha1 = "311765af81bbb48d7bad01fb016d9c328c6ede03" +git-tree-sha1 = "f458ca23ff80e46a630922c555d838303e4b9603" uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" -version = "0.5.3" +version = "0.5.6" [[TranscodingStreams]] deps = ["Random", "Test"] @@ -330,12 +358,6 @@ git-tree-sha1 = "7c53c35547de1c5b9d46a4797cf6d8253807108c" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" version = "0.9.5" -[[URIParser]] -deps = ["Test", "Unicode"] -git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" -uuid = "30578b45-9adc-5946-b283-645ec420af67" -version = "0.4.0" - [[UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" @@ -350,6 +372,12 @@ version = "1.2.0" [[WoodburyMatrices]] deps = ["LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "bbb9f7fd6fbdd9582e77c0b698312c543de5eb71" +git-tree-sha1 = "28ffe06d28b1ba8fdb2f36ec7bb079fac81bac0d" uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6" -version = "0.5.0" +version = "0.5.2" + +[[Zlib_jll]] +deps = ["Libdl", "Pkg"] +git-tree-sha1 = "a2e0d558f6031002e380a90613b199e37a8565bf" +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.11+10" diff --git a/matlab/AB3timestep.m b/matlab/AB3timestep.m index 178bd35..e992a66 100644 --- a/matlab/AB3timestep.m +++ b/matlab/AB3timestep.m @@ -1,7 +1,6 @@ function [qhnew, RHSp, RHSpp] = AB3timestep(qh, RHSp, RHSpp, dt) - global filter RHS = RHS_eq(qh); - qhnew = filter.*(qh + (23*RHS - 16*RHSp + 5*RHSpp)*dt/12); + qhnew = qh + (23*RHS - 16*RHSp + 5*RHSpp)*dt/12; RHSpp = RHSp; RHSp = RHS; end \ No newline at end of file diff --git a/matlab/ForwardEulertimestep.m b/matlab/ForwardEulertimestep.m index d9c19fc..f902497 100644 --- a/matlab/ForwardEulertimestep.m +++ b/matlab/ForwardEulertimestep.m @@ -1,5 +1,4 @@ function [qhnew] = ForwardEulertimestep(qh, dt) - global filter RHS = RHS_eq(qh); - qhnew = filter.*(qh + RHS*dt); + qhnew = qh + RHS*dt; end \ No newline at end of file diff --git a/matlab/RK4timestep.m b/matlab/RK4timestep.m index aa5b2bd..78262c0 100644 --- a/matlab/RK4timestep.m +++ b/matlab/RK4timestep.m @@ -4,5 +4,5 @@ k2 = RHS_eq(qh+k1*dt/2); k3 = RHS_eq(qh+k2*dt/2); k4 = RHS_eq(qh+k3*dt); - qhnew = filter.*(qh + (k1 + 2*k2 + 2*k3 + k4)*dt/6); + qhnew = qh + (k1 + 2*k2 + 2*k3 + k4)*dt/6; end \ No newline at end of file diff --git a/matlab/matlab_decaying2Dturbulence.m b/matlab/matlab_decaying2Dturbulence.m index 481f3e9..c451ab4 100644 --- a/matlab/matlab_decaying2Dturbulence.m +++ b/matlab/matlab_decaying2Dturbulence.m @@ -1,9 +1,9 @@ clear all; -global invKsq K L Ksq nu nnu filter +global invKsq K L Ksq nu nnu maxNumCompThreads(1); -GPU = 0; % set =1 to run on GPU +GPU = 0; % set equal to 1 to run on GPU nx = 256; ny = nx; @@ -11,8 +11,8 @@ Lx = 2*pi; Ly = Lx; -nu = 0.0; -nnu = 2; +nu = 1e-4; +nnu = 1; dt = 1e-3; nsteps = 5000; @@ -35,24 +35,10 @@ invKsq = 1 ./ Ksq; invKsq(Ksq==0)=0; -% creat a filter in wavenumber space; -% a is chosen so that the energy at the largest nondim -% wavenumber K*dx be zero whithin machine double precision -s=4; -Kmax = ny/2; Kmax_s=Kmax*dy; -kcut = 2/3*Kmax;kcut_s=kcut*dy; -a = -log(1e-15)/(Kmax_s-kcut_s)^s * dy^s; -Kmag=sqrt(Ksq); - -filter = ones(ny, nx).*abs(Kmag<=ny/3) + exp(-a*(Kmag-kcut).^s).*abs(Kmag>ny/3); - -psih0 = (Ksq.*(1 + (Kmag/6).^4)).^(-1/2) .* (randn(ny, nx) + 1i*randn(ny, nx)); -psih0(1, 1)=0; -psih0 = fft2(real(ifft2(psih0))); -Etemp = sum(0.5*Ksq(:).*abs(psih0(:)).^2/(nx*ny)^2); -psih0 = psih0*sqrt(0.5/Etemp); -qh0 = -Ksq.*psih0.*filter; -qh = qh0; +% Random initial condition +q0 = randn(ny, nx); +q0 = q0 - mean(q0); % make sure initial condition has zero mean +qh = fft2(q0); if GPU==1 qh = gpuArray(qh); K = gpuArray(K); L = gpuArray(L); Ksq = gpuArray(Ksq); @@ -85,7 +71,7 @@ % figure() % set(gcf,'units','inches','position',[3, 3, 10, 4]) % subplot(1,2,1) -% pcolor2(X, Y, real(ifft2(qh0))) +% pcolor2(X, Y, q0) % set(gca, 'fontsize', 12, 'Box', 'on', 'layer', 'top') % xticks(-3:3); yticks(-3:3); % xlabel('$x$', 'fontsize', 16, 'Interpreter', 'latex') @@ -101,4 +87,4 @@ % title(['vorticity @ $t=' num2str(T(end)) '$'], 'fontsize', 16, 'Interpreter', 'latex') % axis square; % set(gcf,'PaperPositionMode','auto') -% print('matlab_n256.png', '-dpng', '-r400'); \ No newline at end of file +% print(['matlab_n' num2str(nx) '.png'], '-dpng', '-r400'); \ No newline at end of file diff --git a/matlab/matlab_n256.png b/matlab/matlab_n256.png index 88db4cd..1e12755 100644 Binary files a/matlab/matlab_n256.png and b/matlab/matlab_n256.png differ diff --git a/pyqg/pyqg_decaying2Dturbulence.py b/pyqg/pyqg_decaying2Dturbulence.py index 578a2e8..9814bf6 100644 --- a/pyqg/pyqg_decaying2Dturbulence.py +++ b/pyqg/pyqg_decaying2Dturbulence.py @@ -13,26 +13,11 @@ beta=0., H=1., rek=0., rd=None, dt=dt, twrite=np.inf, taveint=np.inf, ntd=1) -# McWilliams 84 IC condition -fk = m.wv != 0 -ckappa = np.zeros_like(m.wv2) -ckappa[fk] = np.sqrt( m.wv2[fk]*(1. + (m.wv2[fk]/36.)**2) )**-1 - -nhx, nhy = m.wv2.shape - -Pi_hat = np.random.randn(nhx, nhy)*ckappa +1j*np.random.randn(nhx,nhy)*ckappa - -Pi = m.ifft( Pi_hat[np.newaxis] ) -Pi = Pi - Pi.mean() -Pi_hat = m.fft( Pi ) -KEaux = spec_var( m, m.filtr*m.wv*Pi_hat ) - -pih = ( Pi_hat * np.sqrt(0.5/KEaux) ) -qih = -m.wv2*pih -qi = m.ifft(qih) +# Random initial condition +qi = np.random.randn(m.nz, m.nx, m.ny) +qi = qi - qi.mean() m.set_q(qi) - t = time.time() # run the model m.run() diff --git a/pyqg/pyqg_n256.png b/pyqg/pyqg_n256.png index ba4b228..75370c1 100644 Binary files a/pyqg/pyqg_n256.png and b/pyqg/pyqg_n256.png differ