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

Add ITime, an integer time type #124

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add ITime, an integer time type #124

wants to merge 2 commits into from

Commits on Nov 7, 2024

  1. Configuration menu
    Copy the full SHA
    badf904 View commit details
    Browse the repository at this point in the history
  2. Add ITime, an integer time type

    This commit introduces the `ITime` type, a new approach to handling time
    and dates within CliMA simulations. `ITime` utilizes integer-based
    representation and operations, offering three advantages:
    - Eliminates floating-point errors.
    - Provides a trivial way to go from times to dates.
    - Provides an abstraction layer over the calendar system, enabling
      future support for calendars beyond the Gregorian calendar currently
      used by Dates.
    
    `ITime` is defined by a `counter`, a `period`, and an optional
    `start_date`. The counter tracks the number of elapsed periods since the
    start date and the period is customizable (1 second by default).
    `ITime`s also support fractional counters (currently represented by
    `Rational`s) to account for stages in the timestepper loop.
    
    `ITime`s support the arithmetic operations (+, -, *, /, div) while
    maintaining consistency in the units and the start date. This allows
    users to just specify `start_date` and `period` for one of their
    `ITime`s (e.g., `t_start`), and everything will be
    automatically propagated.
    
    Given an `ITime` `t`, one can obtain its time with `seconds(t)` and the
    date with `date(t)`. I also added `float(t)` to help with the transition.
    Sbozzolo committed Nov 7, 2024
    Configuration menu
    Copy the full SHA
    70c7597 View commit details
    Browse the repository at this point in the history