Skip to content

Zig library providing physical constants and reference data based on the CODATA recommended values.

License

Notifications You must be signed in to change notification settings

astrozig/codata.zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codata.zig

codata.zig is a Zig library providing physical constants and reference data based on the CODATA recommended values.

Overview

This library aims to provide accurate, up-to-date physical constants for scientific and engineering calculations in Zig, following the latest CODATA recommendations.

Features

  • Standard physical constants (e.g., Planck constant, speed of light, elementary charge)
  • Easy-to-use Zig API
  • Values sourced from CODATA and NIST

Installation

Fetch this repository :

$ zig fetch --save git+https://github.com/astrozig/codata.zig

Add it to your build.zig :

const std = @import("std");

pub fn build(b: *std.Build) void {
    // -- snip --

+   const codata_dep = b.dependency("codata_zig", .{
+       .target = target,
+       .optimize = optimize,
+   });

    // Where `exe` represents your executable/library to link to
+   exe.root_module.addImport("codata", codata_dep.module("codata"));

    // -- snip --
}

Usage

const codata = @import("codata");

pub fn main() !void {
    const c = codata.speed_of_light_in_vacuum; // Example
    // Use constants in calculations
}

Updating constants

Generate new constants from src file:

zig run src/gen.zig -- data/CODATA_2022_adjustment.txt

About

Zig library providing physical constants and reference data based on the CODATA recommended values.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages