Example #1
0
        /** Calculate the gas density, divided by the maximum density GAS_DENSITY
         * 
         * @param pos as 3D length vector offset to global left top front cell
         * @return float_X between 0.0 and 1.0
         */
        DINLINE float_X calcNormedDensitiy( float3_X pos )
        {
            if (pos.y() < VACUUM_Y
                || pos.y() >= (GAS_LENGTH + VACUUM_Y)) return float_X(0.0);

            return float_X(1.0);
        }
Example #2
0
        DINLINE void operator()(DataBoxJ dataBoxJ,
                                const PosType pos,
                                const VelType velocity,
                                const ChargeType charge, const float3_X& cellSize, const float_X deltaTime)
    {
        this->charge = charge;
        const float3_X deltaPos = float3_X(velocity.x() * deltaTime / cellSize.x(),
                                           velocity.y() * deltaTime / cellSize.y(),
                                           velocity.z() * deltaTime / cellSize.z());
        const PosType oldPos = pos - deltaPos;
        Line line(oldPos, pos);
        BOOST_AUTO(cursorJ, dataBoxJ.toCursor());

        /**
         * \brief the following three calls separate the 3D current deposition
         * into three independent 1D calls, each for one direction and current component.
         * Therefore the coordinate system has to be rotated so that the z-direction
         * is always specific.
         */

        using namespace cursor::tools;
        cptCurrent1D(twistVectorFieldAxes<PMacc::math::CT::Int < 1, 2, 0 > >(cursorJ), rotateOrigin < 1, 2, 0 > (line), cellSize.x());
        cptCurrent1D(twistVectorFieldAxes<PMacc::math::CT::Int < 2, 0, 1 > >(cursorJ), rotateOrigin < 2, 0, 1 > (line), cellSize.y());
        cptCurrent1D(cursorJ, line, cellSize.z());
    }
Example #3
0
        /** Calculate the gas density, divided by the maximum density GAS_DENSITY
         * 
         * @param pos as 3D length vector offset to global left top front cell
         * @return float_X between 0.0 and 1.0
         */
        DINLINE float_X calcNormedDensitiy( float3_X pos, float_64 )
        {
            if (pos.y() < VACUUM_Y) return float_X(0.0);

            float_X exponent = float_X(0.0);
            if (pos.y() < GAS_CENTER_LEFT)
                exponent = math::abs((pos.y() - GAS_CENTER_LEFT) / GAS_SIGMA_LEFT);
            else if (pos.y() > GAS_CENTER_RIGHT)
                exponent = math::abs((pos.y() - GAS_CENTER_RIGHT) / GAS_SIGMA_RIGHT);

            const float_X density = math::exp(float_X(GAS_FACTOR) * __powf(exponent, GAS_POWER));
            return density;
        }
