<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://spindynamics.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Ens_block.m</id>
	<title>Ens block.m - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://spindynamics.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Ens_block.m"/>
	<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Ens_block.m&amp;action=history"/>
	<updated>2026-12-04T21:49:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.15</generator>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Ens_block.m&amp;diff=10348&amp;oldid=prev</id>
		<title>Kuprov: sync with Spinach main 3975f139: new function page from the source header</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Ens_block.m&amp;diff=10348&amp;oldid=prev"/>
		<updated>2026-09-18T10:00:57Z</updated>

		<summary type="html">&lt;p&gt;sync with Spinach main 3975f139: new function page from the source header&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:ens_block.m}} __NOTOC__&lt;br /&gt;
Fidelity, gradient, and Hessian contributions of one block of ensemble cases, evaluated on the parallel pool worker that holds the drift generators of that block. This function is called by [[ensemble.m]] inside its spmd block; the per-case physics (phase cycle, offsets, power level, waveform distortions, GRAPE) is applied here. The live client-side control structure is grafted over the frozen worker copy of the problem, keeping the fields that only the worker holds; the GRAPE function is chosen by the formalism ([[grape_liouv.m]] for sphten-liouv, zeeman-liouv, and zeeman-wavef, [[grape_hilb.m]] for zeeman-hilb). For each case of the block, the phase cycle line rotates the control channels and multiplies the initial and target states by its phases, the offset terms are added to the drift with the first channel index running fastest, the waveform is moved into physical units by the power level, and the distortion functions are applied with their Jacobians when derivatives are needed; the gradient of each case is pulled back through the Jacobian, the phase cycle rotation, and the power level, and the Hessian through the phase cycle rotation and the power level squared. The gradients and the Hessians are summed over the block. When control.traj_opts contains &amp;#039;average&amp;#039;, the forward trajectories of the block are summed into one structure.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
     [traj,fid,grad,hess]=ens_block(spin_system,drifts,control,...&lt;br /&gt;
                                    block,waveform,n_outputs)&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
   spin_system  - frozen problem published by optimcon.m, with&lt;br /&gt;
                  the drift generators removed&lt;br /&gt;
&lt;br /&gt;
   drifts       - cell array of drift generators, populated at&lt;br /&gt;
                  the indices that the cases of this block use&lt;br /&gt;
&lt;br /&gt;
   control      - live client-side control structure&lt;br /&gt;
&lt;br /&gt;
   block        - index of the case block, into the cell array&lt;br /&gt;
                  spin_system.control.worker_cases&lt;br /&gt;
&lt;br /&gt;
   waveform     - control coefficients for each control opera-&lt;br /&gt;
                  tor, [ncontrols x nsteps], rad/s&lt;br /&gt;
&lt;br /&gt;
   n_outputs    - number of outputs requested from ensemble.m,&lt;br /&gt;
                  2 for the fidelity, 3 for the gradient, 4 for&lt;br /&gt;
                  the Hessian&lt;br /&gt;
&lt;br /&gt;
==Outputs==&lt;br /&gt;
&lt;br /&gt;
   traj         - cell array of trajectory structures, one per&lt;br /&gt;
                  case of the block in block order; when the&lt;br /&gt;
                  control.traj_opts contains &amp;#039;average&amp;#039;, one&lt;br /&gt;
                  structure holding the sum over the block, or&lt;br /&gt;
                  an empty cell for an empty block&lt;br /&gt;
&lt;br /&gt;
   fid          - [1 x n_block] array of case fidelities&lt;br /&gt;
&lt;br /&gt;
   grad         - sum of the case gradients over the block, a&lt;br /&gt;
                  [ncontrols*nsteps x 1] column, empty unless&lt;br /&gt;
                  n_outputs&amp;gt;2&lt;br /&gt;
&lt;br /&gt;
   hess         - sum of the case Hessians over the block, a&lt;br /&gt;
                  [(ncontrols*nsteps)^2 x 1] column, empty un-&lt;br /&gt;
                  less n_outputs&amp;gt;3&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
This is a low level function that is not designed to be called directly; [[ensemble.m]] calls it on the workers. Hessians are only available with the rectangle integrator and without waveform distortions; the waveform must have nsteps+1 columns for the trapezium integrator.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[ensemble.m]], [[optimcon.m]], [[ens_catalog.m]], [[grape_liouv.m]], [[grape_hilb.m]], [[Optimal control module]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Version 2.13, authors: [[David Goodwin]], [[Ilya Kuprov]], [[Maxi Keitel]]&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Kuprov</name></author>
		
	</entry>
</feed>