def aposteriori_spawning(fin, fout, pin, pout, bid1, bid2): """ :param f: An ``IOManager`` instance providing the simulation data. :param datablock: The data block where the results are. """ # Number of time steps we saved timesteps = fin.load_wavepacket_timegrid() nrtimesteps = timesteps.shape[0] params = fin.load_wavepacket_parameters() coeffs = fin.load_wavepacket_coefficients() # A data transformation needed by API specification coeffs = [ [ coeffs[i,j,:] for j in xrange(pin["ncomponents"]) ] for i in xrange(nrtimesteps) ] # Initialize a mother Hagedorn wavepacket with the data from another simulation HAWP = HagedornWavepacket(pin) HAWP.set_quadrature(None) # Initialize an empty wavepacket for spawning SWP = HagedornWavepacket(pout) SWP.set_quadrature(None) # Initialize a Spawner AS = AdiabaticSpawner(pout) # Iterate over all timesteps and spawn for i, step in enumerate(timesteps): print(" Try spawning at timestep "+str(step)) # Configure the wave packet and project to the eigenbasis. HAWP.set_parameters(params[i]) HAWP.set_coefficients(coeffs[i]) #HAWP.project_to_eigen(Potential) # Try spawning a new packet ps = AS.estimate_parameters(HAWP, 0) if ps is not None: SWP.set_parameters(ps) AS.project_coefficients(HAWP, SWP) # Save the spawned packet fout.save_wavepacket_parameters(HAWP.get_parameters(), timestep=step, blockid=bid1) fout.save_wavepacket_coefficients(HAWP.get_coefficients(), timestep=step, blockid=bid1) fout.save_wavepacket_parameters(SWP.get_parameters(), timestep=step, blockid=bid2) fout.save_wavepacket_coefficients(SWP.get_coefficients(), timestep=step, blockid=bid2)
WP2 = HagedornWavepacket(params) WP2.set_coefficient(0, 0, 1) WP2.set_quadrature(None) HQ1 = HomogeneousQuadrature() HQ1.build_qr(max(WP1.get_basis_size())) HQ2 = HomogeneousQuadrature() HQ2.build_qr(max(WP2.get_basis_size())) IHQ = InhomogeneousQuadrature() IHQ.build_qr(nmax) Pibra = WP1.get_parameters() x = linspace(-4, 4, 4000) positions = linspace(-0.5, 2.5, 61) quads1 = [] quads2 = [] quads12 = [] for index, pos in enumerate(positions): print(pos) # Moving Gaussian WP2.set_parameters((1.0j, 1.0, 0.0, 0.0, pos)) # Transform the nodes nodes1 = squeeze(HQ1.transform_nodes(WP1.get_parameters(), WP1.eps))