Example #4
0
        /** Calculate the gas density, divided by the maximum density GAS_DENSITY
         * 
         * @param pos as 3D length vector offset to global left top front cell
         * @return float_X between 0.0 and 1.0
         */
        DINLINE float_X calcNormedDensitiy( float3_X pos )
        {
            if (pos.y() < VACUUM_Y) return float_X(0.0);

            float_X density = float_X(0.0);
            
            if (pos.y() <= GAS_Y_MAX) // linear slope
                density = GAS_A * pos.y() + GAS_B;
            else // exponential slope
                density = math::exp( (pos.y() - GAS_Y_MAX) * GAS_D );
            
            // avoid < 0 densities for the linear slope
            if (density < float_X(0.0))
                density = float_X(0.0);
            
            return density;
        }
        __host__ DINLINE void operator()(
                                            const BType bField,
                                            const EType eField,
                                            PosType& pos,
                                            MomType& mom,
                                            const MassType mass,
                                            const ChargeType charge)
    {
        const float_X QoM = charge / mass;

        const float_X deltaT = DELTA_T;

        const MomType mom_minus = mom + float_X(0.5) * charge * eField * deltaT;

        Gamma gamma;
        const float_X gamma_reci = float_X(1.0) / gamma(mom_minus, mass);
        const float3_X t = float_X(0.5) * QoM * bField * gamma_reci * deltaT;
        const BType s = float_X(2.0) * t * (float_X(1.0) / (float_X(1.0) + math::abs2(t)));

        const MomType mom_prime = mom_minus + math::cross(mom_minus, t);
        const MomType mom_plus = mom_minus + math::cross(mom_prime, s);

        const MomType new_mom = mom_plus + float_X(0.5) * charge * eField * deltaT;
        mom = new_mom;

        Velocity velocity;
        const float3_X vel = velocity(new_mom, mass);

        /* IMPORTANT: 
         * use float_X(1.0)+X-float_X(1.0) because the rounding of float_X can create position from [-float_X(1.0),2.f],
         * this breaks ower definition that after position change (if statements later) the position must [float_X(0.0),float_X(1.0))
         * 1.e-9+float_X(1.0) = float_X(1.0) (this is not allowed!!!
         * 
         * If we don't use this fermi crash in this kernel in the time step n+1 in field interpolation
         */
        pos.x() += float_X(1.0) + (vel.x() * DELTA_T / CELL_WIDTH);
        pos.y() += float_X(1.0) + (vel.y() * DELTA_T / CELL_HEIGHT);
        pos.z() += float_X(1.0) + (vel.z() * DELTA_T / CELL_DEPTH);

        pos.x() -= float_X(1.0);
        pos.y() -= float_X(1.0);
        pos.z() -= float_X(1.0);

    }
Example #6
0
        /** Calculate the gas density, divided by the maximum density GAS_DENSITY
         * 
         * @param y as distance in propagation direction (unit: meters / UNIT_LENGTH)
         * @return float_X between 0.0 and 1.0
         */
        DINLINE float_X calcNormedDensitiy( float3_X pos )
        {
            if (pos.y() < VACUUM_Y) return float_X(0.0);

            const float3_X exponent = float3_X( math::abs((pos.x() - GAS_CENTER_X)/GAS_SIGMA_X),
                                                 math::abs((pos.y() - GAS_CENTER_Y)/GAS_SIGMA_Y),
                                                 math::abs((pos.z() - GAS_CENTER_Z)/GAS_SIGMA_Z) );

            const float_X density = math::exp(GAS_FACTOR * __powf(exponent.x(), GAS_POWER))
                                * math::exp(GAS_FACTOR * __powf(exponent.y(), GAS_POWER))
                                * math::exp(GAS_FACTOR * __powf(exponent.z(), GAS_POWER));
            return density;
        }
        HDINLINE void operator()(Cursor& cursor, Vector& vector, const float3_X & fieldPos)
    {

        if (speciesParticleShape::ParticleShape::support % 2 == 0)
        {
            //even support

            /* for any direction
             * if fieldPos == 0.5 and vector<0.5 
             * shift curser+(-1) and new_vector=old_vector-(-1)
             * 
             * (vector.x() < fieldPos.x()) is equal ((fieldPos == 0.5) && (vector<0.5))
             */
            float3_X coordinate_shift(
                                      -float_X(vector.x() < fieldPos.x()),
                                      -float_X(vector.y() < fieldPos.y()),
                                      -float_X(vector.z() < fieldPos.z())
                                      );
            cursor = cursor(
                            PMacc::math::Int < 3 > (
                                               coordinate_shift.x(),
                                               coordinate_shift.y(),
                                               coordinate_shift.z()
                                               ));
            //same as: vector = vector - fieldPos - coordinate_shift;
            vector -= (fieldPos + coordinate_shift);
        }
        else
        {
            //odd support

            /* for any direction
             * if fieldPos < 0.5 and vector> 0.5 
             * shift curser+1 and new_vector=old_vector-1
             */
            float3_X coordinate_shift(
                                      float_X(vector.x() > float_X(0.5) && fieldPos.x() != float_X(0.5)),
                                      float_X(vector.y() > float_X(0.5) && fieldPos.y() != float_X(0.5)),
                                      float_X(vector.z() > float_X(0.5) && fieldPos.z() != float_X(0.5))
                                      );
            cursor = cursor(
                            PMacc::math::Int < 3 > (
                                               coordinate_shift.x(),
                                               coordinate_shift.y(),
                                               coordinate_shift.z()
                                               ));
            //same as: vector = vector - fieldPos - coordinate_shift;
            vector -= (fieldPos + coordinate_shift);

        }






    }
