Skip to content

Commit

Permalink
Add tests for coil_current
Browse files Browse the repository at this point in the history
- Adds new parameters into the test framework
  • Loading branch information
spauka committed Jan 25, 2018
1 parent 0d9ca3a commit e7be8e7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
9 changes: 9 additions & 0 deletions qcodes/instrument/sims/AMI430.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ devices:
q: "RAMP"
r: OK

current rating:
default: 3
getter:
q: "CURR:RATING?"
r: "{}"
setter:
q: "CONF:CURR:RATING {}"
r: OK


resources: # we always need three power supplies; one for each axis. For the testing we add a few more
GPIB::1::INSTR:
Expand Down
14 changes: 8 additions & 6 deletions qcodes/instrument_drivers/american_magnetics/AMI430.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,19 @@ def __init__(self, name, address=None, port=None,
'tesla': 1})

# Set programatic safety limits
if current_ramp_limit is None:
self._update_ramp_rate_limit(AMI430._DEFAULT_CURRENT_RAMP_LIMIT, update=False)
else:
self._update_ramp_rate_limit(current_ramp_limit, update=False)
self.add_parameter('current_ramp_limit',
get_cmd=lambda: self._current_ramp_limit,
set_cmd=self._update_ramp_rate_limit)
set_cmd=self._update_ramp_rate_limit,
unit="A/s")
self.add_parameter('field_ramp_limit',
get_cmd=lambda: self.current_ramp_limit(),
set_cmd=lambda x: self.current_ramp_limit(x),
scale=1/float(self.ask("COIL?")))
scale=1/float(self.ask("COIL?")),
unit="T/s")
if current_ramp_limit is None:
self._update_ramp_rate_limit(AMI430._DEFAULT_CURRENT_RAMP_LIMIT, update=False)
else:
self._update_ramp_rate_limit(current_ramp_limit, update=False)

# Add solenoid parameters
self.add_parameter('coil_constant',
Expand Down
13 changes: 7 additions & 6 deletions qcodes/tests/drivers/test_ami430.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,31 +385,32 @@ def test_warning_increased_max_ramp_rate():
ramp rate. We want the user to be really sure what he or she is
doing, as this could risk quenching the magnet
"""
max_ramp_rate = AMI430_VISA.default_current_ramp_limit
max_ramp_rate = AMI430_VISA._DEFAULT_CURRENT_RAMP_LIMIT
# Increasing the maximum ramp rate should raise a warning
target_ramp_rate = max_ramp_rate + 0.01

with pytest.raises(Warning) as excinfo:
with pytest.warns(Warning) as excinfo:
AMI430_VISA("testing_increased_max_ramp_rate",
address='GPIB::4::65535::INSTR', visalib=visalib,
terminator='\n', port=1,
current_ramp_limit=target_ramp_rate)

assert "Increasing maximum ramp rate" in excinfo.value.args[0]
assert len(excinfo) == 1 # Check we onlt saw one warning
assert "Increasing maximum ramp rate" in excinfo[0].message.args[0]


def test_ramp_rate_exception(current_driver):
"""
Test that an exception is raised if we try to set the ramp rate
to a higher value than is allowed
"""
max_ramp_rate = AMI430_VISA.default_current_ramp_limit
max_ramp_rate = AMI430_VISA._DEFAULT_CURRENT_RAMP_LIMIT
target_ramp_rate = max_ramp_rate + 0.01
ix = current_driver._instrument_x

with pytest.raises(Exception) as excinfo:
ix.ramp_rate(target_ramp_rate)

errmsg = "must be between 0 and {} inclusive".format(max_ramp_rate)
errmsg = "must be between 0 and {} inclusive".format(max_ramp_rate)

assert errmsg in excinfo.value.args[0]
assert errmsg in excinfo.value.args[0]

0 comments on commit e7be8e7

Please sign in to comment.