@@ -1566,4 +1566,99 @@ void RingRF(Bunch* bunch, double ring_length, int harmonic_numb,
15661566 }
15671567}
15681568
1569+
1570+ // //////////////////////////
1571+ // NAME
1572+ // continuousLinear
1573+ //
1574+ // DESCRIPTION
1575+ // Continuous axisymmetric focusing element: linear transport matrix. This
1576+ // is equivalent to quad1, but is focusing in both planes. This element
1577+ // assumes there is no energy offset from the synchronous particle.
1578+ //
1579+ // PARAMETERS
1580+ // bunch = reference to the macro-particle bunch
1581+ // length = length of transport
1582+ // kq = quadrupole field strength [m^(-2)]
1583+ // kq already has information about the charge of particle.
1584+ //
1585+ // RETURNS
1586+ // Nothing
1587+ //
1588+ // /////////////////////////////////////////////////////////////////////////
1589+
1590+ void continuousLinear (Bunch* bunch, double length, double kq, int useCharge) {
1591+ if (kq == 0.0 || bunch->getCharge () == 0.0 ) {
1592+ drift (bunch, length);
1593+ return ;
1594+ }
1595+
1596+ double kqc = abs (kq);
1597+ double sqrt_kq;
1598+ double kqlength;
1599+
1600+ double x_init;
1601+ double y_init;
1602+ double xp_init;
1603+ double yp_init;
1604+
1605+ double cx;
1606+ double sx;
1607+ double cy;
1608+ double sy;
1609+
1610+ double m11 = 0.0 ;
1611+ double m12 = 0.0 ;
1612+ double m21 = 0.0 ;
1613+ double m22 = 0.0 ;
1614+ double m33 = 0.0 ;
1615+ double m34 = 0.0 ;
1616+ double m43 = 0.0 ;
1617+ double m44 = 0.0 ;
1618+
1619+ SyncPart* syncPart = bunch->getSyncPart ();
1620+
1621+ double v = OrbitConst::c * syncPart->getBeta ();
1622+ if (length > 0.0 ) {
1623+ syncPart->setTime (syncPart->getTime () + length / v);
1624+ }
1625+
1626+ double gamma2i = 1.0 / (syncPart->getGamma () * syncPart->getGamma ());
1627+ double dp_p_coeff = 1.0 /(syncPart->getMomentum () * syncPart->getBeta ());
1628+
1629+ sqrt_kq = pow (kqc, 0.5 );
1630+ kqlength = sqrt_kq * length;
1631+ cx = cos (kqlength);
1632+ sx = sin (kqlength);
1633+ cy = cos (kqlength);
1634+ sy = sin (kqlength);
1635+ m11 = +cx;
1636+ m12 = +sx / sqrt_kq;
1637+ m21 = -sx * sqrt_kq;
1638+ m22 = +cx;
1639+ m33 = +cy;
1640+ m34 = +sy / sqrt_kq;
1641+ m43 = -sy * sqrt_kq;
1642+ m44 = +cy;
1643+
1644+ double dp_p;
1645+
1646+ double ** arr = bunch->coordArr ();
1647+
1648+ for (int i = 0 ; i < bunch->getSize (); i++) {
1649+ dp_p = arr[i][5 ] * dp_p_coeff;
1650+ x_init = arr[i][0 ];
1651+ xp_init = arr[i][1 ];
1652+ y_init = arr[i][2 ];
1653+ yp_init = arr[i][3 ];
1654+
1655+ arr[i][0 ] = x_init * m11 + xp_init * m12;
1656+ arr[i][1 ] = x_init * m21 + xp_init * m22;
1657+ arr[i][2 ] = y_init * m33 + yp_init * m34;
1658+ arr[i][3 ] = y_init * m43 + yp_init * m44;
1659+ arr[i][4 ] += dp_p * gamma2i * length;
1660+ }
1661+ }
1662+
1663+
15691664} // end of namespace teapot_base
0 commit comments