Skip to content

Physical to Lattice time

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5880
    achodankar
    Participant

    Hello Developers,
    Can you explain why 0.5 is added while converting physical time to lattice time?
    My understanding is lattice time = physical time/(conversion factor for time)

    Here is the code snippet from the source code:

    constexpr size_t getLatticeTime( T physTime ) const
    {
    return size_t(physTime / _conversionTime + 0.5);
    }

    Thank you.

    Yours sincerely,

    Abhijeet D. Chodankar

    #5881
    mathias
    Keymaster

    Its rounding to the next integer.

    #5884
    achodankar
    Participant

    Hello Mathias,
    Thank you for your response. I used two ways to declare the values:
    1) const T
    2) size_t (as done in the code)

    Why use size_t over const T declaration? I get the same values. I understand the rounding part as you suggested.

    Here is the code snippet I tested with

    cout<<“The physical simulation time is “<<maxPhysT<<endl;
    size_t lattice_time = (maxPhysT/converter.getConversionFactorTime()+0.5);

    OR

    const T lattice_time = maxPhysT/converter.getConversionFactorTime();

    cout<<“The Lattice time is “<<converter.getLatticeTime(maxPhysT)<<endl;
    cout<<“The Lattice time is “<<lattice_time<<endl;

    Thank you.

    Yours sincerely,

    Abhijeet D. Chodankar

    #5885
    mathias
    Keymaster

    Because lattice time is an integer value! It must be int, size_T or similar!

    #5886
    achodankar
    Participant

    Hello Mathias,
    Thank you very much. I understand it well now.

    Yours sincerely,

    Abhijeet

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.