def prepare_simulation(self): r""" Set up a Spawning propagator for the simulation loop. Set the potential and initial values according to the configuration. :raise ValueError: For invalid or missing input data. """ potential = PotentialFactory().create_potential(self.parameters) N = potential.get_number_components() # Check for enough initial values if self.parameters["leading_component"] > N: raise ValueError("Leading component index out of range.") if len(self.parameters["parameters"]) < N: raise ValueError("Too few initial states given. Parameters are missing.") if len(self.parameters["coefficients"]) < N: raise ValueError("Too few initial states given. Coefficients are missing.") # Create a suitable wave packet packet = HagedornWavepacket(self.parameters) packet.set_parameters(self.parameters["parameters"][self.parameters["leading_component"]]) packet.set_quadrature(None) # Set the initial values for component, data in enumerate(self.parameters["coefficients"]): for index, value in data: packet.set_coefficient(component, index, value) # Project the initial values to the canonical basis packet.project_to_canonical(potential) # Finally create and initialize the propagator instace inner = HagedornPropagator(potential, packet, self.parameters["leading_component"], self.parameters) self.propagator = SpawnAdiabaticPropagator(inner, potential, packet, self.parameters["leading_component"], self.parameters) # Write some initial values to disk slots = self.tm.compute_number_saves() for packet in self.propagator.get_wavepackets(): bid = self.iom.create_block(groupid=self.gid) self.iom.add_wavepacket(self.parameters, timeslots=slots, blockid=bid) self.iom.save_wavepacket_coefficients(packet.get_coefficients(), blockid=bid, timestep=0) self.iom.save_wavepacket_parameters(packet.get_parameters(), blockid=bid, timestep=0)