Skip to content

Commit

Permalink
UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LemurPwned committed Dec 22, 2024
1 parent 9fc916e commit 09b2f1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 10 additions & 6 deletions view/simulation_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ def create_single_domain(id_: str) -> Layer:

def create_single_layer(id_: str) -> tuple:
"""Do not forget to rescale the units!"""
nxx = st.session_state[f"Nxx{id_}"]
nyy = st.session_state[f"Nyy{id_}"]
nzz = st.session_state[f"Nzz{id_}"]
demag = [
CVector(st.session_state[f"Nxx{id_}"], 0, 0),
CVector(0, st.session_state[f"Nyy{id_}"], 0),
CVector(0, 0, st.session_state[f"Nzz{id_}"]),
CVector(nxx, 0, 0),
CVector(0, nyy, 0),
CVector(0, 0, nzz),
]
demag_sum = nxx + nyy + nzz
if abs(demag_sum - 1.0) > 1e-5:
st.warning(f"Warning: Demagnetization tensor components should sum to 1.0 (Layer {id_})")
Kdir = FieldScan.angle2vector(
theta=st.session_state[f"theta_K{id_}"], phi=st.session_state[f"phi_K{id_}"]
)
Expand Down Expand Up @@ -142,9 +148,7 @@ def get_pimm_data(
):
htheta, hphi = get_axis_angles(H_axis)
hmin, hmax = min([Hmin, Hmax]), max([Hmin, Hmax]) # fix user input
Hscan, Hvecs = FieldScan.amplitude_scan(
hmin, hmax, Hsteps, htheta, hphi
)
Hscan, Hvecs = FieldScan.amplitude_scan(hmin, hmax, Hsteps, htheta, hphi)
if st.session_state["Hreturn"]:
Hscan = np.concatenate((Hscan, Hscan[::-1]))
Hvecs = np.concatenate((Hvecs, Hvecs[::-1]))
Expand Down
8 changes: 6 additions & 2 deletions view/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ def export_session_state():


def import_session_state(file):
for k, v in json.load(file).items():
st.session_state[k] = v
try:
data = json.load(file)
for k, v in data.items():
st.session_state[k] = v
except json.JSONDecodeError:
st.error("Error: Invalid JSON file format. Please upload a valid JSON file.")


with st.expander("# Read me"):
Expand Down

0 comments on commit 09b2f1b

Please sign in to comment.