Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update delta #139

Open
giadarol opened this issue Jun 8, 2021 · 2 comments
Open

Update delta #139

giadarol opened this issue Jun 8, 2021 · 2 comments

Comments

@giadarol
Copy link
Contributor

giadarol commented Jun 8, 2021

Hello,
is there a reason why "add_to_energy" affects zeta and "update delta" does not?

Compare:

SIXTRL_INLINE void NS(Particles_update_delta_value)(

vs

SIXTRL_INLINE void NS(Particles_add_to_energy_value)(

@rdemaria
Copy link
Contributor

rdemaria commented Jun 8, 2021

Yes, it should update z, maybe it is done through add to energy?

@giadarol
Copy link
Contributor Author

giadarol commented Jun 8, 2021

Yes, it should update z, maybe it is done through add to energy?

It doesn't look like it... Se below:

SIXTRL_INLINE void NS(Particles_update_delta_value)(
    SIXTRL_PARTICLE_ARGPTR_DEC NS(Particles)* SIXTRL_RESTRICT p,
    NS(particle_num_elements_t) const index,
    NS(particle_real_t) const new_delta_value )
{
    typedef NS(particle_real_t) real_t;

    SIXTRL_STATIC_VAR real_t const ONE = ( real_t )1;

    real_t const beta0 = NS(Particles_get_beta0_value)( p, index );
    real_t const delta_beta0 = new_delta_value * beta0;
    real_t const ptau_beta0  = sqrt( delta_beta0 * delta_beta0 +
        ( real_t )2 * delta_beta0 * beta0 + ONE ) - ONE;

    real_t const one_plus_delta = ONE + new_delta_value;
    real_t const rvv    = ( one_plus_delta ) / ( ONE + ptau_beta0 );
    real_t const rpp    = ONE / one_plus_delta;
    real_t const psigma = ptau_beta0 / ( beta0 * beta0 );

    #if !defined( NDEBUG ) && !defined( _GPUCODE )
    SIXTRL_STATIC_VAR real_t const EPS  = ( real_t )1e-9;
    SIXTRL_STATIC_VAR real_t const ZERO = ( real_t )0;

    SIXTRL_ASSERT(   beta0              > ZERO );
    SIXTRL_ASSERT( ( beta0 * beta0    ) > EPS  );
    SIXTRL_ASSERT( ( one_plus_delta   ) > EPS  );
    SIXTRL_ASSERT( ( ONE + ptau_beta0 ) > EPS  );
    SIXTRL_ASSERT( ( delta_beta0 * delta_beta0 +
        ( real_t )2 * delta_beta0 * beta0 + ONE ) > ZERO );

    #endif /* !defined( NDEBUG ) && !defined( _GPUCODE ) */

    NS(Particles_set_delta_value)(  p, index, new_delta_value );
    NS(Particles_set_rvv_value)(    p, index, rvv );
    NS(Particles_set_rpp_value)(    p, index, rpp );
    NS(Particles_set_psigma_value)( p, index, psigma );

    return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants