Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/SMU-Simulation_Driver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,29 @@ def get_GUIparameter(self, parameter: dict) -> None: # noqa: N802
self.leakage = parameter.get("Linear Leakage factor", 1.0)
self.hysteresis = parameter.get("Hysteresis time constant", 0.0)

def initialize(self) -> None:
"""Initialize the device. This function is called only once at the start of the measurement."""
def configure(self) -> None:
"""Validate and type-convert the GUI parameters.

This runs at the start of a measurement and again on every reconfigure()
(e.g. when a Control Widget changes a value during a running loop). Doing
the conversion here - rather than in initialize(), which is called only
once - ensures the values stay correctly typed after each live update,
when get_GUIparameter() has re-read them as raw strings.
"""
self.protection = float(self.protection)
max_compliance = 1.0
if float(self.protection) > max_compliance:
if self.protection > max_compliance:
self.stop_Measurement(
f"Compliance {self.protection} is higher than the maximum compliance of {max_compliance}."
)
Comment on lines +151 to 156

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The compliance (self.protection) should be validated to ensure it is greater than 0. A zero or negative compliance value is physically invalid for an SMU and will cause incorrect clipping behavior in simulate_current().

Suggested change
self.protection = float(self.protection)
max_compliance = 1.0
if float(self.protection) > max_compliance:
if self.protection > max_compliance:
self.stop_Measurement(
f"Compliance {self.protection} is higher than the maximum compliance of {max_compliance}."
)
self.protection = float(self.protection)
if self.protection <= 0:
self.stop_Measurement("Compliance must be greater than 0.")
max_compliance = 1.0
if self.protection > max_compliance:
self.stop_Measurement(
f"Compliance {self.protection} is higher than the maximum compliance of {max_compliance}."
)

self.average = proof_average(self.average)
self.protection = float(self.protection)
self.saturation_current = float(self.saturation_current)
self.ideality_factor = float(self.ideality_factor)
if self.ideality_factor <= 0:
self.stop_Measurement("Ideality factor must be greater than 0.")
self.temperature = float(self.temperature)
Comment thread
FelixDollinger-SweepMe marked this conversation as resolved.
if self.temperature <= 0:
self.stop_Measurement("Temperature must be greater than 0 K.")
self.v_t = self.k * self.temperature / self.q
self.photocurrent = float(self.photocurrent)
self.noise = float(self.noise)
Expand Down
11 changes: 7 additions & 4 deletions src/Scope-Simulation_Driver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,13 @@ def get_GUIparameter(self, parameter: dict) -> None: # noqa: N802
self.plottype += [True] # True to plot data
self.savetype += [True] # True to save data

def initialize(self) -> None:
"""Convert GUI parameters to their destination formats."""
def configure(self) -> None:
"""Configure the device and convert GUI parameters to their destination formats.

The conversions live here rather than in initialize() so they are redone on
every reconfigure() (e.g. a live Control Widget change), where
get_GUIparameter() has just re-read these values as raw strings.
"""
if self.channel1:
self.channel1_range = float(self.channel1_range)
self.channel1_offset = float(self.channel1_offset)
Expand All @@ -135,8 +140,6 @@ def initialize(self) -> None:
self.channel2_range = float(self.channel2_range)
self.channel2_offset = float(self.channel2_offset)

def configure(self) -> None:
"""Configure the device."""
# If the Signal-Simulation driver is used in the sequencer, use its signal
self.use_simulated_signal = "Simulated signal" in self.device_communication

Expand Down
Loading