Skip to content

Commit

Permalink
Merge pull request #25344 from dschwen/calories
Browse files Browse the repository at this point in the history
Add calorie unit
  • Loading branch information
dschwen authored Aug 30, 2023
2 parents 4674245 + 6464ec1 commit f11ac02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions framework/src/utils/Units.C
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ const std::vector<std::pair<std::string, MooseUnits>> MooseUnits::_unit_table =
{{MooseUnits::BaseUnit::KILOGRAM, 1},
{MooseUnits::BaseUnit::METER, 2},
{MooseUnits::BaseUnit::SECOND, -2}}}}, // Joule
{"cal",
{4.184,
0,
{{MooseUnits::BaseUnit::KILOGRAM, 1},
{MooseUnits::BaseUnit::METER, 2},
{MooseUnits::BaseUnit::SECOND, -2}}}}, // Calorie
{"W",
{1,
0,
Expand Down
4 changes: 4 additions & 0 deletions unit/src/UnitsTest.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ TEST(Units, numbers)
EXPECT_DOUBLE_EQ(Real(MooseUnits("m/0.1^3") / MooseUnits("km")), 1.0);
EXPECT_DOUBLE_EQ(Real(MooseUnits("m/1e-3") / MooseUnits("km")), 1.0);
EXPECT_DOUBLE_EQ(Real(MooseUnits("1234.567")), 1234.567);
EXPECT_DOUBLE_EQ(Real(MooseUnits("20*80")), 1600);
}

TEST(Units, si_prefixes)
Expand All @@ -55,6 +56,9 @@ TEST(Units, parse)
{"m^3", "m^3"},
{"N*m", "m^2*kg*s^-2"},
{"mm", "0.001 m"},
{"5m * 1/6s", "0.833333 m*s^-1"},
{"5m/(6s)", "0.833333 m*s^-1"},
{"cal", "4.184 m^2*kg*s^-2"},
{"kg/(m*s^2)", "m^-1*kg*s^-2"},
{"kg/(m*s)^2", "m^-2*kg*s^-2"},
{"eV/at", "1.60218e-19 m^2*kg*s^-2*at^-1"},
Expand Down

0 comments on commit f11ac02

Please sign in to comment.