Example #8
0
        HDINLINE void operator()(float3_X data, PMacc::math::Int<3> cellIdx)
        {

            const float_X unit_current = UNIT_CHARGE / (UNIT_LENGTH * UNIT_LENGTH * UNIT_TIME);
            if(data.x() != 0.0f)
                printf("j_x = %g at %d, %d, %d\n", data.x() * unit_current, cellIdx.x(), cellIdx.y(), cellIdx.z());
            if(data.y() != 0.0f)
                printf("j_y = %g at %d, %d, %d\n", data.y() * unit_current, cellIdx.x(), cellIdx.y(), cellIdx.z());
            if(data.z() != 0.0f)
                printf("j_z = %g at %d, %d, %d\n", data.z() * unit_current, cellIdx.x(), cellIdx.y(), cellIdx.z());
                
            this->totalJ += data;
        }
 DINLINE float3_X getPosition( UNIRNG& rng,
                                const uint32_t totalNumParsPerCell,
                                const uint32_t curParticle )
 {
     // spacing between particles in each direction in the cell
     const float3_X spacing = float3_X( float_X(1.0) / float_X(numParsPerCell_X),
                                         float_X(1.0) / float_X(numParsPerCell_Y),
                                         float_X(1.0) / float_X(numParsPerCell_Z) );
     // length of the x lattice, number of particles in the xy plane
     const uint32_t lineX   = numParsPerCell_X;
     const uint32_t planeXY = numParsPerCell_X * numParsPerCell_Y;
     
     // coordinate in the local in-cell lattice
     //   x = [0, numParsPerCell_X-1]
     //   y = [0, numParsPerCell_Y-1]
     //   z = [0, numParsPerCell_Z-1]
     const uint3 inCellCoordinate = make_uint3( curParticle % lineX,
                                                (curParticle % planeXY) / lineX,
                                                curParticle / planeXY );
     
     return float3_X( float_X(inCellCoordinate.x) * spacing.x() + spacing.x() * 0.5,
                         float_X(inCellCoordinate.y) * spacing.y() + spacing.y() * 0.5,
                         float_X(inCellCoordinate.z) * spacing.z() + spacing.z() * 0.5 );
 }
