...
These components' workflow is optimized for manual usage. HYPERSIM will try to keep all related pins up to date during your model edition. Therefore, to allow full control of the configuration via the API, there is a parameter 'managedByAPI' for the emitter, which disables HYPERSIM automated treatments. Please find below a simple example of how to use the radiolink bundles via the API.
Code Block | ||
---|---|---|
| ||
import sys# import osthe hypersim_dir = None # 'C:\OPAL-RT\HYPERSIM\hypersim_2021.2.0.o153' python_path = os.path.join(hypersim_dir, 'Windows', 'HyApi', 'C', 'py') sys.path.insert(1,python_path) importApi as HyWorksApi HyWorksApi.connectToHyWorks() # Some APIs require a call to HyWorksApi.openModel(), but in this example, we assume an empty design is already open. # Emission source = HyWorksApi.addDevice('Network Sources.clf', 'AC V source', -1400, 0) measurement = HyWorksApi.addDevice('Network Measurements.clf', 'I measurement, 3-ph', 0, 0) resistance = HyWorksApi.addDevice('Network RLC.clf', 'R grounded', 2100, 350) pow = HyWorksApi.addDevice('Network Tools.clf', 'Point-on-wave', 2800, 350) emitter = HyWorksApi.addDevice('Signal Routing.clf', 'Radiolink emitter, bundle', 1400, 140) # Reception receiver = HyWorksApi.addDevice('Signal Routing.clf', 'Radiolink receiver, bundle', -1400, 1400) max = HyWorksApi.addDevice('Control Math Operations.clf', 'Max, 3-input', 0, 1400) # Connect power section HyWorksApi.connectDevices(source, 'net_1', measurement, 'net_1', False) HyWorksApi.connectDevices(measurement, 'net_2', resistance, 'net_1', False) HyWorksApi.connectDevices(measurement, 'net_2', pow, 'net_1', False) # Since we have to set component parameters, we need an analyze to let the engine know about the topology HyWorksApi.analyze() # Managed by API, this deactivates HYPERSIM auto connections on this radiolink. So we are in full control in the API HyWorksApi.setComponentParameter(emitter, 'managedByAPI', 'true') # Add the pins inside the bundle of the radiolink HyWorksApi.addPinsToDevice(emitter, "W", "I", ['Bundle[rlb_currentA]', 'Bundle[rlb_currentB]', 'Bundle[rlb_currentC]'], False) # Connect the radiolink to the measurement HyWorksApi.connectBundleToBundle(measurement, ['a', 'b', 'c'], emitter, ['rlb_currentA', 'rlb_currentB', 'rlb_currentC']) # Link both radiolinks via the linkname HyWorksApi.setComponentParameter(emitter, 'linkName', 'myRadiolinkBundle') HyWorksApi.setComponentParameter(receiver, 'linkName', 'myRadiolinkBundle') # Note that we do not need to manage the receiver by api, because the pin list should be the same as the emitter # with opposite directions. So we control the emitter, configure it, and let the receiver match the configuration # Connect the receiver HyWorksApi.connectPinToBundle(max, "u1", receiver, 'rlb_currentA') HyWorksApi.connectPinToBundle(max, "u2", receiver, 'rlb_currentB') HyWorksApi.connectPinToBundle(max, "u3", receiver, 'rlb_currentC') HyWorksApi.analyze() HyWorksApi.selectAllSensors(measurement) HyWorksApi.selectAllSensors(max) |
...