@@ -377,120 +377,6 @@ def test_analytical_models(integrator, model, runner):
377377 model .expected_state (model .tlist [i ]),
378378 atol = 1e-3 )
379379
380-
381- @pytest .mark .parametrize ('integrator' , all_integrator_classes )
382- def test_squeezing (integrator ):
383-
384- def n_thermal (w : float , w_th : float ):
385- """
386- Return the number of average photons in thermal equilibrium for a
387- an oscillator with the given frequency and temperature.
388- """
389- if (w_th > 0 ) and np .exp (w / w_th ) != 1.0 :
390- return 1.0 / (np .exp (w / w_th ) - 1.0 )
391- else :
392- return 0.0
393-
394- # Problem parameters
395- w0 = 1.0 * 2 * np .pi
396- gamma0 = 0.05
397- # the temperature of the environment
398- w_th = 0.0 * 2 * np .pi
399- # the number of average excitations in the environment mode w0 at temperature w_th
400- Nth = n_thermal (w0 , w_th )
401- # squeezing parameter for the environment
402- r = 1.0
403- theta = 0.1 * np .pi
404- N = Nth * (np .cosh (r )** 2 + np .sinh (r )** 2 ) + np .sinh (r )** 2
405- sz_ss_analytical = - 1 / (2 * N + 1 )
406- # System Hamiltonian
407- hamiltonian = - 0.5 * w0 * spin .z (0 )
408- # Collapse operators
409- c_ops = [
410- np .sqrt (gamma0 ) * (spin .minus (0 ) * np .cosh (r ) +
411- spin .plus (0 ) * np .sinh (r ) * np .exp (1j * theta ))
412- ]
413-
414- # System dimension
415- dimensions = {0 : 2 }
416- # Start in an arbitrary superposition state
417- psi0_ = cp .array ([2j , 1.0 ], dtype = cp .complex128 )
418- psi0_ = psi0_ / cp .linalg .norm (psi0_ )
419- psi0 = cudaq .State .from_data (psi0_ )
420- # Simulation time points
421- steps = np .linspace (0 , 50 , 1001 )
422- schedule = Schedule (steps , ["t" ])
423-
424- # Run the simulation
425- evolution_result = evolve (hamiltonian ,
426- dimensions ,
427- schedule ,
428- psi0 ,
429- observables = [spin .x (0 ),
430- spin .y (0 ),
431- spin .z (0 )],
432- collapse_operators = c_ops ,
433- store_intermediate_results = True ,
434- integrator = integrator ())
435-
436- exp_val_x = [
437- exp_vals [0 ].expectation ()
438- for exp_vals in evolution_result .expectation_values ()
439- ]
440- exp_val_y = [
441- exp_vals [1 ].expectation ()
442- for exp_vals in evolution_result .expectation_values ()
443- ]
444- exp_val_z = [
445- exp_vals [2 ].expectation ()
446- for exp_vals in evolution_result .expectation_values ()
447- ]
448-
449- np .testing .assert_allclose (exp_val_z [- 1 ], sz_ss_analytical , atol = 1e-3 )
450-
451-
452- @pytest .mark .parametrize ('integrator' , all_integrator_classes )
453- def test_cat_state (integrator ):
454- # Number of Fock levels
455- N = 15
456- # Kerr non-linearity
457- chi = 1 * 2 * np .pi
458-
459- dimensions = {0 : N }
460-
461- a = operators .annihilate (0 )
462- a_dag = operators .create (0 )
463-
464- # Defining the Hamiltonian for the system (non-linear Kerr effect)
465- hamiltonian = 0.5 * chi * a_dag * a_dag * a * a
466-
467- # we start with a coherent state with alpha=2.0
468- # This will evolve into a cat state.
469- rho0 = cudaq .State .from_data (coherent_state (N , 2.0 ))
470-
471- # Choose the end time at which the state evolves to the exact cat state.
472- steps = np .linspace (0 , 0.5 * chi / (2 * np .pi ), 51 )
473- schedule = Schedule (steps , ["t" ])
474-
475- # Run the simulation: observe the photon count, position and momentum.
476- evolution_result = evolve (hamiltonian ,
477- dimensions ,
478- schedule ,
479- rho0 ,
480- observables = [],
481- collapse_operators = [],
482- store_intermediate_results = False ,
483- integrator = integrator ())
484-
485- # The expected cat state: superposition of `|alpla>` and `|-alpha>` coherent states.
486- expected_state = np .exp (1j * np .pi / 4 ) * coherent_state (N , - 2.0j ) + np .exp (
487- - 1j * np .pi / 4 ) * coherent_state (N , 2.0j )
488- expected_state = expected_state / cp .linalg .norm (expected_state )
489- final_state = evolution_result .final_state ()
490- overlap = final_state .overlap (expected_state )
491- np .testing .assert_allclose (overlap , 1.0 , atol = 1e-3 )
492-
493-
494380@pytest .mark .parametrize ('integrator' , all_integrator_classes )
495381def test_floquet_steady_state (integrator ):
496382 # two-level system coupled with the external heat bath (fixed temperature)
0 commit comments