diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4396eae..ee6a5bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,20 +11,9 @@ on: - 'setup.py' - 'setup.cfg' - 'pyproject.toml' - workflow_dispatch: - inputs: - linux: - type: boolean - required: true - default: true - other-os: - type: boolean - required: true - default: true jobs: linux-build: - if: ${{ inputs.linux }} runs-on: ubuntu-latest env: TWINE_USERNAME: __token__ @@ -50,7 +39,6 @@ jobs: continue-on-error: false other-os-build: - if: ${{ inputs.other-os }} runs-on: ${{ matrix.os }} env: TWINE_USERNAME: __token__ @@ -98,5 +86,5 @@ jobs: run: | gh release create "v${{ steps.get_version.outputs.version }}" \ --repo="$GITHUB_REPOSITORY" \ - --title="${GITHUB_REPOSITORY#*/} v${{ steps.get_version.outputs.version }}" \ + --title="${GITHUB_REPOSITORY#*/} ${{ steps.get_version.outputs.version }}" \ --generate-notes diff --git a/core/junction.hpp b/core/junction.hpp index fb5d509..cab2ca1 100644 --- a/core/junction.hpp +++ b/core/junction.hpp @@ -597,11 +597,15 @@ template class Layer { // dm1/dm1x x m2 = (0, -mz, my) // dm1/dm1y x m2 = (mz, 0, -mx) // dm1/dm1z x m2 = (-my, mx, 0) - const CVector dm1crossm2( - c_dot(Dvector, CVector(0, -coupledMag.z, coupledMag.y)), - c_dot(Dvector, CVector(coupledMag.z, 0, -coupledMag.x)), - c_dot(Dvector, CVector(-coupledMag.y, coupledMag.x, 0))); + // E = D z * (m1 x m2) == D m1 (m2 x z) + // dE/dm1 = D m2 x z + const CVector dm1crossm2 = -1.0 * c_cross(Dvector, coupledMag); return dm1crossm2 / (this->Ms * this->thickness); + // const CVector dm1crossm2( + // c_dot(Dvector, CVector(0, -coupledMag.z, coupledMag.y)), + // c_dot(Dvector, CVector(coupledMag.z, 0, -coupledMag.x)), + // c_dot(Dvector, CVector(-coupledMag.y, coupledMag.x, 0))); + // return dm1crossm2 / (this->Ms * this->thickness); } CVector calculateIDMI(T time, const CVector &stepMag, diff --git a/setup.py b/setup.py index a65bb01..b665255 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools import Extension, find_namespace_packages, setup from setuptools.command.build_ext import build_ext -__version__ = "1.6.1" +__version__ = "1.6.2" """ As per https://github.com/pybind/python_example diff --git a/view/simulation_fns.py b/view/simulation_fns.py index 93f099b..ff162da 100644 --- a/view/simulation_fns.py +++ b/view/simulation_fns.py @@ -35,7 +35,11 @@ def create_single_domain(id_: str) -> Layer: def create_single_layer(id_: str) -> tuple: """Do not forget to rescale the units!""" - demag = [CVector(0, 0, 0), CVector(0, 0, 0), CVector(0, 0, 1)] + demag = [ + CVector(st.session_state[f"Nxx{id_}"] * 1e-6, 0, 0), + CVector(0, st.session_state[f"Nyy{id_}"] * 1e-6, 0), + CVector(0, 0, st.session_state[f"Nzz{id_}"] * 1e-6), + ] Kdir = FieldScan.angle2vector( theta=st.session_state[f"theta_K{id_}"], phi=st.session_state[f"phi_K{id_}"] ) diff --git a/view/streamlit_app.py b/view/streamlit_app.py index e22a499..2c958c8 100644 --- a/view/streamlit_app.py +++ b/view/streamlit_app.py @@ -5,6 +5,24 @@ from autofit import autofit from helpers import simulate_pimm, simulate_vsd from utils import GENERIC_BOUNDS, GENERIC_UNITS +import json + + +def export_session_state(): + export_dict = {} + opts = ["_btn", "_file", "_state", "low_", "up_", "check_", "upload"] + for k, v in st.session_state.items(): + skip = any(forb_opts in k for forb_opts in opts) + if not skip: + export_dict[k] = v + + return json.dumps(export_dict) + + +def import_session_state(file): + for k, v in json.load(file).items(): + st.session_state[k] = v + with st.expander("# Read me"): st.write( @@ -17,13 +35,32 @@ ) with st.sidebar: - st.file_uploader( - "Upload your data here", - help="Upload your data here. Must be `\t` separated values and have H and f headers.", - type=["txt", "dat"], - accept_multiple_files=False, - key="upload", - ) + with st.expander("Export/Import"): + st.download_button( + label="Export session state", + data=export_session_state(), + file_name="session_state.json", + mime="application/json", + type="primary", + ) + + st.file_uploader( + "Upload session state", + help="Upload your data here. Must be `\t` separated values and have H and f headers.", + type=["json"], + accept_multiple_files=False, + key="import_file", + ) + if st.session_state.import_file: + import_session_state(st.session_state.import_file) + + st.file_uploader( + "Upload your data here", + help="Upload your data here. Must be `\t` separated values and have H and f headers.", + type=["txt", "dat"], + accept_multiple_files=False, + key="upload", + ) N = st.number_input( "Number of layers", min_value=1, max_value=10, value=1, key="N", format="%d" ) @@ -95,6 +132,25 @@ key=f"phi_K{i}", help="Azimuthal angle of the anisotropy axis", ) + st.write("Demagnetization field") + st.number_input( + f"Nxx ({i+1})", + value=0.0, + key=f"Nxx{i}", + format="%0.5f", + ) + st.number_input( + f"Nyy ({i+1})", + value=0.0, + key=f"Nyy{i}", + format="%0.5f", + ) + st.number_input( + f"Nzz ({i+1})", + value=1.0, + key=f"Nzz{i}", + format="%0.5f", + ) st.markdown("-----\n") with st.expander("Interlayer parameters"): @@ -150,7 +206,6 @@ help="Maximum frequency (cutoff) visible in plot", ) - pimm_tab, vsd_tab, opt_tab = st.tabs(["PIMM", "VSD", "Optimization"]) with opt_tab: with st.expander("Optimization parameters"): @@ -275,9 +330,9 @@ st.button("Simulate PIMM", on_click=simulate_pimm, key="PIMM_btn") st.number_input( "Hoe (kA/m)", - min_value=0.05, - max_value=50.0, - value=0.05, + min_value=-500.0, + max_value=500.0, + value=50.0, key="Hoe_mag", help="Magnitude of the Oersted field impulse (PIMM excitation)", )