def run_cim(): if len(sys.argv) <= 1: print("usage: %s CIM_FILES" % sys.argv[0]) sys.exit(-1) files = sys.argv[1:] name = "python" system = dpsim.load_cim(name, files, frequency=60) sw = dpsim.dp.ph1.Switch("DP_SynGen_TrStab_Step_StepLoad") sw.resistance_open = 1e9 sw.resistance_closed = 0.1 sw.closed = False sw.connect([dpsim.dp.Node.GND(), system.nodes["BUS9"]]) system.add_component(sw) sim = dpsim.Simulation(name, system, timestep=0.0001, duration=0.1, pbar=True) sim.add_switch_event(sw, 0.05, True) sim.run()
def do_sim(self, scheduler=None, scheduler_args={}, size=1): times = [] if size > 1: # TODO a bit ugly copy_args = self.copy_settings.copy() decouple = copy_args['decouple'] del (copy_args['decouple']) for i in range(0, self.repetitions): sys = dpsim.load_cim(self.name, self.files, self.frequency, log_level=0) if size > 1: if decouple == 'diakoptics': self.sim_args['tear_components'] = multiply_diakoptics( sys, size - 1, **copy_args) elif decouple: multiply_decoupled(sys, size - 1, **copy_args) else: multiply_coupled(sys, size - 1, **copy_args) sim = dpsim.Simulation(self.name, sys, **self.sim_args) if scheduler: sim.set_scheduler(scheduler, **scheduler_args) sim.run() times.append(sim.avg_step_time) if 'tear_components' in self.sim_args: del (self.sim_args['tear_components']) avg = sum(times) / len(times) sigma = math.sqrt(sum([(x - avg)**2 for x in times]) / len(times)) return (avg, sigma)
def load_cim(self, fp): if fp is not None: self.sim = dpsim.load_cim(fp.name) self.logger.info(self.sim) os.unlink(fp.name)
import matplotlib matplotlib.use('SVG') import matplotlib.pyplot as plt name = 'WSCC-9bus_RX_dyn' files = glob.glob('../dpsim/Examples/CIM/WSCC-09_RX_Dyn/*.xml') threads = [1, 2, 4, 8, 16] sizes = range(1, 32) scheduler = 'thread_level' reps = 5 for size in sizes: filename = "measurements_" + str(size) + ".txt" if not os.path.isfile(filename): system = dpsim.load_cim(name, files, frequency=60) if size > 1: system.multiply(size - 1) sim = dpsim.Simulation(name, system, timestep=0.001, duration=0.5, init_steady_state=True, pbar=False, split_subnets=True, log_level=0) sim.set_scheduler('sequential', out_measurement_file=filename) sim.run() step_times = {} for n in threads:
from dpsim.Event import Event import glob import datetime import logging l = logging.getLogger() l.setLevel(logging.DEBUG) l.debug('test') name = 'WSCC-9bus_dyn_switch' config = './villas-node.conf' files = glob.glob('./Examples/CIM/WSCC-09_RX_Dyn/*.xml') # Load system toplogy from CIM files system = dpsim.load_cim(name, files, frequency=60, log_level=0) ## Switch sw = dpsim.dp.ph1.Switch("Switch") sw.resistance_open = 1e9 sw.resistance_closed = 0.1 sw.closed = False ## Load load = dpsim.dp.ph1.PQLoadCS("Switched Load") load.v_nom = 230950 load.power_active = 30000000 load.power_reactive = 0