Example #10
0
        /**
         *
         * @param elong
         * @param phase
         * @param posX
         * @param posZ
         * @return
         */
        HDINLINE float3_X laserTransversal( float3_X elong, float_X phase, const float_X posX, const float_X posZ )
        {
            //const float_X modMue = float_X(PI) * float_X(SPEED_OF_LIGHT / WAVE_LENGTH) * INIT_TIME;
            const float_X f = SPEED_OF_LIGHT / WAVE_LENGTH;
            const float_X timeShift = phase / (2.0f * float_X(PI) * float_X(f)) + FOCUS_POS / SPEED_OF_LIGHT;
            const float_X spaceShift = SPEED_OF_LIGHT * tanf(TILT_X) * timeShift / CELL_HEIGHT;
            const float_X r2 = (posX + spaceShift) * (posX + spaceShift) + posZ * posZ;

            // pure gaussian
            //const float_X r2 = posX * posX + posZ * posZ;

            //rayleigh length (in y-direction)
            const float_X y_R = float_X( PI ) * W0 * W0 / WAVE_LENGTH;

            // the radius of curvature of the beam's  wavefronts
            const float_X R_y = -FOCUS_POS * ( float_X(1.0) + ( y_R / FOCUS_POS )*( y_R / FOCUS_POS ) );


#if !defined(__CUDA_ARCH__) // Host code path
            //beam waist in the near field: w_y(y=0) == W0
            const float_X w_y = W0 * sqrt( float_X(1.0) + ( FOCUS_POS / y_R )*( FOCUS_POS / y_R ) );
            //! the Gouy phase shift
            const float_X xi_y = atan( -FOCUS_POS / y_R );

            if( Polarisation == LINEAR_X || Polarisation == LINEAR_Z )
            {
                elong *= math::exp( -r2 / w_y / w_y ) * cos( 2.0f * float_X( PI ) / WAVE_LENGTH * FOCUS_POS - 2.0f * float_X( PI ) / WAVE_LENGTH * r2 / 2.0f / R_y + xi_y + phase )
                    * math::exp( -( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                       *( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                       / SPEED_OF_LIGHT / SPEED_OF_LIGHT / ( 2.0f * PULSE_LENGTH ) / ( 2.0f * PULSE_LENGTH ) );
            }
            else if( Polarisation == CIRCULAR )
            {
                elong.x() *= math::exp( -r2 / w_y / w_y ) * cos( 2.0f * float_X( PI ) / WAVE_LENGTH * FOCUS_POS - 2.0f * float_X( PI ) / WAVE_LENGTH * r2 / 2.0f / R_y + xi_y + phase )
                    * math::exp( -( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                       *( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                       / SPEED_OF_LIGHT / SPEED_OF_LIGHT / ( 2.0f * PULSE_LENGTH ) / ( 2.0f * PULSE_LENGTH ) );
                phase += float_X( PI / 2.0 );
                elong.z() *= math::exp( -r2 / w_y / w_y ) * cos( 2.0f * float_X( PI ) / WAVE_LENGTH * FOCUS_POS - 2.0f * float_X( PI ) / WAVE_LENGTH * r2 / 2.0f / R_y + xi_y + phase )
                    * math::exp( -( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                       *( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                       / SPEED_OF_LIGHT / SPEED_OF_LIGHT / ( 2.0f * PULSE_LENGTH ) / ( 2.0f * PULSE_LENGTH ) );
                phase -= float_X( PI / 2.0 );
            }

            return elong;
#else
            //beam waist in the near field: w_y(y=0) == W0
            const float_X w_y = W0 * sqrtf( float_X(1.0) + ( FOCUS_POS / y_R )*( FOCUS_POS / y_R ) );
            //! the Gouy phase shift
            const float_X xi_y = atanf( -FOCUS_POS / y_R );

            if( Polarisation == LINEAR_X || Polarisation == LINEAR_Z )
            {
                elong *= math::exp( -r2 / w_y / w_y ) * __cosf( 2.0f * float_X( PI ) / WAVE_LENGTH * FOCUS_POS - 2.0f * float_X( PI ) / WAVE_LENGTH * r2 / 2.0f / R_y + xi_y + phase )
                    * math::exp( -( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                          *( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                          / SPEED_OF_LIGHT / SPEED_OF_LIGHT / ( 2.0f * PULSE_LENGTH ) / ( 2.0f * PULSE_LENGTH ) );
            }
            else if( Polarisation == CIRCULAR )
            {
                elong.x() *= math::exp( -r2 / w_y / w_y ) * __cosf( 2.0f * float_X( PI ) / WAVE_LENGTH * FOCUS_POS - 2.0f * float_X( PI ) / WAVE_LENGTH * r2 / 2.0f / R_y + xi_y + phase )
                    * math::exp( -( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                          *( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                          / SPEED_OF_LIGHT / SPEED_OF_LIGHT / ( 2.0f * PULSE_LENGTH ) / ( 2.0f * PULSE_LENGTH ) );
                phase += float_X( PI / 2.0 );
                elong.z() *= math::exp( -r2 / w_y / w_y ) * __cosf( 2.0f * float_X( PI ) / WAVE_LENGTH * FOCUS_POS - 2.0f * float_X( PI ) / WAVE_LENGTH * r2 / 2.0f / R_y + xi_y + phase )
                    * math::exp( -( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                          *( r2 / 2.0f / R_y - FOCUS_POS - phase / 2.0f / float_X( PI ) * WAVE_LENGTH )
                          / SPEED_OF_LIGHT / SPEED_OF_LIGHT / ( 2.0f * PULSE_LENGTH ) / ( 2.0f * PULSE_LENGTH ) );
                phase -= float_X( PI / 2.0 );
            }

            return elong;
#endif
        }
Example #11
0
        __host__ DINLINE void operator()(
                                            const BType bField, /* at t=0 */
                                            const EType eField, /* at t=0 */
                                            PosType& pos, /* at t=0 */
                                            MomType& mom, /* at t=-1/2 */
                                            const MassType mass,
                                            const ChargeType charge)
    {

        /*   
             time index in paper is reduced by a half: i=0 --> i=-1/2 so that momenta are 
             at half time steps and fields and locations are at full time steps

     Here the real (PIConGPU) momentum (p) is used, not the momentum from the Vay paper (u)
     p = m_0 * u
         */
        const float_X deltaT = DELTA_T;
        const float_X factor = 0.5 * charge * deltaT;
        Gamma gamma;
        Velocity velocity;

        // first step in Vay paper:
        const float3_X velocity_atMinusHalf = velocity(mom, mass);
        //mom /(mass*mass + abs2(mom)/(SPEED_OF_LIGHT*SPEED_OF_LIGHT));
        const MomType momentum_atZero = mom + factor * (eField + math::cross(velocity_atMinusHalf, bField));

        // second step in Vay paper:
        const MomType momentum_prime = momentum_atZero + factor * eField;
        const float_X gamma_prime = gamma(momentum_prime, mass);
        //sqrtf(1.0 + abs2(momentum_prime*(1.0/(mass * SPEED_OF_LIGHT))));
        const sqrt_Vay::float3_X tau = factor / mass * bField;
        const sqrt_Vay::float_X u_star = math::dot( typeCast<sqrt_Vay::float_X>(momentum_prime), tau ) / typeCast<sqrt_Vay::float_X>( SPEED_OF_LIGHT * mass );
        const sqrt_Vay::float_X sigma = gamma_prime * gamma_prime - math::abs2( tau );
        const sqrt_Vay::float_X gamma_atPlusHalf = math::sqrt( sqrt_Vay::float_X(0.5) *
            ( sigma +
              math::sqrt( sigma * sigma +
                          sqrt_Vay::float_X(4.0) * ( math::abs2( tau ) + u_star * u_star ) )
            )
                                                    );
        const float3_X t = tau * (float_X(1.0) / gamma_atPlusHalf);
        const float_X s = float_X(1.0) / (float_X(1.0) + math::abs2(t));
        const MomType momentum_atPlusHalf = s * (momentum_prime + math::dot(momentum_prime, t) * t + math::cross(momentum_prime, t));

        mom = momentum_atPlusHalf;

        const float3_X vel = velocity(momentum_atPlusHalf, mass);

        /* IMPORTEND: 
         * use float_X(1.0)+X-float_X(1.0) because the rounding of float_X can create position from [-float_X(1.0),2.f],
         * this breaks ower definition that after position change (if statements later) the position must [float_X(0.0),float_X(1.0))
         * 1.e-9+float_X(1.0) = float_X(1.0) (this is not allowed!!!
         * 
         * If we don't use this fermi crash in this kernel in the time step n+1 in field interpolation
         */
        pos.x() += float_X(1.0) + (vel.x() * DELTA_T / CELL_WIDTH);
        pos.y() += float_X(1.0) + (vel.y() * DELTA_T / CELL_HEIGHT);
        pos.z() += float_X(1.0) + (vel.z() * DELTA_T / CELL_DEPTH);

        pos.x() -= float_X(1.0);
        pos.y() -= float_X(1.0);
        pos.z() -= float_X(1.0);

    }
Example #12
0
                __host__ DINLINE void operator( )(
                                                      const BType bField, /* at t=0 */
                                                      const EType eField, /* at t=0 */
                                                      PosType& pos, /* at t=0 */
                                                      MomType& mom, /* at t=-1/2 */
                                                      const MassType mass,
                                                      const ChargeType charge)
            {
                Gamma gammaCalc;
                Velocity velocityCalc;
                const float_X epsilon = 1.0e-6;
                const float_X deltaT = DELTA_T;

                //const float3_X velocity_atMinusHalf = velocity(mom, mass);
                const float_X gamma = gammaCalc( mom, mass );

                const MomType mom_old = mom;

                const float_X B2 = math::abs2( bField );
                const float_X B = abs( bField );

                if( B2 > epsilon )
                {
                    trigo_X sinres;
                    trigo_X cosres;
                    trigo_X arg = B * charge * deltaT / gamma;
                    math::sincos( arg, sinres, cosres );

                    mom.x() = bField.x() * bField.x() * ( eField.x() * charge * deltaT + mom_old.x() );
                    mom.y() = bField.y() * bField.y() * ( eField.y() * charge * deltaT + mom_old.y() );
                    mom.z() = bField.z() * bField.z() * ( eField.z() * charge * deltaT + mom_old.z() );

#define SUM_PLINE1(I,J,K) bField.J() * ( -levichivita(I,J,K) * gamma * eField.K() + bField.I() * ( eField.J() * charge * deltaT + mom_old.J() ) )
#define SUM_PLINE2(I,J,K) -bField.J() * ( -levichivita(I,J,K) * gamma * eField.K() + bField.I() * mom_old.J() - bField.J() * mom_old.I() )
#define SUM_PLINE3(I,J,K) bField.J() * bField.J() * gamma * eField.I() - bField.I() * bField.J() * gamma * eField.J() + levichivita(I,J,K) * mom_old.J() * bField.K() * B2

                    mom.x() += FOR_JK_NOT_I( x, y, z, SUM_PLINE1 );
                    mom.x() += float_X(cosres ) * ( FOR_JK_NOT_I( x, y, z, SUM_PLINE2 ) );
                    mom.x() += float_X(sinres ) / B * ( FOR_JK_NOT_I( x, y, z, SUM_PLINE3 ) );

                    mom.y() += FOR_JK_NOT_I( y, z, x, SUM_PLINE1 );
                    mom.y() += float_X(cosres ) * ( FOR_JK_NOT_I( y, z, x, SUM_PLINE2 ) );
                    mom.y() += float_X(sinres ) / B * ( FOR_JK_NOT_I( y, z, x, SUM_PLINE3 ) );

                    mom.z() += FOR_JK_NOT_I( z, x, y, SUM_PLINE1 );
                    mom.z() += float_X(cosres ) * ( FOR_JK_NOT_I( z, x, y, SUM_PLINE2 ) );
                    mom.z() += float_X(sinres ) / B * ( FOR_JK_NOT_I( z, x, y, SUM_PLINE3 ) );

                    mom *= float_X(1.0) / B2;
                }
                else
                {
                    mom += eField * charge * deltaT;
                }

                float3_X dr = float3_X( float_X(0.0), float_X(0.0), float_X(0.0) );
                
                // old spacial change calculation: linear step
                if( TrajectoryInterpolation == LINEAR )
                {
                    const float3_X vel = velocityCalc( mom, mass );
                    dr = float3_X( vel.x() * deltaT / CELL_WIDTH,
                                                   vel.y() * deltaT / CELL_HEIGHT,
                                                   vel.z() * deltaT / CELL_DEPTH );
                }

                // new spacial change calculation
                if( TrajectoryInterpolation == NONLINEAR )
                {
                    const float3_X vel_old = velocityCalc( mom_old, mass );
                    const float_X QoM = charge / mass;
                    const float_X B4 = B2 * B2;
                    float3_X r = pos;

                    if( B4 > epsilon )
                    {
                        trigo_X sinres;
                        trigo_X cosres;
                        trigo_X arg = B * QoM * deltaT / SPEED_OF_LIGHT;
                        math::sincos( arg, sinres, cosres );

                        r.x() = bField.x() * bField.x() * bField.x() * bField.x() * QoM
                            * ( eField.x() * QoM * deltaT * deltaT + 2.0f * ( deltaT * vel_old.x() + pos.x() ) );

#define SUM_RLINE1(I,J,K) 2.0 * bField.J() * bField.J() * bField.J() * bField.J() * QoM * pos.x() \
                    + 2.0 * bField.J() * bField.J() * bField.K() * bField.K() * QoM * pos.x() \
                    + bField.J() * bField.J() * bField.J() * ( -levichivita(I,J,K) * 2.0 * SPEED_OF_LIGHT * ( eField.K() * QoM * deltaT + vel_old.K() ) + bField.I() * QoM * deltaT * ( eField.J() * QoM * deltaT + 2.0 * vel_old.J() ) ) \
                    + bField.J() * bField.J() * ( 2.0 * SPEED_OF_LIGHT * SPEED_OF_LIGHT * eField.I() + bField.I() * bField.I() * QoM * ( eField.I() * QoM * deltaT * deltaT + 2.0 * deltaT * vel_old.I() + 4.0 * pos.I() ) + levichivita(I,J,K) * 2.0 * SPEED_OF_LIGHT * bField.K() * vel_old.J() + bField.K() * QoM * ( levichivita(I,J,K) * 2.0 * eField.J() * SPEED_OF_LIGHT * deltaT + bField.I() * bField.K() * QoM * deltaT * deltaT ) ) \
                    + bField.I() * bField.J() * ( bField.I() * bField.I() * QoM * deltaT * ( eField.J() * QoM * deltaT + 2.0 * vel_old.J() ) - levichivita(I,J,K) * 2.0 * bField.I() * SPEED_OF_LIGHT * ( eField.K() * QoM * deltaT + vel_old.K() ) - 2.0 * SPEED_OF_LIGHT * SPEED_OF_LIGHT * eField.J() )

#define SUM_RLINE2(I,J,K) - bField.J() * ( SPEED_OF_LIGHT * eField.I() * bField.J() - levichivita(I,J,K) * bField.J() * bField.J() * vel_old.K() - bField.I() * SPEED_OF_LIGHT * eField.J() - levichivita(I,J,K) * bField.J() * vel_old.K() * ( bField.I() * bField.I() + bField.K() *bField.K() ) )

#define SUM_RLINE3(I,J,K) levichivita(I,J,K) * bField.J() * ( SPEED_OF_LIGHT * eField.K() + levichivita(I,J,K) * ( bField.J() * vel_old.I() - bField.I() * vel_old.J() ) )

                        r.x() += FOR_JK_NOT_I( x, y, z, SUM_RLINE1 );
                        r.x() += float_X(cosres ) * 2.0 * SPEED_OF_LIGHT * ( FOR_JK_NOT_I( x, y, z, SUM_RLINE2 ) );
                        r.x() += float_X(sinres ) * 2.0 * SPEED_OF_LIGHT * B * ( FOR_JK_NOT_I( x, y, z, SUM_RLINE3 ) );

                        r.y() += FOR_JK_NOT_I( y, z, x, SUM_RLINE1 );
                        r.y() += float_X(cosres ) * 2.0 * SPEED_OF_LIGHT * ( FOR_JK_NOT_I( y, z, x, SUM_RLINE2 ) );
                        r.y() += float_X(sinres ) * 2.0 * SPEED_OF_LIGHT * B * ( FOR_JK_NOT_I( y, z, x, SUM_RLINE3 ) );

                        r.z() += FOR_JK_NOT_I( z, x, y, SUM_RLINE1 );
                        r.z() += float_X(cosres ) * 2.0 * SPEED_OF_LIGHT * ( FOR_JK_NOT_I( z, x, y, SUM_RLINE2 ) );
                        r.z() += float_X(sinres ) * 2.0 * SPEED_OF_LIGHT * B * ( FOR_JK_NOT_I( z, x, y, SUM_RLINE3 ) );

                        r *= float_X(0.5) / B4 / QoM;
                    }
                    else
                    {
                        r += eField * QoM * deltaT * deltaT + vel_old * deltaT;
                    }
                    dr = r - pos;
                    
                    dr *= float3_X(1.0) / cellSize;

                }

                pos += dr;
            }
Example #13
0
 ~PrintNonZeroComponents()
 {
     const float_X unit_current = UNIT_CHARGE / (UNIT_LENGTH * UNIT_LENGTH * UNIT_TIME);
     totalJ *= unit_current;
     printf("totalJ: (%g, %g, %g) A/m²\n", totalJ.x(), totalJ.y(), totalJ.z());
 }