diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000..363fcab --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/job.out b/job.out new file mode 100644 index 0000000..9654dc6 --- /dev/null +++ b/job.out @@ -0,0 +1,90 @@ +[I 2024-05-29 12:28:22.679 ServerApp] jupyter_lsp | extension was successfully linked. +[I 2024-05-29 12:28:22.686 ServerApp] jupyter_server_terminals | extension was successfully linked. +[I 2024-05-29 12:28:22.694 ServerApp] jupyterlab | extension was successfully linked. +[I 2024-05-29 12:28:35.922 ServerApp] notebook_shim | extension was successfully linked. +[I 2024-05-29 12:28:36.548 ServerApp] notebook_shim | extension was successfully loaded. +[I 2024-05-29 12:28:36.550 ServerApp] jupyter_lsp | extension was successfully loaded. +[I 2024-05-29 12:28:36.555 ServerApp] jupyter_server_terminals | extension was successfully loaded. +[I 2024-05-29 12:28:36.721 LabApp] JupyterLab extension loaded from /home/benstem/.conda/envs/myjupyter/lib/python3.10/site-packages/jupyterlab +[I 2024-05-29 12:28:36.722 LabApp] JupyterLab application directory is /home/benstem/.conda/envs/myjupyter/share/jupyter/lab +[I 2024-05-29 12:28:36.775 LabApp] Extension Manager is 'pypi'. +[I 2024-05-29 12:28:36.869 ServerApp] jupyterlab | extension was successfully loaded. +[I 2024-05-29 12:28:36.870 ServerApp] Serving notebooks from local directory: /work/benstem/SpiDySims +[I 2024-05-29 12:28:36.871 ServerApp] Jupyter Server 2.14.0 is running at: +[I 2024-05-29 12:28:36.872 ServerApp] http://10.9.70.16:9099/lab?token=d3620b0e3b079d70b5f294f7f5343cf1f9e2ac776a6438ec +[I 2024-05-29 12:28:36.872 ServerApp] http://127.0.0.1:9099/lab?token=d3620b0e3b079d70b5f294f7f5343cf1f9e2ac776a6438ec +[I 2024-05-29 12:28:36.873 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). +[C 2024-05-29 12:28:36.917 ServerApp] + + To access the server, open this file in a browser: + file:///home/benstem/.local/share/jupyter/runtime/jpserver-58461-open.html + Or copy and paste one of these URLs: + http://10.9.70.16:9099/lab?token=d3620b0e3b079d70b5f294f7f5343cf1f9e2ac776a6438ec + http://127.0.0.1:9099/lab?token=d3620b0e3b079d70b5f294f7f5343cf1f9e2ac776a6438ec +[I 2024-05-29 12:28:37.249 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server +[W 2024-05-29 12:33:20.842 LabApp] Could not determine jupyterlab build status without nodejs +[W 2024-05-29 12:33:28.571 ServerApp] 404 GET /api/contents/abstractarray.jl?content=0&hash=0&1716978807811 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 1.40ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:28.572 ServerApp] 404 GET /api/contents/abstractarray.jl?content=0&hash=0&1716978807811 (10.9.70.3): No such file or directory: abstractarray.jl +[W 2024-05-29 12:33:29.335 ServerApp] 404 GET /api/contents/abstractarray.jl?content=0&hash=0&1716978809333 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.84ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:29.336 ServerApp] 404 GET /api/contents/abstractarray.jl?content=0&hash=0&1716978809333 (10.9.70.3): No such file or directory: abstractarray.jl +[W 2024-05-29 12:33:29.402 ServerApp] 404 GET /api/contents/array.jl?content=0&hash=0&1716978809399 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.88ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:29.403 ServerApp] 404 GET /api/contents/array.jl?content=0&hash=0&1716978809399 (10.9.70.3): No such file or directory: array.jl +[I 2024-05-29 12:33:29.492 ServerApp] Kernel started: d4ecd049-70db-4816-828d-d04d5031bf9b +[W 2024-05-29 12:33:29.501 ServerApp] 404 GET /api/contents/abstractarray.jl?content=0&hash=0&1716978809410 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 1.78ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:29.502 ServerApp] 404 GET /api/contents/abstractarray.jl?content=0&hash=0&1716978809410 (10.9.70.3): No such file or directory: abstractarray.jl +[I 2024-05-29 12:33:29.502 ServerApp] Kernel started: 1848e135-c447-47ca-ad92-767ab7b508c2 +[I 2024-05-29 12:33:29.503 ServerApp] Kernel started: ff608dcf-f94c-41e2-ab5a-c922fca6f41d +[I 2024-05-29 12:33:29.509 ServerApp] Kernel started: d0e3567f-0254-44eb-b4d0-d99c8c082d7c +[W 2024-05-29 12:33:29.619 ServerApp] 404 GET /api/contents/env.jl?content=0&hash=0&1716978809612 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 1.74ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:29.620 ServerApp] 404 GET /api/contents/env.jl?content=0&hash=0&1716978809612 (10.9.70.3): No such file or directory: env.jl +[W 2024-05-29 12:33:29.638 ServerApp] 404 GET /api/contents/essentials.jl?content=0&hash=0&1716978809633 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.96ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:29.638 ServerApp] 404 GET /api/contents/essentials.jl?content=0&hash=0&1716978809633 (10.9.70.3): No such file or directory: essentials.jl +[W 2024-05-29 12:33:29.650 ServerApp] 404 GET /api/contents/essentials.jl?content=0&hash=0&1716978809644 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 1.15ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:29.651 ServerApp] 404 GET /api/contents/essentials.jl?content=0&hash=0&1716978809644 (10.9.70.3): No such file or directory: essentials.jl +[W 2024-05-29 12:33:29.725 ServerApp] 404 GET /api/contents/io.jl?content=0&hash=0&1716978809720 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 1.41ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:29.726 ServerApp] 404 GET /api/contents/io.jl?content=0&hash=0&1716978809720 (10.9.70.3): No such file or directory: io.jl +[W 2024-05-29 12:33:29.987 ServerApp] 404 GET /api/contents/io.jl?content=0&hash=0&1716978809986 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.86ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:33:29.988 ServerApp] 404 GET /api/contents/io.jl?content=0&hash=0&1716978809986 (10.9.70.3): No such file or directory: io.jl +[I 2024-05-29 12:33:35.240 ServerApp] Adapting from protocol version 5.0 (kernel d0e3567f-0254-44eb-b4d0-d99c8c082d7c) to 5.3 (client). +[I 2024-05-29 12:33:35.241 ServerApp] Connecting to kernel d0e3567f-0254-44eb-b4d0-d99c8c082d7c. +[I 2024-05-29 12:33:35.370 ServerApp] Starting buffering for d0e3567f-0254-44eb-b4d0-d99c8c082d7c:8a9d0245-8083-4551-910c-12d119840d8c +[I 2024-05-29 12:33:35.605 ServerApp] Adapting from protocol version 5.0 (kernel d4ecd049-70db-4816-828d-d04d5031bf9b) to 5.3 (client). +[I 2024-05-29 12:33:35.607 ServerApp] Connecting to kernel d4ecd049-70db-4816-828d-d04d5031bf9b. +[I 2024-05-29 12:33:35.915 ServerApp] Adapting from protocol version 5.0 (kernel 1848e135-c447-47ca-ad92-767ab7b508c2) to 5.3 (client). +[I 2024-05-29 12:33:35.917 ServerApp] Connecting to kernel 1848e135-c447-47ca-ad92-767ab7b508c2. +[I 2024-05-29 12:33:36.188 ServerApp] Adapting from protocol version 5.0 (kernel ff608dcf-f94c-41e2-ab5a-c922fca6f41d) to 5.3 (client). +[I 2024-05-29 12:33:36.189 ServerApp] Connecting to kernel ff608dcf-f94c-41e2-ab5a-c922fca6f41d. +Starting kernel event loops. +[I 2024-05-29 12:33:40.400 ServerApp] Adapting from protocol version 5.0 (kernel d0e3567f-0254-44eb-b4d0-d99c8c082d7c) to 5.3 (client). +[I 2024-05-29 12:33:40.401 ServerApp] Connecting to kernel d0e3567f-0254-44eb-b4d0-d99c8c082d7c. +[I 2024-05-29 12:33:40.403 ServerApp] Discarding 1 buffered messages for d0e3567f-0254-44eb-b4d0-d99c8c082d7c:8a9d0245-8083-4551-910c-12d119840d8c +[I 2024-05-29 12:33:40.410 ServerApp] Kernel restarted: d0e3567f-0254-44eb-b4d0-d99c8c082d7c +[I 2024-05-29 12:33:40.417 ServerApp] Adapting from protocol version 5.0 (kernel d0e3567f-0254-44eb-b4d0-d99c8c082d7c) to 5.3 (client). +[I 2024-05-29 12:33:40.418 ServerApp] Connecting to kernel d0e3567f-0254-44eb-b4d0-d99c8c082d7c. +[I 2024-05-29 12:33:40.434 ServerApp] Adapting from protocol version 5.0 (kernel d0e3567f-0254-44eb-b4d0-d99c8c082d7c) to 5.3 (client). +[I 2024-05-29 12:33:40.435 ServerApp] Connecting to kernel d0e3567f-0254-44eb-b4d0-d99c8c082d7c. +[I 2024-05-29 12:35:28.380 ServerApp] Saving file at /runs/Comparison-Copy2.ipynb +[I 2024-05-29 12:37:28.714 ServerApp] Saving file at /runs/Comparison-Copy2.ipynb +[W 2024-05-29 12:37:51.969 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979071967 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 1.08ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:37:51.970 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979071967 (10.9.70.3): No such file or directory: math.jl +[W 2024-05-29 12:37:51.991 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979071991 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.78ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:37:51.992 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979071991 (10.9.70.3): No such file or directory: math.jl +[W 2024-05-29 12:37:51.998 ServerApp] 404 GET /api/contents/In?content=0&hash=0&1716979071997 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.76ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:37:51.999 ServerApp] 404 GET /api/contents/In?content=0&hash=0&1716979071997 (10.9.70.3): No such file or directory: In +[W 2024-05-29 12:39:13.413 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979153413 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 1.06ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:39:13.414 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979153413 (10.9.70.3): No such file or directory: math.jl +[W 2024-05-29 12:39:13.424 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979153423 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.83ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:39:13.424 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979153423 (10.9.70.3): No such file or directory: math.jl +[W 2024-05-29 12:39:13.435 ServerApp] 404 GET /api/contents/In?content=0&hash=0&1716979153434 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.78ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:39:13.435 ServerApp] 404 GET /api/contents/In?content=0&hash=0&1716979153434 (10.9.70.3): No such file or directory: In +[I 2024-05-29 12:39:29.370 ServerApp] Saving file at /runs/Comparison-Copy2.ipynb +[W 2024-05-29 12:39:45.887 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979185887 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.92ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:39:45.888 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979185887 (10.9.70.3): No such file or directory: math.jl +[W 2024-05-29 12:39:45.896 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979185896 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.77ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:39:45.897 ServerApp] 404 GET /api/contents/math.jl?content=0&hash=0&1716979185896 (10.9.70.3): No such file or directory: math.jl +[W 2024-05-29 12:39:45.904 ServerApp] 404 GET /api/contents/In?content=0&hash=0&1716979185904 (29e5fe51140841b98363cfb9110faabf@10.9.70.3) 0.71ms referer=http://127.0.0.1:9099/lab +[W 2024-05-29 12:39:45.905 ServerApp] 404 GET /api/contents/In?content=0&hash=0&1716979185904 (10.9.70.3): No such file or directory: In +[I 2024-05-29 12:41:29.881 ServerApp] Saving file at /runs/Comparison-Copy2.ipynb +[I 2024-05-29 12:43:30.294 ServerApp] Saving file at /runs/Comparison-Copy2.ipynb +[I 2024-05-29 12:45:30.724 ServerApp] Saving file at /runs/Comparison-Copy2.ipynb +[I 2024-05-29 12:55:31.597 ServerApp] Saving file at /runs/Comparison-Copy2.ipynb diff --git a/jupyterlab.job b/jupyterlab.job new file mode 100644 index 0000000..8fd9b04 --- /dev/null +++ b/jupyterlab.job @@ -0,0 +1,22 @@ +#!/bin/bash + +#SBATCH --partition=all +#SBATCH --ntasks=1 +#SBATCH --cpus-per-task=64 +#SBATCH --mem=64G +#SBATCH --time 0-03:00 +#SBATCH --chdir=/work/benstem/SpiDySims +#SBATCH --mail-type=ALL +#SBATCH --output=job.out + +export https_proxy=http://proxy2.uni-potsdam.de:3128 + + #Load Python modules +module load lang/Julia/1.7.3-linux-x86_64 +module load lang/Anaconda3/2020.11 +source activate myjupyter + +export JULIA_NUM_THREADS=64 # $SLULRM_CPUS_PER_TASK + + #jupyter-lab --no-browser +jupyter-lab --no-browser --port 9099 --ip=$(hostname -I | cut -f1 -d' ') diff --git a/runs/.ipynb_checkpoints/Comparison-Copy1-checkpoint.ipynb b/runs/.ipynb_checkpoints/Comparison-Copy1-checkpoint.ipynb new file mode 100644 index 0000000..4b8b03f --- /dev/null +++ b/runs/.ipynb_checkpoints/Comparison-Copy1-checkpoint.ipynb @@ -0,0 +1,643 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "e47f1fd3-c09d-43cb-80c8-64f42e8161a4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 1000\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "s0 = [0, 1, 0]\n", + "J0 = 1.\n", + "JH = Nchain(1, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + ] + } + ], + "source": [ + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_ohm = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_ohm[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_ohm = mean(sols_ohm, dims=1)[1, :, :];\n", + "solstd_ohm = std(sols_ohm, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "3422af78-2f32-468c-a8a3-a0732a836fd1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + } + ], + "source": [ + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_col = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_col[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_col = mean(sols_col, dims=1)[1, :, :];\n", + "solstd_col = std(sols_col, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_ohm[:, 1])\n", + "plot!(saveat, solstd_ohm[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1])\n", + "plot!(saveat, solstd_col[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg_ohm[:, 3])\n", + "plot!(saveat, solavg_col[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected_ohm = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_ohm)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_ohm[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_ohm[j, i, 1] = dot(u,b)\n", + " projected_ohm[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "f1661b24-42b1-4f59-989a-54dc3ed03bf8", + "metadata": {}, + "outputs": [], + "source": [ + "projected_col = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_col)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_col[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_col[j, i, 1] = dot(u,b)\n", + " projected_col[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests\n", + "using LaTeXStrings" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB_ohm = zeros(N)\n", + "for i in 1:N\n", + " JB_ohm[i] = HypothesisTests.JarqueBeraTest(projected_ohm[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "51ccaeb8-2b3d-4630-afc3-2640142c4d54", + "metadata": {}, + "outputs": [], + "source": [ + "JB_col = zeros(N)\n", + "for i in 1:N\n", + " JB_col[i] = HypothesisTests.JarqueBeraTest(projected_col[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, JB_ohm, title=\"JB Test for Ohmic and Non-Ohmic Coupling\", label=\"Ohmic\", linewidth=2, xlabel=\"Time\", ylabel=\"JB Test\", legend=:topleft, ylimits=(0, 200))\n", + "plot!(saveat, JB_col, label=\"Non-Ohmic\", linewidth=2)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "ad2674ba-9711-4feb-96ab-a39d88b27ce5", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "right_axis = twinx()\n", + "\n", + "plot!(right_axis, saveat, solavg_ohm[:, 3], label=\"Ohmic\", ls=:dash, ylabel=L\"S_z\", ylimits=(-1.5, 1.5))\n", + "plot!(right_axis, saveat, solavg_col[:, 3], label=\"Non-Ohmic\", ls=:dash)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "a1c77edf-652b-42ea-8bc0-445749a22a2c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.010024181624728401 and 2.9355563110404956\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: fail to reject h_0\n", + " one-sided p-value: 0.3872\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 1.89789\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected_col[:, 125, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "48b2963f-d070-46c9-a077-fe4aad09155a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/.ipynb_checkpoints/Comparison-Copy2-checkpoint.ipynb b/runs/.ipynb_checkpoints/Comparison-Copy2-checkpoint.ipynb new file mode 100644 index 0000000..1ffcf5b --- /dev/null +++ b/runs/.ipynb_checkpoints/Comparison-Copy2-checkpoint.ipynb @@ -0,0 +1,641 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "e47f1fd3-c09d-43cb-80c8-64f42e8161a4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 1000\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "s0 = [0, 1, 1]\n", + "s0 = s0 ./ norm(s0)\n", + "\n", + "J0 = 1.\n", + "JH = Nchain(1, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + ] + } + ], + "source": [ + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_ohm = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_ohm[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_ohm = mean(sols_ohm, dims=1)[1, :, :];\n", + "solstd_ohm = std(sols_ohm, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "3422af78-2f32-468c-a8a3-a0732a836fd1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + } + ], + "source": [ + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_col = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_col[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_col = mean(sols_col, dims=1)[1, :, :];\n", + "solstd_col = std(sols_col, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_ohm[:, 1])\n", + "plot!(saveat, solstd_ohm[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1])\n", + "plot!(saveat, solstd_col[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg_ohm[:, 3])\n", + "plot!(saveat, solavg_col[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected_ohm = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_ohm)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_ohm[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_ohm[j, i, 1] = dot(u,b)\n", + " projected_ohm[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "f1661b24-42b1-4f59-989a-54dc3ed03bf8", + "metadata": {}, + "outputs": [], + "source": [ + "projected_col = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_col)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_col[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_col[j, i, 1] = dot(u,b)\n", + " projected_col[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests\n", + "using LaTeXStrings" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB_ohm = zeros(N)\n", + "for i in 1:N\n", + " JB_ohm[i] = HypothesisTests.JarqueBeraTest(projected_ohm[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "51ccaeb8-2b3d-4630-afc3-2640142c4d54", + "metadata": {}, + "outputs": [], + "source": [ + "JB_col = zeros(N)\n", + "for i in 1:N\n", + " JB_col[i] = HypothesisTests.JarqueBeraTest(projected_col[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, JB_ohm, title=\"JB Test for Ohmic and Non-Ohmic Coupling\", label=\"Ohmic\", linewidth=2, xlabel=\"Time\", ylabel=\"JB Test\", legend=:topleft, ylimits=(0, 200))\n", + "plot!(saveat, JB_col, label=\"Non-Ohmic\", linewidth=2)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "ad2674ba-9711-4feb-96ab-a39d88b27ce5", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "right_axis = twinx()\n", + "\n", + "plot!(right_axis, saveat, solavg_ohm[:, 3], label=\"Ohmic\", ls=:dash, ylabel=L\"S_z\", ylimits=(-1.5, 1.5))\n", + "plot!(right_axis, saveat, solavg_col[:, 3], label=\"Non-Ohmic\", ls=:dash)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "a1c77edf-652b-42ea-8bc0-445749a22a2c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.3052333801108836 and 3.1710040046492263\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: reject h_0\n", + " one-sided p-value: <1e-36\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 167.463\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected_col[:, 125, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "48b2963f-d070-46c9-a077-fe4aad09155a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/.ipynb_checkpoints/Comparison-Copy3-checkpoint.ipynb b/runs/.ipynb_checkpoints/Comparison-Copy3-checkpoint.ipynb new file mode 100644 index 0000000..3ca5004 --- /dev/null +++ b/runs/.ipynb_checkpoints/Comparison-Copy3-checkpoint.ipynb @@ -0,0 +1,643 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "e47f1fd3-c09d-43cb-80c8-64f42e8161a4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 1000\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "theta = pi * 3/8\n", + "\n", + "s0 = [0, 1, cos(pi)]\n", + "s0 = s0 ./ norm(s0)\n", + "\n", + "J0 = 1.\n", + "JH = Nchain(1, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + ] + } + ], + "source": [ + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_ohm = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_ohm[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_ohm = mean(sols_ohm, dims=1)[1, :, :];\n", + "solstd_ohm = std(sols_ohm, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "3422af78-2f32-468c-a8a3-a0732a836fd1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + } + ], + "source": [ + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_col = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_col[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_col = mean(sols_col, dims=1)[1, :, :];\n", + "solstd_col = std(sols_col, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_ohm[:, 1])\n", + "plot!(saveat, solstd_ohm[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1])\n", + "plot!(saveat, solstd_col[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg_ohm[:, 3])\n", + "plot!(saveat, solavg_col[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected_ohm = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_ohm)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_ohm[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_ohm[j, i, 1] = dot(u,b)\n", + " projected_ohm[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "f1661b24-42b1-4f59-989a-54dc3ed03bf8", + "metadata": {}, + "outputs": [], + "source": [ + "projected_col = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_col)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_col[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_col[j, i, 1] = dot(u,b)\n", + " projected_col[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests\n", + "using LaTeXStrings" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB_ohm = zeros(N)\n", + "for i in 1:N\n", + " JB_ohm[i] = HypothesisTests.JarqueBeraTest(projected_ohm[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "51ccaeb8-2b3d-4630-afc3-2640142c4d54", + "metadata": {}, + "outputs": [], + "source": [ + "JB_col = zeros(N)\n", + "for i in 1:N\n", + " JB_col[i] = HypothesisTests.JarqueBeraTest(projected_col[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, JB_ohm, title=\"JB Test for Ohmic and Non-Ohmic Coupling\", label=\"Ohmic\", linewidth=2, xlabel=\"Time\", ylabel=\"JB Test\", legend=:topleft, ylimits=(0, 200))\n", + "plot!(saveat, JB_col, label=\"Non-Ohmic\", linewidth=2)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "ad2674ba-9711-4feb-96ab-a39d88b27ce5", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "right_axis = twinx()\n", + "\n", + "plot!(right_axis, saveat, solavg_ohm[:, 3], label=\"Ohmic\", ls=:dash, ylabel=L\"S_z\", ylimits=(-1.5, 1.5))\n", + "plot!(right_axis, saveat, solavg_col[:, 3], label=\"Non-Ohmic\", ls=:dash)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "a1c77edf-652b-42ea-8bc0-445749a22a2c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.3052333801108836 and 3.1710040046492263\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: reject h_0\n", + " one-sided p-value: <1e-36\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 167.463\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected_col[:, 125, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "48b2963f-d070-46c9-a077-fe4aad09155a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/.ipynb_checkpoints/Comparison-checkpoint.ipynb b/runs/.ipynb_checkpoints/Comparison-checkpoint.ipynb new file mode 100644 index 0000000..fb1eb17 --- /dev/null +++ b/runs/.ipynb_checkpoints/Comparison-checkpoint.ipynb @@ -0,0 +1,1152 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "f52c5daf-9123-4b36-b83c-d5d2bcae5d91", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 600\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "\n", + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "matrix = AnisoCoupling([-sin(π/4) 0. 0. # coupling to the environment\n", + " 0. 0. 0.\n", + " cos(π/4) 0. 0.]);\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "nspin = 1 # number of spins\n", + "\n", + "s0 = [0, 1, 1] ./ sqrt(2)\n", + "J0 = 1.\n", + "JH = Nchain(nspin, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:01:39\u001b[39m2:11\u001b[39m\n" + ] + } + ], + "source": [ + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols = zeros(nruns, length(saveat), 3*nspin)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg = mean(sols, dims=1)[1, :, :];\n", + "solstd = std(sols, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 1], ribbon=solstd[:, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 2], ribbon=solstd[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 3], ribbon=solstd[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected[j, i, 1] = dot(u,b)\n", + " projected[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "03467eca-3f0c-4bd4-b3f7-5649b68780bc", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 280, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "9c6484d3-3396-47bb-b063-98e8d013d020", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 280, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f6df949c-15b2-447f-a264-8ef48ce1725e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "nth_moment (generic function with 1 method)" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function nth_moment(data, N)\n", + " return mean(data .^ N)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB = zeros(N)\n", + "for i in 10:N\n", + " JB[i] = HypothesisTests.JarqueBeraTest(projected[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "ebf486ee-5e68-45ba-b98d-b25e08d766b7", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "attempt to save state beyond implementation limit\n" + ] + } + ], + "source": [ + "plot(saveat[1:N-1], JB[1:N-1])" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "2ba81fb8-bfed-40f2-8d33-4b1447a162b3", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot!(saveat, solavg[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6ac5d053-d730-4118-8a73-f4af439a4058", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 200, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "1f7d2316-131d-4faf-941e-eb4ca032727c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.17966985914759054 and 3.1431723658541975\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: reject h_0\n", + " one-sided p-value: <1e-13\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 62.3431\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected[:, 200, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/.ipynb_checkpoints/Grid-checkpoint.ipynb b/runs/.ipynb_checkpoints/Grid-checkpoint.ipynb new file mode 100644 index 0000000..5cb8836 --- /dev/null +++ b/runs/.ipynb_checkpoints/Grid-checkpoint.ipynb @@ -0,0 +1,1030 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "f52c5daf-9123-4b36-b83c-d5d2bcae5d91", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .1\n", + "N = 300\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "matrix = AnisoCoupling([-sin(π/4) 0. 0. # coupling to the environment\n", + " 0. 0. 0.\n", + " cos(π/4) 0. 0.]);\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "nspin = 1 # number of spins\n", + "\n", + "s0 = zeros(3*nspin)\n", + "for i in 1:nspin\n", + " ϵ = 0.1\n", + " s0tmp = [ϵ*rand(), ϵ*rand(), -1]\n", + " s0[1+(i-1)*3:3+(i-1)*3] = s0tmp./norm(s0tmp)\n", + "end\n", + "J0 = 1.\n", + "JH = Nchain(nspin, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:29\u001b[39m:38\u001b[39m\n" + ] + } + ], + "source": [ + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols = zeros(nruns, length(saveat), 3*nspin)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg = mean(sols, dims=1)[1, :, :];\n", + "solstd = std(sols, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 1], ribbon=solstd[:, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 2], ribbon=solstd[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 3], ribbon=solstd[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected[j, i, 1] = dot(u,b)\n", + " projected[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "03467eca-3f0c-4bd4-b3f7-5649b68780bc", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 70, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "9c6484d3-3396-47bb-b063-98e8d013d020", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 70, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f6df949c-15b2-447f-a264-8ef48ce1725e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "nth_moment (generic function with 1 method)" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function nth_moment(data, N)\n", + " return mean(data .^ N)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB = zeros(N)\n", + "for i in 10:N\n", + " JB[i] = HypothesisTests.JarqueBeraTest(projected[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "3ad3f882-caa1-4dfc-b83c-3b57c214ecea", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(10:N, JB[10:N])" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "bb3c6b84-5b21-4d79-b5bc-3345a8f2d893", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"0.024334226316224686 and 2.969023598052513\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: fail to reject h_0\n", + " one-sided p-value: 0.4999\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 1.38673\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected[:, 197, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "e331f6c7-fb4b-4f21-84d3-6a3f203a95b6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"0.019720125889005284 and 2.974701096764015\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: fail to reject h_0\n", + " one-sided p-value: 0.6329\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 0.91482\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected[:, 200, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "240660fb-d008-4dab-8bc1-aaf530885102", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8150abab-cacc-4617-9d95-bebdc4c7cac8", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/.ipynb_checkpoints/LLB-checkpoint.ipynb b/runs/.ipynb_checkpoints/LLB-checkpoint.ipynb new file mode 100644 index 0000000..363fcab --- /dev/null +++ b/runs/.ipynb_checkpoints/LLB-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/.ipynb_checkpoints/Projections-Copy1-checkpoint.ipynb b/runs/.ipynb_checkpoints/Projections-Copy1-checkpoint.ipynb new file mode 100644 index 0000000..fbd8b62 --- /dev/null +++ b/runs/.ipynb_checkpoints/Projections-Copy1-checkpoint.ipynb @@ -0,0 +1,1152 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "f52c5daf-9123-4b36-b83c-d5d2bcae5d91", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 600\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "\n", + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "matrix = AnisoCoupling([-sin(π/4) 0. 0. # coupling to the environment\n", + " 0. 0. 0.\n", + " cos(π/4) 0. 0.]);\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "nspin = 1 # number of spins\n", + "\n", + "s0 = [0, 1, 1] ./ sqrt(2)\n", + "J0 = 1.\n", + "JH = Nchain(nspin, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:01:39\u001b[39m2:11\u001b[39m\n" + ] + } + ], + "source": [ + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols = zeros(nruns, length(saveat), 3*nspin)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg = mean(sols, dims=1)[1, :, :];\n", + "solstd = std(sols, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 1], ribbon=solstd[:, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 2], ribbon=solstd[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 3], ribbon=solstd[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected[j, i, 1] = dot(u,b)\n", + " projected[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "03467eca-3f0c-4bd4-b3f7-5649b68780bc", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 280, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "9c6484d3-3396-47bb-b063-98e8d013d020", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 280, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f6df949c-15b2-447f-a264-8ef48ce1725e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "nth_moment (generic function with 1 method)" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function nth_moment(data, N)\n", + " return mean(data .^ N)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB = zeros(N)\n", + "for i in 10:N\n", + " JB[i] = HypothesisTests.JarqueBeraTest(projected[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ebf486ee-5e68-45ba-b98d-b25e08d766b7", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat[1:N], JB)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "2ba81fb8-bfed-40f2-8d33-4b1447a162b3", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "ename": "BoundsError", + "evalue": "BoundsError: attempt to access 600-element StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64} at index [1:601]", + "output_type": "error", + "traceback": [ + "BoundsError: attempt to access 600-element StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64} at index [1:601]", + "", + "Stacktrace:", + " [1] throw_boundserror(A::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, I::Tuple{UnitRange{Int64}})", + " @ Base ./abstractarray.jl:691", + " [2] checkbounds", + " @ ./abstractarray.jl:656 [inlined]", + " [3] getindex(r::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, s::UnitRange{Int64})", + " @ Base ./twiceprecision.jl:484", + " [4] gr_draw_segments(series::Plots.Series, x::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, y::Vector{Float64}, z::Nothing, fillrange::Tuple{Vector{Float64}, Vector{Float64}}, clims::Tuple{Float64, Float64})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:1825", + " [5] gr_add_series(sp::Plots.Subplot{Plots.GRBackend}, series::Plots.Series)", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:1742", + " [6] gr_display(sp::Plots.Subplot{Plots.GRBackend}, w::Measures.AbsoluteLength, h::Measures.AbsoluteLength, vp_canvas::Plots.GRViewport{Float64})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:964", + " [7] (::Plots.var\"#537#538\"{Int64, Int64, Plots.GRViewport{Float64}})(sp::Plots.Subplot{Plots.GRBackend})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:688", + " [8] foreach(f::Plots.var\"#537#538\"{Int64, Int64, Plots.GRViewport{Float64}}, itr::Vector{Plots.Subplot})", + " @ Base ./abstractarray.jl:2712", + " [9] gr_display(plt::Plots.Plot{Plots.GRBackend}, dpi_factor::Int64)", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:688", + " [10] #582", + " @ ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:2062 [inlined]", + " [11] withenv(::Plots.var\"#582#583\"{Plots.Plot{Plots.GRBackend}, Int64}, ::Pair{String, String}, ::Vararg{Pair{String, String}})", + " @ Base ./env.jl:172", + " [12] _show(io::IOBuffer, #unused#::MIME{Symbol(\"image/svg+xml\")}, plt::Plots.Plot{Plots.GRBackend})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:2057", + " [13] #invokelatest#2", + " @ ./essentials.jl:716 [inlined]", + " [14] invokelatest", + " @ ./essentials.jl:714 [inlined]", + " [15] show(io::IOBuffer, m::MIME{Symbol(\"image/svg+xml\")}, plt::Plots.Plot{Plots.GRBackend})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/output.jl:232", + " [16] sprint(::Function, ::MIME{Symbol(\"image/svg+xml\")}, ::Vararg{Any}; context::Nothing, sizehint::Int64)", + " @ Base ./strings/io.jl:114", + " [17] sprint", + " @ ./strings/io.jl:108 [inlined]", + " [18] _ijulia_display_dict(plt::Plots.Plot{Plots.GRBackend})", + " @ Plots.IJuliaExt ~/.julia/packages/Plots/ju9dp/ext/IJuliaExt.jl:54", + " [19] display_dict(plt::Plots.Plot{Plots.GRBackend})", + " @ Plots.IJuliaExt ~/.julia/packages/Plots/ju9dp/ext/IJuliaExt.jl:70", + " [20] #invokelatest#2", + " @ ./essentials.jl:716 [inlined]", + " [21] invokelatest", + " @ ./essentials.jl:714 [inlined]", + " [22] execute_request(socket::ZMQ.Socket, msg::IJulia.Msg)", + " @ IJulia ~/.julia/packages/IJulia/Vo51o/src/execute_request.jl:112", + " [23] #invokelatest#2", + " @ ./essentials.jl:716 [inlined]", + " [24] invokelatest", + " @ ./essentials.jl:714 [inlined]", + " [25] eventloop(socket::ZMQ.Socket)", + " @ IJulia ~/.julia/packages/IJulia/Vo51o/src/eventloop.jl:8", + " [26] (::IJulia.var\"#15#18\")()", + " @ IJulia ./task.jl:429" + ] + } + ], + "source": [ + "plot!(saveat, solavg[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6ac5d053-d730-4118-8a73-f4af439a4058", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 200, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "1f7d2316-131d-4faf-941e-eb4ca032727c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.17966985914759054 and 3.1431723658541975\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: reject h_0\n", + " one-sided p-value: <1e-13\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 62.3431\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected[:, 200, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/135.png b/runs/135.png new file mode 100644 index 0000000..78f3eab Binary files /dev/null and b/runs/135.png differ diff --git a/runs/22_5.png b/runs/22_5.png new file mode 100644 index 0000000..e69de29 diff --git a/runs/45.png b/runs/45.png new file mode 100644 index 0000000..4abfa2d Binary files /dev/null and b/runs/45.png differ diff --git a/runs/45_hist_col.gif b/runs/45_hist_col.gif new file mode 100644 index 0000000..3b2d433 Binary files /dev/null and b/runs/45_hist_col.gif differ diff --git a/runs/45_hist_ohm.gif b/runs/45_hist_ohm.gif new file mode 100644 index 0000000..dd050fa Binary files /dev/null and b/runs/45_hist_ohm.gif differ diff --git a/runs/67_5.png b/runs/67_5.png new file mode 100644 index 0000000..e69de29 diff --git a/runs/90.png b/runs/90.png new file mode 100644 index 0000000..078df4f Binary files /dev/null and b/runs/90.png differ diff --git a/runs/90_hist_col.gif b/runs/90_hist_col.gif new file mode 100644 index 0000000..f01c92d Binary files /dev/null and b/runs/90_hist_col.gif differ diff --git a/runs/90_hist_ohm.gif b/runs/90_hist_ohm.gif new file mode 100644 index 0000000..64b2a37 Binary files /dev/null and b/runs/90_hist_ohm.gif differ diff --git a/runs/Comparison-Copy1.ipynb b/runs/Comparison-Copy1.ipynb new file mode 100644 index 0000000..0c09d9c --- /dev/null +++ b/runs/Comparison-Copy1.ipynb @@ -0,0 +1,619 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "e47f1fd3-c09d-43cb-80c8-64f42e8161a4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 1000\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "theta = pi * 3/8\n", + "\n", + "s0 = [0, 1, cos(theta)]\n", + "s0 = s0 ./ norm(s0)\n", + "\n", + "J0 = 1.\n", + "JH = Nchain(1, J0)\n", + "\n", + "nruns = 1000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:03:04\u001b[39mm\n" + ] + } + ], + "source": [ + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_ohm = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_ohm[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_ohm = mean(sols_ohm, dims=1)[1, :, :];\n", + "solstd_ohm = std(sols_ohm, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "3422af78-2f32-468c-a8a3-a0732a836fd1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:52\u001b[39m\n" + ] + } + ], + "source": [ + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_col = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_col[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_col = mean(sols_col, dims=1)[1, :, :];\n", + "solstd_col = std(sols_col, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests\n", + "using LaTeXStrings" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"/work/benstem/SpiDySims/runs/std_66_5.png\"" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_ohm[:, 1], label=L\"\\Delta x\", lw=1)\n", + "plot!(saveat, solstd_ohm[:, 2], label=L\"\\Delta y\", lw=1)\n", + "plot!(legend=:topright, xlabel=\"Time\", ylabel=\"Standard Deviation\")\n", + "\n", + "axis = twinx()\n", + "plot!(axis, saveat, solavg_col[:, 3], label=L\"s_z\", ls=:dash)\n", + "hline!(axis, [0], label=\"\", ls=:dash)\n", + "plot!(axis, legend=:bottomright, ylabel=L\"$s_z$ Spin Component\")\n", + "\n", + "savefig(\"./std_66_5.png\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1], label=L\"\\Delta s_x\")\n", + "plot!(saveat, solstd_col[:, 2], label=L\"\\Delta s_y\")\n", + "\n", + "axis = twinx()\n", + "plot!(axis, saveat, solavg_col[:, 3], label=L\"s_z\", ls=:dash)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg_ohm[:, 3])\n", + "plot!(saveat, solavg_col[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected_ohm = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_ohm)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_ohm[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_ohm[j, i, 1] = dot(u,b)\n", + " projected_ohm[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "f1661b24-42b1-4f59-989a-54dc3ed03bf8", + "metadata": {}, + "outputs": [], + "source": [ + "projected_col = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_col)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_col[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_col[j, i, 1] = dot(u,b)\n", + " projected_col[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB_ohm = zeros(N)\n", + "for i in 1:N\n", + " JB_ohm[i] = HypothesisTests.JarqueBeraTest(projected_ohm[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "51ccaeb8-2b3d-4630-afc3-2640142c4d54", + "metadata": {}, + "outputs": [], + "source": [ + "JB_col = zeros(N)\n", + "for i in 1:N\n", + " JB_col[i] = HypothesisTests.JarqueBeraTest(projected_col[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, JB_ohm, title=\"JB Test for Ohmic and Non-Ohmic Coupling\", label=\"Ohmic\", linewidth=2, xlabel=\"Time\", ylabel=\"JB Test\", legend=:topleft, ylimits=(0, 200))\n", + "plot!(saveat, JB_col, label=\"Non-Ohmic\", linewidth=2)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "ad2674ba-9711-4feb-96ab-a39d88b27ce5", + "metadata": {}, + "outputs": [ + { + "ename": "LoadError", + "evalue": "BoundsError: attempt to access 1000-element Vector{Float64} at index [1:1001]", + "output_type": "error", + "traceback": [ + "BoundsError: attempt to access 1000-element Vector{Float64} at index [1:1001]", + "", + "Stacktrace:", + " [1] throw_boundserror(A::Vector{Float64}, I::Tuple{UnitRange{Int64}})", + " @ Base ./abstractarray.jl:691", + " [2] checkbounds", + " @ ./abstractarray.jl:656 [inlined]", + " [3] getindex(A::Vector{Float64}, I::UnitRange{Int64})", + " @ Base ./array.jl:867", + " [4] gr_draw_segments(series::Plots.Series, x::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, y::Vector{Float64}, z::Nothing, fillrange::Nothing, clims::Tuple{Float64, Float64})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:1825", + " [5] gr_add_series(sp::Plots.Subplot{Plots.GRBackend}, series::Plots.Series)", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:1742", + " [6] gr_display(sp::Plots.Subplot{Plots.GRBackend}, w::Measures.AbsoluteLength, h::Measures.AbsoluteLength, vp_canvas::Plots.GRViewport{Float64})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:964", + " [7] (::Plots.var\"#537#538\"{Int64, Int64, Plots.GRViewport{Float64}})(sp::Plots.Subplot{Plots.GRBackend})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:688", + " [8] foreach(f::Plots.var\"#537#538\"{Int64, Int64, Plots.GRViewport{Float64}}, itr::Vector{Plots.Subplot})", + " @ Base ./abstractarray.jl:2712", + " [9] gr_display(plt::Plots.Plot{Plots.GRBackend}, dpi_factor::Float64)", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:688", + " [10] #578", + " @ ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:2062 [inlined]", + " [11] withenv(::Plots.var\"#578#579\"{Plots.Plot{Plots.GRBackend}, Float64}, ::Pair{String, String}, ::Vararg{Pair{String, String}})", + " @ Base ./env.jl:172", + " [12] _show(io::IOStream, #unused#::MIME{Symbol(\"image/png\")}, plt::Plots.Plot{Plots.GRBackend})", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/backends/gr.jl:2057", + " [13] #invokelatest#2", + " @ ./essentials.jl:716 [inlined]", + " [14] invokelatest", + " @ ./essentials.jl:714 [inlined]", + " [15] show", + " @ ~/.julia/packages/Plots/ju9dp/src/output.jl:232 [inlined]", + " [16] #345", + " @ ~/.julia/packages/Plots/ju9dp/src/output.jl:6 [inlined]", + " [17] open(::Plots.var\"#345#346\"{Plots.Plot{Plots.GRBackend}}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})", + " @ Base ./io.jl:330", + " [18] open", + " @ ./io.jl:328 [inlined]", + " [19] png(plt::Plots.Plot{Plots.GRBackend}, fn::String)", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/output.jl:6", + " [20] savefig(plt::Plots.Plot{Plots.GRBackend}, fn::String)", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/output.jl:149", + " [21] savefig(fn::String)", + " @ Plots ~/.julia/packages/Plots/ju9dp/src/output.jl:154", + " [22] top-level scope", + " @ In[25]:6" + ] + } + ], + "source": [ + "right_axis = twinx()\n", + "\n", + "plot!(right_axis, saveat, solavg_ohm[:, 3], label=\"Ohmic\", ls=:dash, ylabel=L\"S_z\", ylimits=(-1.5, 1.5))\n", + "plot!(right_axis, saveat, solavg_col[:, 3], label=\"Non-Ohmic\", ls=:dash)\n", + "\n", + "savefig(\"./67_5.png\")" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "a1c77edf-652b-42ea-8bc0-445749a22a2c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.09472173866793361 and 3.1398692030437387\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: fail to reject h_0\n", + " one-sided p-value: 0.3150\n", + "\n", + "Details:\n", + " number of observations: 1000\n", + " JB statistic: 2.31051\n" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected_col[:, 125, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "48b2963f-d070-46c9-a077-fe4aad09155a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/Comparison-Copy2.ipynb b/runs/Comparison-Copy2.ipynb new file mode 100644 index 0000000..61f15da --- /dev/null +++ b/runs/Comparison-Copy2.ipynb @@ -0,0 +1,2478 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 39, + "id": "e47f1fd3-c09d-43cb-80c8-64f42e8161a4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "using HypothesisTests\n", + "using LaTeXStrings\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 1000\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .2\n", + "noise = ClassicalNoise(T);\n", + "\n", + "theta = pi * 1/4\n", + "\n", + "s0 = [0, 1, cos(theta)]\n", + "s0 = s0 ./ norm(s0)\n", + "\n", + "J0 = 1.\n", + "JH = Nchain(1, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:55\u001b[39m\n" + ] + } + ], + "source": [ + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_ohm = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_ohm[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "a4e3af5e-2db7-4f18-b9e2-113c9091afe6", + "metadata": {}, + "outputs": [], + "source": [ + "solavg_ohm = mean(sols_ohm, dims=1)[1, :, :];\n", + "solstd_ohm = std(sols_ohm, dims=1)[1, :, :];\n", + "\n", + "velavg_ohm = solavg_ohm[2:N, :] .- solavg_ohm[1:N-1, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "adcc1f01-a10b-4727-9766-72f003e7044a", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat[2:N], velavg_ohm[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "3422af78-2f32-468c-a8a3-a0732a836fd1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:26\u001b[39m\n" + ] + } + ], + "source": [ + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_col = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_col[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "fbae64d8-54f9-4c81-868f-91ac450cca74", + "metadata": {}, + "outputs": [], + "source": [ + "solavg_col = mean(sols_col, dims=1)[1, :, :];\n", + "solstd_col = std(sols_col, dims=1)[1, :, :];\n", + "\n", + "velavg_col = solavg_col[2:N, :] .- solavg_col[1:N-1, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "2540ee8c-7f89-4a3c-82fd-22a0a9e08cc0", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat[1:200], velavg_col[1:200, 3])\n", + "\n", + "axis = twinx()\n", + "plot!(axis, saveat[1:200], solavg_col[1:200, 3], label=L\"s_z\", ls=:dash)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1], label=L\"\\Delta s_x\")\n", + "plot!(saveat, solstd_col[:, 2], label=L\"\\Delta s_y\")\n", + "\n", + "axis = twinx()\n", + "plot!(axis, saveat, solavg_col[:, 3], label=L\"s_z\", ls=:dash)" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1])\n", + "plot!(saveat, solstd_col[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg_ohm[:, 3])\n", + "plot!(saveat, solavg_col[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected_ohm = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_ohm)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_ohm[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_ohm[j, i, 1] = dot(u,b)\n", + " projected_ohm[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "id": "f1661b24-42b1-4f59-989a-54dc3ed03bf8", + "metadata": {}, + "outputs": [], + "source": [ + "projected_col = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_col)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_col[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_col[j, i, 1] = dot(u,b)\n", + " projected_col[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB_ohm = zeros(N)\n", + "for i in 1:N\n", + " JB_ohm[i] = HypothesisTests.JarqueBeraTest(projected_ohm[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "51ccaeb8-2b3d-4630-afc3-2640142c4d54", + "metadata": {}, + "outputs": [], + "source": [ + "JB_col = zeros(N)\n", + "for i in 1:N\n", + " JB_col[i] = HypothesisTests.JarqueBeraTest(projected_col[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, JB_ohm, title=\"JB Test for Ohmic and Non-Ohmic Coupling\", label=\"Ohmic\", linewidth=2, xlabel=\"Time\", ylabel=\"JB Test\", legend=:topleft, ylimits=(0, 400))\n", + "plot!(saveat, JB_col, label=\"Non-Ohmic\", linewidth=2)" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "ad2674ba-9711-4feb-96ab-a39d88b27ce5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"/work/benstem/SpiDySims/runs/45.png\"" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "right_axis = twinx()\n", + "\n", + "plot!(right_axis, saveat, solavg_ohm[:, 3], label=\"Ohmic\", ls=:dash, ylabel=L\"S_z\", ylimits=(-1.5, 1.5))\n", + "plot!(right_axis, saveat, solavg_col[:, 3], label=\"Non-Ohmic\", ls=:dash)\n", + "\n", + "savefig(\"./45.png\")" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "a1c77edf-652b-42ea-8bc0-445749a22a2c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.1670969424751246 and 2.352471247359044\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: reject h_0\n", + " one-sided p-value: <1e-48\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 221.241\n" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected_col[:, 125, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "48b2963f-d070-46c9-a077-fe4aad09155a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(10000, 1001, 2)" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "size(projected_ohm)" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "id": "74f52e41-7867-40da-8acb-8fff6df32a5c", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram2d(projected_ohm[:, 250, 1], projected_ohm[:, 250, 2], bins=50)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "24f34aa7-c00d-444b-9fcb-f11ddcbdee43", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram2d(projected_col[:, 250, 1], projected_col[:, 250, 2], bins=50)" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "id": "b26e685a-eeb4-47d1-aeb9-2e9d2275f5e8", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[36m\u001b[1m[ \u001b[22m\u001b[39m\u001b[36m\u001b[1mInfo: \u001b[22m\u001b[39mSaved animation to /work/benstem/SpiDySims/runs/45_hist_ohm.gif\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Plots.AnimatedGif(\"/work/benstem/SpiDySims/runs/45_hist_ohm.gif\")" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Function to create a single histogram plot\n", + "function plot_histogram(i)\n", + " histogram2d(projected_ohm[:, i, 1], projected_ohm[:, i, 2], nbins=50, xlims=(-1, 1), ylims=(-1, 1), title=\"Time: $(i/5)\")\n", + "end\n", + "\n", + "# Create the animation\n", + "anim = @animate for i in 1:200\n", + " plot_histogram(i)\n", + "end\n", + "\n", + "# Save the animation as a gif\n", + "gif(anim, \"45_hist_ohm.gif\", fps=10)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "c5c2e13f-3a0a-41b9-b066-84c0f95dd04f", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[36m\u001b[1m[ \u001b[22m\u001b[39m\u001b[36m\u001b[1mInfo: \u001b[22m\u001b[39mSaved animation to /work/benstem/SpiDySims/runs/45_hist_col.gif\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Plots.AnimatedGif(\"/work/benstem/SpiDySims/runs/45_hist_col.gif\")" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Function to create a single histogram plot\n", + "function plot_histogram(i)\n", + " histogram2d(projected_col[:, i, 1], projected_col[:, i, 2], nbins=50, xlims=(-1, 1), ylims=(-1, 1), title=\"Time: $(i/5)\")\n", + "end\n", + "\n", + "# Create the animation\n", + "anim = @animate for i in 1:100\n", + " plot_histogram(i)\n", + "end\n", + "\n", + "# Save the animation as a gif\n", + "gif(anim, \"45_hist_col.gif\", fps=10)" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "id": "cd4c4953-57ec-44dd-9f4c-07faff6726f2", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat[1:200], solavg_col[1:200, 1])\n", + "plot!(twinx(), saveat[1:200], solavg_col[1:200, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "id": "a7183f4c-b998-4df1-8be4-ba687e837074", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot_histogram(400)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cff3a62d-8ffe-4e55-867b-03a79059c05f", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/Comparison-Copy3.ipynb b/runs/Comparison-Copy3.ipynb new file mode 100644 index 0000000..5f439ff --- /dev/null +++ b/runs/Comparison-Copy3.ipynb @@ -0,0 +1,671 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "e47f1fd3-c09d-43cb-80c8-64f42e8161a4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 1000\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "theta = pi * 6/8\n", + "\n", + "s0 = [0, 1, cos(theta)]\n", + "s0 = s0 ./ norm(s0)\n", + "\n", + "J0 = 1.\n", + "JH = Nchain(1, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 63%|█████████████████████████▉ | ETA: 0:00:31\u001b[39m9:19\u001b[39mbase64 binary data: DQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\n", + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:01:05\u001b[39m\n" + ] + } + ], + "source": [ + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_ohm = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_ohm[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_ohm = mean(sols_ohm, dims=1)[1, :, :];\n", + "solstd_ohm = std(sols_ohm, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "3422af78-2f32-468c-a8a3-a0732a836fd1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:15\u001b[39m\n" + ] + } + ], + "source": [ + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_col = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_col[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_col = mean(sols_col, dims=1)[1, :, :];\n", + "solstd_col = std(sols_col, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests\n", + "using LaTeXStrings" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1], label=L\"\\Delta s_x\")\n", + "plot!(saveat, solstd_col[:, 2], label=L\"\\Delta s_y\")\n", + "\n", + "axis = twinx()\n", + "plot!(axis, saveat, solavg_col[:, 3], label=L\"s_z\", ls=:dash)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1])\n", + "plot!(saveat, solstd_col[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg_ohm[:, 3])\n", + "plot!(saveat, solavg_col[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected_ohm = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_ohm)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_ohm[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_ohm[j, i, 1] = dot(u,b)\n", + " projected_ohm[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f1661b24-42b1-4f59-989a-54dc3ed03bf8", + "metadata": {}, + "outputs": [], + "source": [ + "projected_col = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_col)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_col[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_col[j, i, 1] = dot(u,b)\n", + " projected_col[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB_ohm = zeros(N)\n", + "for i in 1:N\n", + " JB_ohm[i] = HypothesisTests.JarqueBeraTest(projected_ohm[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "51ccaeb8-2b3d-4630-afc3-2640142c4d54", + "metadata": {}, + "outputs": [], + "source": [ + "JB_col = zeros(N)\n", + "for i in 1:N\n", + " JB_col[i] = HypothesisTests.JarqueBeraTest(projected_col[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, JB_ohm, title=\"JB Test for Ohmic and Non-Ohmic Coupling\", label=\"Ohmic\", linewidth=2, xlabel=\"Time\", ylabel=\"JB Test\", legend=:topleft, ylimits=(0, 200))\n", + "plot!(saveat, JB_col, label=\"Non-Ohmic\", linewidth=2)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "ad2674ba-9711-4feb-96ab-a39d88b27ce5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"/work/benstem/SpiDySims/runs/135.png\"" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "right_axis = twinx()\n", + "\n", + "plot!(right_axis, saveat, solavg_ohm[:, 3], label=\"Ohmic\", ls=:dash, ylabel=L\"S_z\", ylimits=(-1.5, 1.5))\n", + "plot!(right_axis, saveat, solavg_col[:, 3], label=\"Non-Ohmic\", ls=:dash)\n", + "\n", + "savefig(\"./135.png\")" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "a1c77edf-652b-42ea-8bc0-445749a22a2c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.3733609401457007 and 3.1341598219562954\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: reject h_0\n", + " one-sided p-value: <1e-05\n", + "\n", + "Details:\n", + " number of observations: 1000\n", + " JB statistic: 23.983\n" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected_col[:, 125, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "b0f70a5b-db25-4b7c-b78f-15df38037947", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1000, 1001, 2)" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "size(projected_ohm)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "51c758ea-1611-49d4-aae0-83416a2c3459", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[36m\u001b[1m[ \u001b[22m\u001b[39m\u001b[36m\u001b[1mInfo: \u001b[22m\u001b[39mSaved animation to /work/benstem/SpiDySims/runs/45_hist_col.gif\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Plots.AnimatedGif(\"/work/benstem/SpiDySims/runs/45_hist_col.gif\")" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function plot_histogram(i)\n", + " histogram2d(projected_col[:, i, 1], projected_col[:, i, 2], nbins=50, xlims=(-.5, .5), ylims=(-.5, .5), title=\"Time: $(i/5)\")\n", + "end\n", + "\n", + "# Create the animation\n", + "anim = @animate for i in 1:200\n", + " plot_histogram(i)\n", + "end\n", + "\n", + "# Save the animation as a gif\n", + "gif(anim, \"135_hist_col.gif\", fps=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e9f17aca-7569-4f7d-98f6-2c0a08c3dd8f", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/Comparison.ipynb b/runs/Comparison.ipynb new file mode 100644 index 0000000..89c680c --- /dev/null +++ b/runs/Comparison.ipynb @@ -0,0 +1,692 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "e47f1fd3-c09d-43cb-80c8-64f42e8161a4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 1000\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "theta = pi * 1/2\n", + "\n", + "s0 = [0, 1, cos(theta)]\n", + "s0 = s0 ./ norm(s0)\n", + "\n", + "J0 = 1.\n", + "JH = Nchain(1, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:01:11\u001b[39m6:19\u001b[39m\n" + ] + } + ], + "source": [ + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_ohm = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_ohm[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_ohm = mean(sols_ohm, dims=1)[1, :, :];\n", + "solstd_ohm = std(sols_ohm, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "3422af78-2f32-468c-a8a3-a0732a836fd1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:15\u001b[39m\n" + ] + } + ], + "source": [ + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "\n", + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols_col = zeros(nruns, length(saveat), 3)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols_col[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg_col = mean(sols_col, dims=1)[1, :, :];\n", + "solstd_col = std(sols_col, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests\n", + "using LaTeXStrings" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1], label=L\"\\Delta s_x\")\n", + "plot!(saveat, solstd_col[:, 2], label=L\"\\Delta s_y\")\n", + "\n", + "axis = twinx()\n", + "plot!(axis, saveat, solavg_col[:, 3], label=L\"s_z\", ls=:dash)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solstd_col[:, 1])\n", + "plot!(saveat, solstd_col[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg_ohm[:, 3])\n", + "plot!(saveat, solavg_col[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected_ohm = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_ohm)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_ohm[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_ohm[j, i, 1] = dot(u,b)\n", + " projected_ohm[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f1661b24-42b1-4f59-989a-54dc3ed03bf8", + "metadata": {}, + "outputs": [], + "source": [ + "projected_col = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg_col)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols_col[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected_col[j, i, 1] = dot(u,b)\n", + " projected_col[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB_ohm = zeros(N)\n", + "for i in 1:N\n", + " JB_ohm[i] = HypothesisTests.JarqueBeraTest(projected_ohm[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "51ccaeb8-2b3d-4630-afc3-2640142c4d54", + "metadata": {}, + "outputs": [], + "source": [ + "JB_col = zeros(N)\n", + "for i in 1:N\n", + " JB_col[i] = HypothesisTests.JarqueBeraTest(projected_col[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat[5:N], JB_ohm[5:N], title=\"JB Test for Ohmic and Non-Ohmic Coupling\", label=\"Ohmic\", linewidth=2, xlabel=\"Time\", ylabel=\"JB Test\", legend=:topleft, ylimits=(0, 200))\n", + "plot!(saveat[5:N], JB_col[5:N], label=\"Non-Ohmic\", linewidth=2)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "ad2674ba-9711-4feb-96ab-a39d88b27ce5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"/work/benstem/SpiDySims/runs/90.png\"" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "right_axis = twinx()\n", + "\n", + "plot!(right_axis, saveat, solavg_ohm[:, 3], label=\"Ohmic\", ls=:dash, ylabel=L\"S_z\", ylimits=(-1.5, 1.5))\n", + "plot!(right_axis, saveat, solavg_col[:, 3], label=\"Non-Ohmic\", ls=:dash)\n", + "\n", + "savefig(\"./90.png\")" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "a1c77edf-652b-42ea-8bc0-445749a22a2c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.05774318582232778 and 2.9724957756989863\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: fail to reject h_0\n", + " one-sided p-value: 0.0531\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 5.87233\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected_col[:, 125, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "5635c908-03cf-4e4c-98bb-4f2a700e349d", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[36m\u001b[1m[ \u001b[22m\u001b[39m\u001b[36m\u001b[1mInfo: \u001b[22m\u001b[39mSaved animation to /work/benstem/SpiDySims/runs/90_hist_ohm.gif\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Plots.AnimatedGif(\"/work/benstem/SpiDySims/runs/90_hist_ohm.gif\")" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Function to create a single histogram plot\n", + "function plot_histogram(i)\n", + " histogram2d(projected_ohm[:, i, 1], projected_ohm[:, i, 2], nbins=50, xlims=(-.5, .5), ylims=(-.5, .5), title=\"Time: $(i/5)\")\n", + "end\n", + "\n", + "# Create the animation\n", + "anim = @animate for i in 1:200\n", + " plot_histogram(i)\n", + "end\n", + "\n", + "# Save the animation as a gif\n", + "gif(anim, \"90_hist_ohm.gif\", fps=10)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "9f452292-42d4-4c8c-ace2-6a1b7b4131d9", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[36m\u001b[1m[ \u001b[22m\u001b[39m\u001b[36m\u001b[1mInfo: \u001b[22m\u001b[39mSaved animation to /work/benstem/SpiDySims/runs/90_hist_col.gif\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Plots.AnimatedGif(\"/work/benstem/SpiDySims/runs/90_hist_col.gif\")" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Function to create a single histogram plot\n", + "function plot_histogram(i)\n", + " histogram2d(projected_col[:, i, 1], projected_col[:, i, 2], nbins=50, xlims=(-.5, .5), ylims=(-.5, .5), title=\"Time: $(i/5)\")\n", + "end\n", + "\n", + "# Create the animation\n", + "anim = @animate for i in 1:200\n", + " plot_histogram(i)\n", + "end\n", + "\n", + "# Save the animation as a gif\n", + "gif(anim, \"90_hist_col.gif\", fps=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "48b2963f-d070-46c9-a077-fe4aad09155a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/Grid.ipynb b/runs/Grid.ipynb new file mode 100644 index 0000000..7b568e5 --- /dev/null +++ b/runs/Grid.ipynb @@ -0,0 +1,1049 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 13, + "id": "f52c5daf-9123-4b36-b83c-d5d2bcae5d91", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "100" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .1\n", + "N = 300\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "nspin = 1 # number of spins (nspin * nspin)\n", + "\n", + "s0 = zeros(3*nspin*nspin)\n", + "for i in 1:nspin\n", + " ϵ = 0.1\n", + " s0tmp = [ϵ*rand(), ϵ*rand(), -1]\n", + " s0[1+(i-1)*3:3+(i-1)*3] = s0tmp./norm(s0tmp)\n", + "end\n", + "J0 = 1.\n", + "JH = NNlattice(nspin, J0, J0, boundary=:periodic)\n", + "\n", + "nruns = 100" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n", + "(3, 301)(3, 301)" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 2%|▉ | ETA: 0:00:31\u001b[39m" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:01\u001b[39m\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)(3, 301)" + ] + } + ], + "source": [ + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols = zeros(nruns, length(saveat), 3*nspin*nspin)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat)\n", + " print(size(sol))\n", + " sols[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg = mean(sols, dims=1)[1, :, :];\n", + "solstd = std(sols, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 1], ribbon=solstd[:, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 2], ribbon=solstd[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 3], ribbon=solstd[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected[j, i, 1] = dot(u,b)\n", + " projected[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "03467eca-3f0c-4bd4-b3f7-5649b68780bc", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 70, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "9c6484d3-3396-47bb-b063-98e8d013d020", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 70, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f6df949c-15b2-447f-a264-8ef48ce1725e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "nth_moment (generic function with 1 method)" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function nth_moment(data, N)\n", + " return mean(data .^ N)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB = zeros(N)\n", + "for i in 10:N\n", + " JB[i] = HypothesisTests.JarqueBeraTest(projected[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "3ad3f882-caa1-4dfc-b83c-3b57c214ecea", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(10:N, JB[10:N])" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "bb3c6b84-5b21-4d79-b5bc-3345a8f2d893", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"0.024334226316224686 and 2.969023598052513\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: fail to reject h_0\n", + " one-sided p-value: 0.4999\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 1.38673\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected[:, 197, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "e331f6c7-fb4b-4f21-84d3-6a3f203a95b6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"0.019720125889005284 and 2.974701096764015\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: fail to reject h_0\n", + " one-sided p-value: 0.6329\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 0.91482\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected[:, 200, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "240660fb-d008-4dab-8bc1-aaf530885102", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8150abab-cacc-4617-9d95-bebdc4c7cac8", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/LLB.ipynb b/runs/LLB.ipynb new file mode 100644 index 0000000..6b03210 --- /dev/null +++ b/runs/LLB.ipynb @@ -0,0 +1,248 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 16, + "id": "c265b324-30c9-451c-a23d-31cadf964a2c", + "metadata": {}, + "outputs": [], + "source": [ + "using LinearAlgebra\n", + "using Plots" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "d3e2294e-e773-44ec-a654-d715230ef135", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "100×3 Matrix{Float64}:\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " ⋮ \n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0\n", + " 0.0 0.0 0.0" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "delta_t = 0.001\n", + "T = 0.01\n", + "\n", + "m_0 = [1., 0, 0]\n", + "\n", + "H_ext = [0, 0, 1.]\n", + "\n", + "sols = zeros(100, 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "07fe4cf9-e12b-4263-923a-1c2346c61e56", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "llb_step (generic function with 1 method)" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function llb_step(m, dt, T, H_ext)\n", + " H_eff = H_ext\n", + " alpha_par = .1\n", + " alpha_ort = .1\n", + " gamma = 1 # 1.76*10^-11\n", + " return gamma .* ( .- cross(m, H_eff) .- alpha_par / dot(m, m) .* dot(m, H_eff) .- alpha_ort / dot(m, m) * cross(m, cross(m, H_eff))) * dt\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "6e309085-abeb-4c34-8a1b-4e3ffc542fc9", + "metadata": {}, + "outputs": [], + "source": [ + "m = m_0\n", + "for i in 1:100\n", + " m = llb_step(m, delta_t, T, H_ext)\n", + " sols[i, :] = m\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "1dbcada3-b98e-4e74-98b9-6af9373f3867", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "100×3 Matrix{Float64}:\n", + " -0.0 0.001 0.0001\n", + " -0.00990199 -0.00991089 -0.00980198\n", + " 0.00332949 0.00330965 0.00341991\n", + " -0.0101746 -0.0101678 -0.0100722\n", + " 0.00324336 0.00322304 0.00333352\n", + " -0.0104478 -0.0104412 -0.0103456\n", + " 0.00315844 0.00313757 0.00324832\n", + " -0.0107322 -0.0107256 -0.01063\n", + " 0.00307467 0.00305323 0.00316426\n", + " -0.0110283 -0.011022 -0.0109263\n", + " 0.002992 0.00296997 0.00308128\n", + " -0.0113372 -0.011331 -0.0112352\n", + " 0.0029104 0.00288775 0.00299937\n", + " ⋮ \n", + " 0.000451695 0.000285996 0.000468889\n", + " -0.0927667 -0.0927506 -0.092668\n", + " 0.000418663 0.000233152 0.000425948\n", + " -0.103663 -0.103643 -0.103563\n", + " 0.000391809 0.00018451 0.000388198\n", + " -0.11481 -0.114785 -0.114709\n", + " 0.000371749 0.000142161 0.000356993\n", + " -0.124934 -0.124905 -0.124832\n", + " 0.000358351 0.00010852 0.000333473\n", + " -0.132696 -0.132662 -0.132593\n", + " 0.00035051 8.51602e-5 0.000317874\n", + " -0.137565 -0.137528 -0.13746" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sols" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "b8e823ee-a493-420f-b982-0925509645d5", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(sols[:, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1923be04-709f-4f9a-af44-4f944033b7f5", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/Projections-Copy1.ipynb b/runs/Projections-Copy1.ipynb new file mode 100644 index 0000000..292fb34 --- /dev/null +++ b/runs/Projections-Copy1.ipynb @@ -0,0 +1,991 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "f52c5daf-9123-4b36-b83c-d5d2bcae5d91", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10000" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using SpiDy\n", + "using NPZ\n", + "using DataFrames\n", + "using CSV\n", + "using ProgressMeter\n", + "using Random\n", + "using Statistics\n", + "using LinearAlgebra\n", + "using Plots\n", + "\n", + "########################\n", + "########################\n", + "\n", + "Δt = .2\n", + "N = 600\n", + "tspan = (0., N*Δt)\n", + "saveat = (0:1:N)*Δt\n", + "\n", + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "\n", + "α = 0.16\n", + "ω0 = 1.4\n", + "Γ = 0.5\n", + "\n", + "\n", + "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", + "matrix = AnisoCoupling([-sin(π/4) 0. 0. # coupling to the environment\n", + " 0. 0. 0.\n", + " cos(π/4) 0. 0.]);\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", + "T = .01\n", + "noise = ClassicalNoise(T);\n", + "\n", + "nspin = 1 # number of spins\n", + "\n", + "s0 = [0, 1, 1] ./ sqrt(2)\n", + "J0 = 1.\n", + "JH = Nchain(nspin, J0)\n", + "\n", + "nruns = 10000" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Starting...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:01:39\u001b[39m2:11\u001b[39m\n" + ] + } + ], + "source": [ + "println(\"Starting...\")\n", + "progress = Progress(nruns);\n", + "\n", + "sols = zeros(nruns, length(saveat), 3*nspin)\n", + "\n", + "Threads.@threads for i in 1:nruns\n", + " bfields = [bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise),\n", + " bfield(N, Δt, J, noise)];\n", + " sol = diffeqsolver(s0, tspan, J, bfields, matrix; JH=JH, saveat=saveat);\n", + " sols[i, :, :] = transpose(sol[:, :])\n", + " next!(progress)\n", + "end\n", + "\n", + "solavg = mean(sols, dims=1)[1, :, :];\n", + "solstd = std(sols, dims=1)[1, :, :];" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 1], ribbon=solstd[:, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "a06addc4-47b2-4467-8148-3e68f3eae702", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 2], ribbon=solstd[:, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(saveat, solavg[:, 3], ribbon=solstd[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", + "metadata": {}, + "outputs": [], + "source": [ + "projected = zeros(nruns, length(saveat), 2)\n", + "\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg)]\n", + "\n", + "Threads.@threads for i in 1:length(saveat)\n", + " n = normalized_avg[i, :][1]\n", + "\n", + " u = normalize(cross(n, [0,0,1]))\n", + " v = cross(u, n)\n", + "\n", + " for j in 1:nruns\n", + " b = sols[j, i, :]\n", + " proj = dot(b, n) * n\n", + " b_ort = b - proj\n", + "\n", + " projected[j, i, 1] = dot(u,b)\n", + " projected[j, i, 2] = dot(v,b)\n", + " end\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "03467eca-3f0c-4bd4-b3f7-5649b68780bc", + "metadata": {}, + "outputs": [ + { + "ename": "LoadError", + "evalue": "UndefVarError: projected not defined", + "output_type": "error", + "traceback": [ + "UndefVarError: projected not defined", + "", + "Stacktrace:", + " [1] top-level scope", + " @ In[1]:1" + ] + } + ], + "source": [ + "histogram(projected[:, 50, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "9c6484d3-3396-47bb-b063-98e8d013d020", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 280, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f6df949c-15b2-447f-a264-8ef48ce1725e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "nth_moment (generic function with 1 method)" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function nth_moment(data, N)\n", + " return mean(data .^ N)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", + "metadata": {}, + "outputs": [], + "source": [ + "using HypothesisTests" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", + "metadata": {}, + "outputs": [], + "source": [ + "JB = zeros(N)\n", + "for i in 10:N\n", + " JB[i] = HypothesisTests.JarqueBeraTest(projected[:, i, 1]).JB\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "ebf486ee-5e68-45ba-b98d-b25e08d766b7", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "attempt to save state beyond implementation limit\n" + ] + } + ], + "source": [ + "plot(saveat[1:N-1], JB[1:N-1])" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "2ba81fb8-bfed-40f2-8d33-4b1447a162b3", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot!(saveat, solavg[:, 3])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6ac5d053-d730-4118-8a73-f4af439a4058", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "histogram(projected[:, 200, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "1f7d2316-131d-4faf-941e-eb4ca032727c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.17966985914759054 and 3.1431723658541975\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: reject h_0\n", + " one-sided p-value: <1e-13\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 62.3431\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "HypothesisTests.JarqueBeraTest(projected[:, 200, 1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6c63a170-6eff-4c8b-8b80-542eb705666f", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.7.3", + "language": "julia", + "name": "julia-1.7" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/runs/Projections.ipynb b/runs/Projections.ipynb index 6be940b..0d81ec7 100644 --- a/runs/Projections.ipynb +++ b/runs/Projections.ipynb @@ -9,7 +9,7 @@ { "data": { "text/plain": [ - "1000" + "10000" ] }, "execution_count": 1, @@ -31,37 +31,38 @@ "########################\n", "########################\n", "\n", - "Δt = 1\n", - "N = 200\n", + "Δt = .2\n", + "N = 600\n", "tspan = (0., N*Δt)\n", "saveat = (0:1:N)*Δt\n", - "α = 0.16\n", - "ω0 = 1.4\n", - "Γ = 0.5\n", + "\n", + "α = 10. # 0.16\n", + "ω0 = 7. # 1.4\n", + "Γ = 5. # 0.5\n", + "\n", + "\n", "J = LorentzianSD(α, ω0, Γ) # coloring the noise\n", "matrix = AnisoCoupling([-sin(π/4) 0. 0. # coupling to the environment\n", " 0. 0. 0.\n", " cos(π/4) 0. 0.]);\n", + "\n", + "matrix = IsoCoupling(1)\n", + "\n", "T = .01\n", "noise = ClassicalNoise(T);\n", "\n", "nspin = 1 # number of spins\n", "\n", - "s0 = zeros(3*nspin)\n", - "for i in 1:nspin\n", - " ϵ = 0.1\n", - " s0tmp = [ϵ*rand(), ϵ*rand(), -1]\n", - " s0[1+(i-1)*3:3+(i-1)*3] = s0tmp./norm(s0tmp)\n", - "end\n", + "s0 = [0, 1, 1] ./ sqrt(2)\n", "J0 = 1.\n", "JH = Nchain(nspin, J0)\n", "\n", - "nruns = 1000\n" + "nruns = 10000" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "6e3cdf02-c243-4622-a52a-a6d7f987c68d", "metadata": {}, "outputs": [ @@ -76,7 +77,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "\u001b[32mProgress: 7%|██▊ | ETA: 0:13:09\u001b[39m" + "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:06:29\u001b[39m3:53\u001b[39m\n" ] } ], @@ -101,46 +102,215 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "d16b97dd-b9f5-415c-b388-2b1f3344be45", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "plot(saveat, solavg[:, 1], ribbon=solstd[:, 1])" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "a06addc4-47b2-4467-8148-3e68f3eae702", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "plot(saveat, solavg[:, 2], ribbon=solstd[:, 2])" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "bc1686fd-d86d-42b0-9d87-bcb911526d00", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "plot(saveat, solavg[:, 3], ribbon=solstd[:, 3])" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "59ac92d9-6a78-402b-91ae-3f5fd22cc6ff", "metadata": {}, "outputs": [], "source": [ "projected = zeros(nruns, length(saveat), 2)\n", "\n", - "normalized_avg = eachrow(solavg) |> x -> normalize(x)\n", + "normalized_avg = [normalize(vec(row)) for row in eachrow(solavg)]\n", "\n", - "for i in 1:length(saveat)\n", + "Threads.@threads for i in 1:length(saveat)\n", " n = normalized_avg[i, :][1]\n", "\n", " u = normalize(cross(n, [0,0,1]))\n", @@ -159,30 +329,485 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "03467eca-3f0c-4bd4-b3f7-5649b68780bc", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "histogram(projected[:, 197, 1])" + "histogram(projected[:, 500, 1])" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "9c6484d3-3396-47bb-b063-98e8d013d020", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "histogram(projected[:, 20, 2])" + "histogram(projected[:, 500, 2])" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "f6df949c-15b2-447f-a264-8ef48ce1725e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "nth_moment (generic function with 1 method)" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "function nth_moment(data, N)\n", " return mean(data .^ N)\n", @@ -191,7 +816,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "e4ad51fc-0dc7-4106-99e4-2b29e54b1930", "metadata": {}, "outputs": [], @@ -201,7 +826,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "e5b9609e-f467-4bd7-9b51-9a4c1f175738", "metadata": {}, "outputs": [], @@ -214,38 +839,181 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "3ad3f882-caa1-4dfc-b83c-3b57c214ecea", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "plot(10:N, JB[10:N])" + "plot(saveat[10:N], JB[10:N])" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "bb3c6b84-5b21-4d79-b5bc-3345a8f2d893", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.06640955564275836 and 2.878302889621456\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: reject h_0\n", + " one-sided p-value: 0.0012\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 13.5213\n" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "HypothesisTests.JarqueBeraTest(projected[:, 197, 1])" + "HypothesisTests.JarqueBeraTest(projected[:, 400, 1])" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "e331f6c7-fb4b-4f21-84d3-6a3f203a95b6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "Jarque-Bera normality test\n", + "--------------------------\n", + "Population details:\n", + " parameter of interest: skewness and kurtosis\n", + " value under h_0: \"0 and 3\"\n", + " point estimate: \"-0.009755563978670194 and 3.0706123545537634\"\n", + "\n", + "Test summary:\n", + " outcome with 95% confidence: fail to reject h_0\n", + " one-sided p-value: 0.3269\n", + "\n", + "Details:\n", + " number of observations: 10000\n", + " JB statistic: 2.23616\n" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "HypothesisTests.JarqueBeraTest(projected[:, 200, 1])" + "HypothesisTests.JarqueBeraTest(projected[:, 2, 2])" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "240660fb-d008-4dab-8bc1-aaf530885102", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "64" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using Base.Threads\n", + "nthreads()" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "8150abab-cacc-4617-9d95-bebdc4c7cac8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " PID COMMAND VSZ RSS SIZE\n", + " 54147 julia 20209472 1568276 15911276\n" + ] + } + ], + "source": [ + "run(`ps -p $(getpid()) -o pid,comm,vsize,rss,size`);" ] }, { "cell_type": "code", "execution_count": null, - "id": "240660fb-d008-4dab-8bc1-aaf530885102", + "id": "e21d4205-2f8e-4b39-b1ea-ba722ea3fb13", "metadata": {}, "outputs": [], "source": [] @@ -253,15 +1021,15 @@ ], "metadata": { "kernelspec": { - "display_name": "Julia 1.9.4", + "display_name": "Julia 1.7.3", "language": "julia", - "name": "julia-1.9" + "name": "julia-1.7" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.9.4" + "version": "1.7.3" } }, "nbformat": 4, diff --git a/runs/std_22_5.png b/runs/std_22_5.png new file mode 100644 index 0000000..e8b25ed Binary files /dev/null and b/runs/std_22_5.png differ diff --git a/runs/std_45.png b/runs/std_45.png new file mode 100644 index 0000000..25b83e7 Binary files /dev/null and b/runs/std_45.png differ diff --git a/runs/std_67_5.png b/runs/std_67_5.png new file mode 100644 index 0000000..86651b7 Binary files /dev/null and b/runs/std_67_5.png differ diff --git a/runs/std_90.png b/runs/std_90.png new file mode 100644 index 0000000..bd58226 Binary files /dev/null and b/runs/std_90.png differ