@mark1russell7/stack-needs
v0.11.4
Published
The need rates of draws as reference data: the daily food energy of each person by age, sex and activity, from the Dietary Guidelines for Americans, with its source. An add-on of system-stack.
Maintainers
Readme
@mark1russell7/stack-needs
The need rates of draws as reference data. Each rate has its source and its license. The first tables are the food energy that each person needs each day.
It is an add-on of @mark1russell7/system-stack. It makes a fragment of an endurance layer, and @mark1russell7/stack-endurance calculates with it. The data names no person and no place. The persons of a household are input data.
Each function is a plain function with no clock, no network and no file.
The records
| Record | What it tells |
| --- | --- |
| CalorieTable | A table of estimated calorie needs from one source, with the place of the tables in the source. |
| CalorieTables | One table, or tables in order. For each person, the first table with a row for the age gives the need. |
| CalorieRow | A sex, a range of ages in months, and the need of each activity level, or one need for all levels. |
| CalorieChange | A stage (for example pregnancy-2), a sex, and the change of the daily need at that stage, with the condition of the source. |
| Person | A group of persons: a sex, an age in whole months, a count and, as options, an activity level and a stage. |
| HouseholdFragment | A fragment of an endurance layer: the resources, the stores, the draws and their direct uses. It has the form of EnduranceLayer. |
| OpenedWaste | The containers of one product with no cold storage: the count, the energy of one container, the feed, the energy used and the waste. |
| CookFragment | A fragment of an endurance layer: the resources and one cook converter for each dry resource with a read. It has the form of EnduranceLayer. |
| CookLine | The energy, the cook water, the heat to boil, the stove time and the fuel of one pot of one dry food, each a read or a no read. |
| WaterTreatFragment | A fragment of an endurance layer: the resources, the stores of the treatment supplies and one converter for each method with a read. It has the form of EnduranceLayer. |
| HeatStoveFragment | A fragment of an endurance layer: the resources, the fuel stores and one heat converter for each heater with a read. It has the form of EnduranceLayer. |
| ResourceSubset | A resource and a wider resource. Each unit of the resource is also a unit of the wider resource, for example water.bottled in water.stored. |
| CitedFormulaWater | The rule of the mix water of infant formula powder: the resource, the quotes of the source, the cleaning water as a no read and the citation. |
The rules of the data
- Each value comes from a table of a cited source. A value with no source is not data.
- An age with no row in the tables gives a line with no read for that person, not an error. The total of
calorieNeedis then a lower limit, andreadis false. - The activity level is an explicit input. The package has no default level.
- A stage of pregnancy or lactation is an input of a person record.
calorieNeedadds the change of the stage to the need of the row. The change comes from the table of the row. A stage that this table does not have for the sex of the record is an error, not a no read. Thus the optionleave-outcannot remove a pregnant person from a draw. One stage holds for each day of a call. For a period that crosses stages, the planner selects the stage, for example the stage with the largest change. - The cook converters come from the cited cook facts of the catalog and cited constants. The boil fuel comes from a cited stove share or a cited boil yield. A missing fact gives a no read, not a figure. Refer to the section on the water and the fuel of a cook.
checkCalorieTable is the gate of a table. It gives the findings of checkSources of @mark1russell7/guidebook for the source, also for a hash that is not 64 lowercase hexadecimal digits (bad-sha256). The source of a table must have a publisher (by), a page of its terms and a hash, and HTTPS addresses (the options require and https of the gate). A missing field gives missing-field. For the rows, it refuses two rows of one sex with ages in common, and a need that is not above 0 in kcal/d. The rows of each sex have no gap between two rows (needs-gap). A table can start after month 0 and end at a closed row. Each change has a stage, a title, a sex of the table and a finite value in kcal/d. Each stage and sex has one change at most (needs-change).
checkCalorieChain is the gate of tables in order. It gives the findings of checkCalorieTable for each table. Two tables with the same id give needs-id.
Then, for each sex, the rows of all the tables must cover each month from 0 to an open last row (needs-gap, record chain). Before 0.6.0, checkCalorieTable refused a table with a closed last row.
The source of a table is the Source of @mark1russell7/guidebook, with its field sha256. Before 0.3.0, the package had its own type HashedSource and the code needs-hash.
A first look
import { SUPPLY_CATALOG } from "@mark1russell7/market/supplies";
import { enduranceOf } from "@mark1russell7/stack-endurance";
import { calorieNeed, DGA_CALORIES, householdFragment, type Person } from "@mark1russell7/stack-needs";
// Made-up persons: two adults of 33 years.
const persons: Person[] = [
{ sex: "male", ageMonths: 396, count: 1 },
{ sex: "female", ageMonths: 396, count: 1 },
];
console.log(calorieNeed(DGA_CALORIES, persons, "sedentary", 1).need); // { value: 4200, unit: "kcal" }
const food = householdFragment({
persons,
activity: "sedentary",
catalog: SUPPLY_CATALOG,
units: { "food.rice-white-1kg": 4, "food.peanut-butter-1kg": 2 },
level: "critical",
levels: ["critical"],
});
const cut = { case: "food-cut", title: "No food shops", cuts: [{ part: "food.retail", title: "No food shops", source: "example" }] };
if (food.layer === undefined) throw new Error(food.why);
console.log(enduranceOf(food.layer, cut, { at: "2026-11-22" }).needs["food.energy"]?.days); // about 2.85: the peanut butter aloneThe join of a household and a buy list
householdFragment turns the persons and a buy list into a fragment of an endurance layer. The buy list is the count of units of each product of the catalog of supplies of @mark1russell7/market.
- The draw
food.energyhas the need of the persons for one day, inkcal. Its users are the persons. - The draw
food.infant-formulahas the infants on formula below 6 months (FORMULA_DRAW_MONTHS), with the whole need of their rows. - The fragment has each draw with one or more users. The draw
food.energyis first. - Each gift of the buy list (
giftsOf) is one store. Examples arefood.no-cookinkcal, the dry foods inkg,water.storedinLandwater.bottledinL. - The only converters of the fragment are the subsets of the resources of its stores (
subsetConverters). The defaultRESOURCE_SUBSETSmakeswater.bottledalsowater.stored. Refer to the section on the water of infant formula powder. - A gift with no read has no store. It is in
noReads, andstoresReadis false. The draw does not change. - With no cold storage, an opened container of formula serves one feed. This is the default (
coldis false), the worst case of no power. The next section tells the rule. - The direct uses are each use of
usesfor the need of a draw. The defaultDIRECT_USESgivesfood.no-cookto the food draw andfood.infant-formula-readyto the formula draw, 1 kcal for each kcal. - The resources are the resources of the stores and of the direct uses. The resource of each direct use is in
kcalin the catalog, or the function throws aRangeError. - The supply part of each draw is
supply. Its default is the part ofNEED_SUPPLIESfor the need of the draw:food.retail. - The result also has the food energy of each product (
buyListEnergy). A caller gets the energy of the dry food for its converters from it.
The result has two reads. needRead tells if the draw has a read, and storesRead tells if each gift of the buy list has a read.
Opened containers with no cold storage
The WIC guide of the USDA (page 106) tells this rule: with limited access to a refrigerator, use formula immediately after a ready-to-feed container is opened. The catalog of market gives the rule as the field opened of a product, with the size of one container.
| Step | Value |
| --- | --- |
| Feeds in one day | 8 (FORMULA_FEEDS). Table 5.2 of the WIC guide (page 137) gives a feed every 3 to 4 hours. More feeds give smaller feeds, so 8 is the worst case. |
| One feed | The smallest need of an infant of the formula draw, divided by 8 |
| Energy that one container gives | feed / ceil(feed / container). A feed that is more than a container takes more containers, and the rest of the last is waste. |
| Store | The count of containers times the energy that one container gives. waste gives the rest for each product. |
A product with a container of no read gives no store. It is in noReads, so the stores are a lower limit. The 1 kg formula of the catalog has no container size yet. The option cold: true gives the whole energy of each container. Only the formula draw has a cited size of one feed. Thus a product with opened containers that feeds no formula draw makes the function throw a RangeError.
A person with no row
The default tables are CALORIE_CHAIN: the guidelines, then the infant table. They give a row for each age. A table of the option table can have no row for an age. By default, a person with no row gives no layer. The result has layer: undefined, the persons with no row and the reason. A low rate gives too many days, and the draw has no field for a no read. A draw of 0 kcal also gives no layer: a household with no person, or each count 0.
The option noRow: "leave-out" leaves those persons out of the draw. The users are then the persons with a row, and leftOut lists the other persons. The draw then has no need of those persons.
The days are then an upper limit for the whole household.
An infant
The infant table gives the need of an infant below 12 months (INFANT_MONTHS). Each person record below 12 months must have the field feeding. It has no default, because each way gives a different draw.
| feeding | The draw of food energy |
| --- | --- |
| food | The draw holds the need of the infant, from the infant table. |
| breast-milk | Only below 12 months. Below 6 months (BREAST_MILK_MONTHS), the draw does not hold the need of the infant. The milk comes from the food of the mother, so the stage of lactation of the mother holds that energy. From 6 months, the infant also has food. The draw holds the need of the row minus the milk energy (MILK_LATER, 381 kcal/d). The result lists the infant in breastMilk. |
| formula | Only below 12 months. Below 6 months (FORMULA_DRAW_MONTHS), the draw food.infant-formula holds the whole need of the infant, because the infant has milk only. Only the formula of the buy list feeds it, so a list with no formula gives 0 days. From 6 months, no cited source gives the part of formula. Thus the infant gives no layer, as a person with no row. With noRow: "leave-out", no draw has the need of the infant, and leftOut lists the infant. With formulaLater: "whole", the formula draw holds the whole need: the upper limit of formula. With formulaLater: "least", the formula draw holds the lower limit, and the food draw holds the rest. The result lists each infant on formula in formula. |
With the default tables, the line of each infant in need has a read, so need gives the energy of the whole household.
The limits of formula from 6 months:
- The upper limit is the whole need of the row. Formula cannot give more energy than the whole need. Give
formulaLater: "whole"for this limit. - Table 5.2 of the WIC guide (page 137) gives the formula of one day. It is approximately 24 to 32 ounces at 6 to 8 months.
- At 8 to 12 months, the table gives approximately 24 ounces.
- The lower limit is 24 fl oz a day (
FORMULA_LATER_LEAST). GiveformulaLater: "least"for this limit. When the need of the row is less, the formula draw holds the need. - The FDC item 172319 (ready-to-feed formula) gives 63 kcal in 100 g and 30.4 g in 1 fl oz. Thus 1 fl oz gives 19.152 kcal, and 24 fl oz give 459.648 kcal.
- The two limits give the same total energy. Only the split between the formula draw and the food draw changes.
The rules of breast milk:
- A person of the household must have a stage of lactation, or the function gives a
RangeError. - The change of a stage is the milk of one infant. Thus each infant on breast milk needs one person of the draw with a stage of lactation. When the infants are more, the function gives no layer, also with
leave-out. A person that the draw leaves out does not count. - From 6 months, the food draw holds the need of the row minus 381 kcal/d of milk. The next sections give the sources.
The notes b and c of Table A2-3 of the guidelines (page 141) give the two changes of lactation:
| Stage | The note of the source | The change |
| --- | --- | --- |
| lactation-1 | 500 calories/day for the milk production, minus 170 calories/day for the weight loss after the birth. | 330 kcal/d |
| lactation-2 | 400 calories/day for the milk production. The source assumes a stable weight after 6 months. | 400 kcal/d |
Thus below 6 months, a part of the milk comes from the stores of the mother. The draw holds only the part from food. The source gives the energy of the milk production, not the energy that the infant gets. It gives no change for two or more infants.
Table 5-14 of the NASEM report (2023, page 97) gives the milk of the first year. The milk energy is the milk times 0.67 kcal/g:
| Time after the birth | Milk (g/d) | Milk energy (kcal/d) | The women of the source | | --- | --- | --- | --- | | 0 to 2 months | 732 | 490 | Only breastfeed | | 3 to 4 months | 779 | 522 | Only breastfeed | | 5 months | 826 | 553 | Only breastfeed | | 6 months | 894 | 599 | Only breastfeed | | 7 to 12 months | 568 | 381 | Partly breastfeed |
From 6 months, the infant also has food. Thus the package takes 381 kcal/d of milk from 6 months (MILK_LATER). Less milk gives a larger draw, so this is the worst case.
The NASEM report gives no change for a mother of two or more infants. Thus twins on breast milk stay a no read: the function gives no layer.
A stage of lactation is a change with milk: true: lactation-1 and lactation-2 of the guidelines. From 6 months, an infant eats food and drinks milk. With feeding: "food" and the stage lactation-2 of the mother, the draw counts a part of that energy two times. The result is then more food than the household needs, which is on the safe side.
The resources of the buy list and the join
The fragment has no converter of food. Thus, with this fragment alone, only food.no-cook feeds the draw. This is the worst case: no water and no fuel.
cookFragment gives the converters for the dry food in a different fragment, with the water and the fuel of each pot. Then joinEndurance joins the fragments. The dry food then adds days only while the water and the fuel last.
formulaMixFragment gives the converter of the infant formula powder in a different fragment, with its water. The powder then adds days of formula only while the water lasts.
This fragment declares the resource codes of the buy list, for example water.stored in L. A different fragment, for example the fragment of a water tank, can declare the same resource. joinEndurance of @mark1russell7/stack-endurance joins two equal records into one. A different unit is a fault of the join.
The water and the fuel of a cook
cookFragment turns the dry food of a buy list into converters of an endurance layer. One run of a converter is one pot. The run takes the dry food, the cook water and the fuel, and gives the food energy of the pot. Thus a dry food with no fuel or no water gives no meal.
import { SUPPLY_CATALOG } from "@mark1russell7/market/supplies";
import { cookFragment } from "@mark1russell7/stack-needs";
const cook = cookFragment({
catalog: SUPPLY_CATALOG,
units: { "food.rice-white-1kg": 4 },
// Made-up stove and share: 227 g of propane in 90 min, and 0.5 of the higher heating value.
stove: { fuel: "fuel.propane", rate: { amount: 227, unit: "g", per: { amount: 90, unit: "min" }, fact: "example.stove" } },
share: { value: 0.5, heating: "higher", cite: "example.share" },
batch: { value: 0.5, unit: "kg" },
});
// cook.layer has the converter cook:food.rice-white-dry. Join it with the layer of householdFragment and a store of fuel.Since 0.11.4, the input foods also cooks food resources of the catalog from their own cook facts and food energy. An example is the harvest of a garden bed of @mark1russell7/stack-yields. With market 0.12.5, foods: ["food.potato", "food.sweet-potato"] gives a converter of each, from the cited cook water of two MyPlate Kitchen recipes. The line of a food resource has the code of the resource in product. A resource with no cook water, no cook time or no food energy gives a no read, not 0.
The model of one pot:
- The cook water is
cookWaterof@mark1russell7/markettimes the dry mass. It takeswater.stored, the resource of the drinking water. - The heat to boil is the mass times 4.19002 kJ/(kg.K) times the rise to the boil (100 °C). The mass is the water and the dry food. The rise starts at the start temperature. This temperature is an input with its citation. The default is 0 °C, which gives the most heat. The dry food takes the specific heat of water, which is higher than its own. This term holds the heat above the true value.
- The boil time is the heat divided by the stove rate times the stove share. The share is the part of the stove heat that goes into the water and the food. The heat of the pot itself is in the losses. It is a cited input with its heating value. It has no default.
A boil yield of the stove (
boilof market) also gives the boil fuel, with no share and no fuel energy. The boil fuel is then the heat of the pot over the heat that 1 kg of fuel put into the test water. The test water takesWATER_DENSITY_MIN(0.95865 kg/L at 100 °C, from the USGS table). The rise goes from the cited start to the cited end of the test. Each choice gives the most fuel. At a high place the test water boils below 100 °C, so the end has no default. The boil time is then the boil fuel over the mass rate. When the share and the yield both give a boil fuel, the line takes the most. The adverse factor of the stove (adverseof market) multiplies the boil fuel of the yield. Cold, snow melt and wind take more fuel than the calm test. A factor with the boundmostalso takes a most yield. So does a factor with a typical range (typical). The fuel from each of the two is an estimate, not an upper limit. For example, the canister stove of the catalog has a most yield and the factor 4. The factor is the high end of its typical range of 3 to 4. Its boil fuel is 4 times the calm fuel. The line also gives the fuel of the pot at each end of the range (fuelSpread). A factor with no bound and no range is the value. The cook part stays the rate times the cook time. - The stove time is the boil time plus the high end of the cook time. The cook time starts when the water boils.
Since 0.11.3, a cook time can be for a mass of the food (the field
perof market). A skillet bread cooks one piece after the other. The cook time of the pot is then that time times the batch, divided by that mass. - The fuel is a safe upper limit: the stove burns at its full rate for all of the stove time. A stove rate with a bound gives a read only on its safe side (since 0.10.8). The read then has the field
bound: "most": the true value is at most the read. At a high place the cook time is longer. From 1000 ft, the cook time and the fuel are a no read (see the elevation). A boil fuel from an adverse factor is an estimate (step 3), so that fuel is not a proven upper limit. - A rate in a mass gives the fuel mass directly. A rate in an energy gives a mass only through the cited energy of the fuel (
fuelEnergy), with the same heating value. - The dry mass of one pot (
batch) is a plan of the caller. It has no default. Give the smallest pot that the cook makes. Each pot takes its own cook time, so a batch above the real pot gives too little fuel.
Each value of a line is a read or a no read with its reasons. These facts give a no read:
| Missing fact | The no read |
| --- | --- |
| No cited cook water | The water, the heat and the fuel. A food with a cook time and no cited water has no fuel. |
| No cited cook time | The stove time and the fuel. |
| No cited stove rate, or a rate that is not an energy or a mass in a time | The stove time and the fuel. |
| A stove rate with the bound least of market | The fuel. The fuel of the cook time is the rate times the time, so a least rate gives too little fuel. The stove time has a read as a most. |
| A stove rate with the bound most of market | The stove time. The stove time falls when the rate rises, so a most rate gives too little time. The fuel has a read as a most, because the boil fuel does not change with the rate. |
| A stove rate with another bound | The stove time and the fuel. The bound has no known side. |
| No cited stove share, and no boil yield with a read | The stove time and the fuel. The water and the heat keep their reads. |
| A boil yield with the bound most and no adverse factor with the bound most or a typical range, or with no cited start or end temperature | No boil fuel from the yield. A most yield, for example the calm test of a maker, gives too little fuel for the boil. |
| An adverse factor with the bound least, or a factor that is not a finite number of 1 or more | No boil fuel from the yield. A least factor gives too little fuel. |
| An adverse factor with a bound and a typical range, a range that is not 1 <= low <= high, or a factor outside its range | No boil fuel from the yield. |
| A heating value of the share or of the rate that is not the heating value of the fuel energy | The stove time and the fuel. |
| No cited energy of the fuel, with a rate in an energy or a share on a rate in a mass | The stove time and the fuel. |
| A cited soak rate that does not convert to L/kg, for example a rate for each volume with no bulk mass | The soak water. The resource then has no converter. |
| The quick soak (soak: "quick") for a product with a cold soak and no quick soak | The soak water, the stove time and the fuel. The model does not take the cold soak in its place. |
| No soak (soak: "none") for a product with a cited soak and no unsoakedTime | The stove time and the fuel. The cook time of the food with no soak has no source. |
| No soak (soak: "none") for a product with a cited soak | The cook water, the stove time and the fuel. The cited cook water is for the food after its soak. An unsoaked food takes up more water, so that rate is too low. The catalog cites no cook water for the food with no soak. |
| No food energy of the product | The energy. |
| A product that gives more than one food | The energy. The catalog gives one energy for the whole product. |
A dry resource with a no read in a line has no converter. It is in noReads, and read is false. Two products of the list can give one dry resource, for example rice and oats. The converter then takes the worst case of their lines: the most water, the most fuel and the least energy.
The water take of a pot is the cook water and the soak water. The cook discards the soak water: the market fact usda.refried-beans-soak cites the USDA recipe, which tells to discard it. Thus the soak adds to the water take.
For example, the dry beans of the catalog take 3.65 L/kg of soak water and 3.65 L/kg of cook water. A product with no cited soak takes no soak water.
The input soak gives the soak method of the buy list. Since 0.10.5. The line of a quick soak or of no soak tells the method in soakMethod.
| soak | The soak water | The heat and the fuel of the soak | The cook time |
| --- | --- | --- | --- |
| cold (the default) | soakWater of market | None. The soak is cold. | time |
| quick | quickSoakWater of market | The heat to boil the soak water and the dry food from the start temperature (soakHeat), with the rule of the cook water. The boil fuel of that heat, and the full rate for the high end of the boil span (quickSoak.boil). The stand time is off the heat, so it takes no fuel. | time |
| none | None | None | The high end of unsoakedTime for a food with a cited soak. A food with no soak facts keeps time. A food with a cited soak takes unsoakedCookWater, or has a no read of its cook water. |
The default gives the same lines as before 0.10.5. A product with no cited soak, cold or quick, takes no soak with each method. The cook water stays cookWater, except for a soaked food with no soak.
Since 0.10.7, a soaked food with no soak takes the cited cook water unsoakedCookWater of market. The catalog of market cites none for its beans, so they stay a no read.
The stove day
A stove cooks only so many pots in a day. Since 0.10.9, the input stoveDay gives the most time that the stove burns in a day, for example 240 min. It is a plan of the caller, with no default.
- Each converter then has the limit
perDayof stack-endurance. The limit is the whole pots of the stove day at the most stove time of one pot. A part of a pot is not a pot, so the limit rounds down. - The converters of all the dry foods share the day of the stove. So
stoveDayneedsdevice. - The stove time of a pot must be a value or a most. A stove time with no read, for example from a most stove rate, gives no converter. A converter with no limit can cook more pots than the stove day gives.
- A least stove rate gives a most stove time, but too little fuel. Thus a stove rate with a bound gives no converter with a stove day. Only a rate with no bound gives one.
The elevation
The cook times of the catalog are for a boil at sea level. Since 0.10.6, the input elevation gives the elevation of the cook in m, with its citation.
- Without
elevation, the model takes a cook at sea level. - From
SEA_LEVEL_TIME_ELEVATION(1000 ft, 304.8 m), each cook time and fuel is a no read. The heat to 100 °C stays, because it is more than the heat to the true boil. - USDA Guide 1 of the Complete Guide to Home Canning gives the limit. A time for sea level is not enough from 1000 ft, because water boils at a lower temperature.
- The guide gives the limit for canning. The model applies it to the cook time of a dry food in boiling water. No cited rule gives the longer time.
- Below sea level, water boils above 100 °C. Each heat, cook time and fuel is then a no read.
The fuel of the quick soak also adds to each end of
fuelSpread.
The cook water and the drinking water are one store, water.stored. A cook can use tap water. The subset converter of householdFragment also gives the bottled water of the buy list as water.stored, so a cook takes the two. A drinking draw at a higher level takes its water first, by the take order of enduranceOf. The drinking draw keeps back its days times its demand, which is all of the store. Thus, when a case cuts the water supply, the dry food adds 0 days at each amount of stored water.
jointDays of @mark1russell7/stack-endurance gives the joint answer: the days that the drink and the cook hold together, with the best share of the water.
The cited constants:
| Name | Value | Source |
| --- | --- | --- |
| WATER_SPECIFIC_HEAT | 4.19002 kJ/(kg.K) | The NIST Guide to the SI (SP 811). Appendix B.8 gives 4.190 02 J for the calorie (mean). The common definition of that calorie is the mean from 0 °C to 100 °C, and SP 811 does not state the range. Footnote 10 tells that the calorie is the energy to raise 1 g of water by 1 °C. The enthalpy table of water at 0.101325 MPa in the NIST Chemistry WebBook checks the range: the mean from 0.01 °C to the boil is 4.19104 kJ/(kg.K). From a start of 10 °C to 30 °C, the heat is within 0.02% of the table. From 90 °C, the heat is 0.48% less than the table. The WebBook is all rights reserved (the license all-rights-reserved of guidebook), so the check cites only its values as facts. US law gives no copyright to facts, and that law permits this use, not the terms of NIST. |
| WATER_DENSITY_MAX | 1 kg/L | The page Water Density of the USGS Water Science School. Its table gives 1.00000 g/cm3 at 4.0 °C, its largest value. Thus the water mass is an upper limit. |
| BOIL_CELSIUS | 100 °C | The end of the rise. Water boils at a lower temperature at a high place, so the heat is less. But the cook time is longer there. From SEA_LEVEL_TIME_ELEVATION, the cook time and the fuel are a no read. |
| SEA_LEVEL_TIME_ELEVATION | 304.8 m | USDA Guide 1 of the Complete Guide to Home Canning, page 1-10. A process time for sea level is not enough at 1000 ft or more, because water boils at a lower temperature. |
The two sources are works of the United States federal government (the license us-public-domain of guidebook).
The water constants (WATER_SPECIFIC_HEAT, WATER_DENSITY_MIN, WATER_DENSITY_MAX and BOIL_CELSIUS), their sources and the type CookConstant are in one module, src/water-facts.ts. The cook, stove, water, heat, rain and mix modules import it. The package root gives the same names as before.
The water of a raw source
Since 0.10.15, waterTreatFragment makes raw water safe to drink, as converters of an endurance layer. Raw water is water from a spring, a stream, a pond or rain. Each converter takes raw water (water.raw) and a treatment supply. It gives the same volume of safe water in water.stored, the resource of the drinking water.
import { SUPPLY_CATALOG } from "@mark1russell7/market/supplies";
import { waterTreatFragment } from "@mark1russell7/stack-needs";
const water = waterTreatFragment({
// Made-up amounts: 200 L of raw water, one reverse osmosis filter of 400 L, 50 mL of 6% bleach and 20 tablets of 1 L.
raw: { liters: 200, cite: "example.raw" },
filter: { rating: "reverse-osmosis", liters: 400, count: 1, cite: "example.filter" },
bleach: { percent: 6, milliliters: 50, cite: "example.bleach" },
tablet: { liters: 1, count: 20, cite: "example.tablet" },
// Made-up stove and share, as in the cook example.
boil: {
catalog: SUPPLY_CATALOG,
stove: { fuel: "fuel.propane", rate: { amount: 227, unit: "g", per: { amount: 90, unit: "min" }, fact: "example.stove" } },
share: { value: 0.5, heating: "higher", cite: "example.share" },
pot: { value: 2, unit: "L" },
},
});
// water.layer has the stores of the supplies and the converters treat:filter, treat:bleach, treat:tablet and treat:boil.The converters:
| Method | One run takes | One run gives |
| --- | --- | --- |
| boil | The water of one pot and the fuel of the pot | The water of the pot |
| filter | 1 L of raw water and 1 L of filter capacity (water.filter), and a chemical dose for a filter that does not remove viruses | 1 L |
| bleach | 1 L of raw water and the cited dose of bleach (water.bleach, in mL) | 1 L |
| tablet | 1 L of raw water and 1 / liters tablets (water.tablet) | 1 L |
- The boil fuel has the rules of the cook fuel. The heat is the water mass times
WATER_SPECIFIC_HEATtimes the rise to 100 °C. The water mass takes 1 kg/L (WATER_DENSITY_MAX). - The rolling boil then adds the full stove rate for 1 min (
BOIL_MINUTES). Above 1000 m (LONG_BOIL_ELEVATION), it adds 3 min (LONG_BOIL_MINUTES). Below sea level, the fuel is a no read. - The steam of the boil takes some water. No cited rate gives it, so the converter gives back all the water of the pot.
- The capacity of a filter in
Lis a fact of its label, from the caller. Only a reverse osmosis filter removes viruses, so only that class gives safe water alone. - Each other class of filter also takes a chemical dose: the bleach dose, else the tablet dose. CDC tells to add a chemical disinfectant after such a filter. With no dose, the filter is a no read.
- The bleach dose is 0.1 mL/L for 5% to 9% sodium hypochlorite, and 0.5 mL/L for 1%. A different strength is a no read. With the input
cloudy, the dose is two times the table. - CDC and EPA tell to follow the label of a tablet. Thus the liters of one tablet are a fact of the label, from the caller.
- The wait of 30 min after the bleach (
CHLORINE_WAIT) does not change the days. - The raw water is a store. A source converter of raw water also works, but it makes
enduranceOfread the days in segments, as for a season.
The gate of the fragment:
- With no raw water, no converter has an input, so the days do not change.
- With raw water and no fuel, filter capacity, bleach or tablets, the days do not change.
- When a treatment supply is used up first, the field
bindingofenduranceOfnames its resource, for examplewater.bleach.
The cited constants:
| Name | Value | Source |
| --- | --- | --- |
| BOIL_MINUTES | 1 min | The CDC page How to Make Water Safe in an Emergency: "Bring clear water to a rolling boil for 1 minute". The EPA page Emergency Disinfection of Drinking Water gives the same time. |
| LONG_BOIL_MINUTES | 3 min | The CDC page gives 3 minutes above 6,500 feet. The EPA page gives three minutes above its elevation. |
| LONG_BOIL_ELEVATION | 1000 m | The EPA page gives "5,000 feet (1,000 meters)". The two values do not agree, because 5,000 ft is 1524 m. The CDC page gives 6,500 ft (1981.2 m). The model takes the lowest value, because it gives the most fuel. |
| BLEACH_DOSES | 0.1 mL/L (5% to 9%), 0.5 mL/L (1%) | The CDC emergency page. The EPA page checks the first dose: 2 drops for 1 quart or liter of 6% or 8.25% bleach. |
| CLOUDY_BLEACH_FACTOR | 2 | The CDC emergency page: double the bleach for cloudy, murky, colored or very cold water. The EPA page gives the same rule. |
| CHLORINE_WAIT | 30 min | The CDC emergency page gives at least 30 minutes. The EPA page gives 30 minutes. |
| FILTER_RATINGS | 4 classes | The CDC page About Water Treatment Options When Hiking, Camping, or Traveling gives the germs that each class removes. |
| FILTER_DISINFECT | A rule | The CDC emergency page: after a filter, add a chemical disinfectant. |
The CDC and EPA pages are works of the United States federal government (the license us-public-domain of guidebook). The CDC terms tell that most of its web content is in the public domain. The EPA disclaimers tell that a document can have other terms. The EPA page has no copyright notice, and the model takes only facts, with a citation.
The rain of a roof
Since 0.10.17, rainCatchFragment gives the catch of rain from a roof into a tank, as a source converter of an endurance layer. It has the form of solarConverter: a limit perDay for the wettest month, and the share of each month in monthly. One run gives 1 L of raw water (water.raw), so the treatment converters of waterTreatFragment take it.
import { INCH_MM, rainCatchFragment, waterTreatFragment } from "@mark1russell7/stack-needs";
// Made-up values: a roof of 120 m², the rain of each month in inches, and a tank of 2000 L.
const inches = [3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3];
const rain = rainCatchFragment({
area: { squareMeters: 120, cite: "example.roof" },
rain: { millimeters: inches.map((value) => value * INCH_MM), cite: "example.normals" },
firstFlush: { litersPerSquareMeter: 0.4, cite: "example.flush" },
events: { counts: [10, 9, 11, 11, 11, 10, 10, 9, 8, 8, 9, 10], cite: "example.normals" },
tank: { capacity: 2000, cite: "example.tank" },
});
// rain.layer has the store rain:tank (capacity 2000 L) and the source converter rain:catch.
const treat = waterTreatFragment({ bleach: { percent: 6, milliliters: 500, cite: "example.bleach" } });
// Join the two layers and a drinking draw. The bleach converter takes the raw water of the tank.The catch of one month, in L:
- The gross volume is the area times the rain: 1 mm of rain on 1 m² is 1 L.
- The runoff is the gross volume times the runoff coefficient.
- The first flush is the events times the first flush of 1 m² times the area. The net volume is the runoff minus the first flush, and not less than 0.
- The tank takes at most its capacity in one event. Thus the net volume is not more than the events times the capacity.
- The catch of one day is the net volume divided by the days of the month. February has 29 days, so a year with no leap day gets less water.
The rules of the model:
- The place is input data. The caller gives the rain of each month with its citation, for example from the U.S. Climate Normals of NOAA (
NOAA_NORMALS_SOURCE). For an inch, multiply byINCH_MM. - No federal page that we read gives a runoff coefficient for each roof kind. The caller gives the coefficient of a roof kind with its citation. Without it, the model takes
RAIN_COLLECTION_EFFICIENCY, the low end of the DOE range. - No federal page that we read gives a first-flush volume. Thus the first flush is an input of the caller. The DOE range already includes the loss of the first flush, so a first flush of the caller counts it two times. This is the safe side.
- Without the input
events, the first flush counts one event on each day of the month, and the tank fills one time in a month. Each choice gives less water. - The model spreads the catch of a month evenly on its days.
- The tank is a store of raw water with a capacity. It takes the charge of the converter on the days that no draw takes it. The input
litersof the tank is its water at the start. Do not also give the inputrawofwaterTreatFragment. The stores of one resource all have a capacity, or none has one. - Rain water is raw water.
RAIN_TREAT_RULEandRAIN_FIRST_FLUSH_RULEare cited use rules in the result. They do not change a value. - The converter needs
@mark1russell7/stack-endurance0.8.21 or later, for the charge of a store with a capacity.
The gate of the fragment:
- With no tank, or a tank of capacity 0, the fragment has no store and no converter, so the days do not change.
- A month with no rain has the share 0, so it adds nothing.
- A probe of the tests holds a hand-computed month: area times rain times coefficient, minus the first flush.
The constants:
| Name | Value | Source |
| --- | --- | --- |
| RAIN_COLLECTION_EFFICIENCY | 0.75 | The DOE page Rainwater Harvesting Systems Technology Review of FEMP: "Typical system efficiency is between 0.75 and 0.9". The losses include the roof material and the first flush. The model takes the low end. |
| RAIN_GALLONS_PER_INCH_SQUARE_FOOT | 144 / 231, approximately 0.6234 gal | The sizes of the units: INCH_MM, SQUARE_FOOT_M2 and GALLON_L are exact by definition. The DOE page gives 0.62 (RAIN_GALLONS_CHECK). |
| RAIN_TREAT_RULE | A rule | The CDC page Collecting Rainwater and Your Health: rain water is not necessarily safe to drink without the removal of germs and chemicals. |
| RAIN_FIRST_FLUSH_RULE | A rule | The same CDC page: the device sends the first rain of a storm away from the system. |
The DOE, CDC and NOAA pages are works of the United States federal government (the license us-public-domain of guidebook). The pages have no copyright notice. The model takes only facts and short rules, with a citation.
The water of infant formula powder
formulaMixFragment turns the infant formula powder of a buy list into one converter of an endurance layer. The converter needs no fuel. One run is 1 kg of powder. The run takes the powder and its mix water, and gives the energy of the powder as ready formula. Thus a powder with no water gives no feed.
import { SUPPLY_CATALOG } from "@mark1russell7/market/supplies";
import { formulaMixFragment } from "@mark1russell7/stack-needs";
const mix = formulaMixFragment({ catalog: SUPPLY_CATALOG, units: { "food.infant-formula-powder-1kg": 2 } });
// mix.layer has the converter mix:food.infant-formula-powder. Join it with the layer of householdFragment and a store of water.The records of the converter:
| Field | Value for 1 kg of the catalog powder |
| --- | --- |
| takes | 1 kg of food.infant-formula-powder, and 7.0016 L of water.bottled |
| gives | 5240 kcal of food.infant-formula-ready, the resource of the ready formula |
| id | mix:food.infant-formula-powder. The option prefix changes the start. |
The direct use of food.infant-formula-ready then feeds the formula draw. The powder has a store in the household fragment, and no direct use. cookFragment does not cook it.
The mix rule
The rule takes the label water of the powder. 21 CFR 107.10(a) puts on each US infant formula label a table for 100 kcal of the formula, as prepared by the label directions. The table gives the water in grams. Thus the label water gives the mix ratio of the label as a mass, with no scoop size.
- The label of the store-brand infant powder gives 134 g of water for 100 kcal (
STORE_BRAND_LABEL, from the product page of its maker). - The powder gives 524 kcal and 2 g of water in 100 g (FDC item 173554).
- Thus the formula of 1 kg of powder holds 1.34 × 5240 = 7021.6 g of water. The powder holds 20 g of it.
- The mix water is 7.0016 kg for each kg of powder, and 1.33618 g for each kcal (
formulaMixWater). - The water mass converts to a volume at
WATER_DENSITY_MAX, 1 kg/L. Water above 4 °C is less dense, so the true volume is a little more. - The energy of each powder product comes from its food energy in the catalog. Two products can give powder. Then the converter takes the most water and the least energy of their lines.
The product page tells that the actual label varies with the retailer. A label of a different powder gives a different value. Give it as mix.label.
Without mix.label, the rule is a mass balance. It assumes that the prepared powder has the energy in 100 g of the ready-to-feed item 172319, 63 kcal. Then the mix water is 5240 / 630 − 1 = 7.3175 kg for each kg of powder, 4.5% more than the label rule.
formulaMixCheck gives an independent check of the rule with the cited water of the ready-to-feed item. The rule does not use that water.
| Rule | Powder in 100 g of prepared formula | Predicted water | The FDC item 172319 | | --- | --- | --- | --- | | The label rule | 12.4975 g | 87.7525 g | 88.1 g, 0.39% more | | The mass balance | 12.023 g | 88.218 g | 88.1 g, 0.13% less |
These facts give a no read, and then the powder has no converter:
| Missing fact | The no read | | --- | --- | | No food energy of the product, or an energy in a unit that does not convert to kcal | The energy and the water | | A product that gives more than one food | The energy and the water | | An energy of the powder that is not more than the 630 kcal/kg of the ready-to-feed item | The water |
Only bottled water
The mix takes only commercially bottled water, water.bottled (FORMULA_WATER). The rule comes from the WIC guide "Infant Nutrition and Feeding" of the USDA (WIC_INFANT_SOURCE, us-public-domain). The guide gives it from the CDC.
| Locator | The words of the source | | --- | --- | | Page 107, the box "Natural Disaster or Power Outage: Infant Formula Guidelines" | "Use ready-to-feed formula if possible." | | The same box | "Use bottled water to prepare powdered or liquid concentrated infant formula. If bottled water or ready-to-feed formulas are not available, discuss options with a health care provider." | | The same box | "Clean bottles and nipples with bottled, boiled, or treated water before each use." |
- The catalog of market gives bottled water its own resource,
water.bottled, since market 0.9.0. The jug of commercially bottled water gives it. The container filled from the tap giveswater.stored. RESOURCE_SUBSETSmakeswater.bottleda subset ofwater.stored.householdFragmentgives one converter for it: 1 L ofwater.bottledgives 1 L ofwater.stored, with no device and no limit.- Thus a drinking draw and a cook take the tap water and the bottled water, and the mix takes only the bottled water. Each litre goes to one draw only.
- The endurance query decides the share. A take of
water.storeduses the tap water first, then the bottled water through the converter. - The draws take in the order of their level, then of their codes. A drinking draw at a higher level keeps back its water first, so the powder can add 0 days.
- A household with only tap water and powder gets 0 days of formula from the powder.
bindingof the formula draw then nameswater.bottled. formulaMixFragmentgives the reason inwaterWhywhen the buy list has powder and no product that giveswater.bottled.bottlednames the products that give it.- The converter stays in that case, because a different fragment can give a store of bottled water.
- The guide tells to discuss the options with a health care provider when the household has no bottled water. The model does not model that step.
- The cleaning water of the bottles and the nipples is a no read (
FORMULA_WATER.cleaning). The source gives no amount, so the model has no draw for it.
The WIC guide tells to prepare powder one bottle at a time, for one feed. Thus the mix has no waste of an opened container. The rule of opened containers applies only to a product with the field opened.
The cited constant:
| Name | Value | Source |
| --- | --- | --- |
| FORMULA_MIX | 524 kcal and 2 g of water in 100 g of powder. 63 kcal and 88.1 g of water in 100 g of ready-to-feed formula. | FoodData Central, SR Legacy (April 2018, CC0 1.0): FDC ID 173554 (store brand, powder) and FDC ID 172319 (store brand, ready-to-feed), food_nutrient.csv. The water source is the WIC guide, page 106. |
| FORMULA_WATER | The mix water is water.bottled only. The cleaning water is a no read. | The WIC guide, page 107, the box "Natural Disaster or Power Outage: Infant Formula Guidelines", from the CDC. |
The uses, the supply parts and the join gate
The package holds one record of each use and of each default supply part. householdFragment takes its food use from DIRECT_USES.
| Name | What it has |
| --- | --- |
| NEED_SUPPLIES | The default reference part of each need: hydration.drink to water.main, and food.energy and food.infant-formula to food.retail. A household with a well gives a different part. |
| DIRECT_USES | water.stored gives hydration.drink, 1 L for each L. This is a definition, not a read. food.no-cook gives food.energy, and food.infant-formula-ready gives food.infant-formula, 1 kcal for each kcal. |
| RESOURCE_SUBSETS | water.bottled is a subset of water.stored. This is a definition, not a read. |
| subsetConverters | The converter of each subset whose resource has a store. One run gives the same amount of the wider resource, in its unit. |
| checkJoins | The join gate of a catalog, the direct uses and the supply parts with the reference lists. |
checkJoins(catalog, uses, supplies, { needs, parts }, subsets) gives one finding for each break. The default of subsets is RESOURCE_SUBSETS. An empty list is a pass. Each finding is an error.
A finding has the form of a finding of @mark1russell7/guidebook, the same form as the findings of checkCalorieTable. Its record is use, supply or subset. The id of a use or a subset finding is its resource. The id of a supply finding is the need.
| Code | Record | The break |
| --- | --- | --- |
| join-use-resource | use | A direct use names a resource that is not in the catalog. |
| join-use-need | use | A direct use names a need that is not a reference need. |
| join-use-unit | use | The unit of the resource of a direct use does not convert to the unit of its need. |
| join-use-amount | use | The amount of a direct use is not the factor from the unit of its resource to the unit of its need. |
| join-supply-need | supply | A supply names a need that is not a reference need. |
| join-supply-part | supply | A supply names a part that is not a reference part. |
| join-subset-resource | subset | A subset names a resource that is not in the catalog. |
| join-subset-same | subset | A subset names one resource two times. |
| join-subset-unit | subset | The unit of the resource of a subset does not convert to the unit of the wider resource. |
A direct use is a definition. Thus its amount is the factor of the units, from valueIn of @mark1russell7/quantity. For example, a use in gal for a need in L gives 3.785411784 L for each gal. A different rate is a converter, and a converter has a cited source.
The reference lists are parameters. An add-on does not import a different add-on, thus the caller gives them. Give NEEDS of @mark1russell7/alerts and SUPPLY_PARTS of @mark1russell7/stack-hazards. A test of the package joins these real lists. It also checks that food.energy is a need of NEEDS in kcal.
import { NEEDS } from "@mark1russell7/alerts";
import { SUPPLY_CATALOG } from "@mark1russell7/market/supplies";
import { SUPPLY_PARTS } from "@mark1russell7/stack-hazards";
import { checkJoins, DIRECT_USES, NEED_SUPPLIES } from "@mark1russell7/stack-needs";
console.log(checkJoins(SUPPLY_CATALOG, DIRECT_USES, NEED_SUPPLIES, { needs: NEEDS, parts: SUPPLY_PARTS })); // []The gate does not examine the FoodKeeper id of each product. That join goes to the gate of the catalog of @mark1russell7/market.
The sources
The calorie table comes from Appendix 2 of the Dietary Guidelines for Americans, 2020-2025, 9th Edition (USDA and HHS). Table A2-1 gives the ages of 12 through 23 months, on page 139. Table A2-2 gives the ages of 2 and more, on pages 140 and 141. The table has 68 rows: 34 for each sex. Table A2-3, on page 141, gives the changes of pregnancy and lactation. They are 0, 340 and 452 kcal/d in the three trimesters. They are 330 and 400 kcal/d in the first and the second 6 months of lactation.
The guidelines are a work of the United States federal government, in the public domain (the license us-public-domain of guidebook). The record of the source has the SHA-256 hash of the PDF of the check of 2026-11-22.
- A calorie of the source is a food calorie, thus 1 kcal.
- Table A2-1 gives one need for each age and sex of a toddler. The level does not change it.
- Each row of a toddler covers the months up to the next row. The table has no row below 12 months.
- The source gives each need for a reference height and weight. A person can need more or less.
- The source gives the changes of Table A2-3 for women with a healthy weight before the pregnancy. Each change has this condition in its field
condition.
The infant table comes from the report Dietary Reference Intakes for Energy (2023) of the National Academies of Sciences, Engineering, and Medicine (DOI 10.17226/26818). Table 7-5 gives the boys of 0 to 35 months, on page 160. Table 7-6 gives the girls of 0 to 35 months, on page 161. The table has 24 rows: one row for each group of 3 months and each sex.
The report gives each need for the median length and weight of the age group in the United States.
The report is all rights reserved (the license all-rights-reserved of guidebook). The table cites its values as facts and copies no text, and the gate of the sources permits this use. The record of the source has the SHA-256 hash of the PDF of the check of 2026-11-24. The Infant Nutrition and Feeding guide of the WIC program of the USDA gives no table of daily needs (read on 2026-11-24).
- The rows of 12 to 35 months are also in the table. In
CALORIE_CHAIN, the guidelines come first, so they give the need of those ages. - A table with the report first gives the needs of the report up to 35 months.
The 2025-2030 edition of the guidelines was read on 2026-11-24. It has no table of calorie needs. It sends the reader to the DRI calculator of the USDA, and its daily servings start from a calorie level. Thus the table stays the table of the 2020-2025 edition.
The daily needs of the kit
DAILY_NEEDS gives the needs of the kit items: light, the watch of an alert receiver and warmth. Each need has a cited daily rate, or a no read with its reason. A no read is not 0, and the list keeps it.
| Code | Unit | Users | Daily rate |
| --- | --- | --- | --- |
| alert.watch | h | household | 24 h/d |
| light.see | h | household | no read |
| warmth.shelter | kWh | household | no read |
alert.watchcomes from two pages of the National Weather Service (read on 2026-11-24). Many receivers have a muted standby mode that turns on when a warning comes. Warnings also come at night. Thus a receiver stays on and listens at all hours, so 24 hours each day. One receiver for each home is a choice of this model, not of the pages. The pages are in the public domain (the licenseus-public-domain).light.seeis a no read. The kit lists of Ready.gov give a flashlight and extra batteries, but no hours of use each day. The hours of dark are the same for all the persons of a home, so the users are the household. The count of lights of each person is a fact of the plan or the device.lightNeedgives a read from the point of the home and its awake window.warmth.shelteris a no read. The heat that a home needs changes with the weather, the building and the persons. It is space heat only. The blankets and the sleeping bags of each person are gear, not this need.warmthNeedgives a read from the facts of the building and the temperatures.- A user gives each no read as input data.
- The rate of a device is a fact of the device, not of the need. An example is the watts of a radio in standby.
checkDailyNeeds is the gate of the list. It gives the findings of checkSources of @mark1russell7/guidebook. Each source must have a publisher (by), a page of its terms and HTTPS addresses. resultOf of guidebook tells if the gate passes.
The gate refuses an empty code and two needs with one code (daily-need-id). It refuses a unit that @mark1russell7/quantity does not read (daily-need-unit). It also refuses a bad read or a no read with no reason (daily-need-rate). A bad read has no source. Or its amount is not a finite number of 0 or more in the unit of the need for each day.
The devices of the kit
deviceFragment gives the devices of a buy list that run on cells, as converters of an endurance layer. Examples are a radio and a flashlight.
- Each device of the catalog of market with a cited run time gives one converter. The field
deviceof a product gives its need, its cells and its run time. - One run takes one cell, and gives the hours of the need for each cell. For example, 48 h on 3 cells gives 16 h for each cell.
- One device gives its need for 24 hours in a day or less. Thus the limit
perDayisHOURS_IN_DAYdivided by the hours for each cell. The count of devices is the count of whole units. - The input
runsgives the run time of a device of the caller, with its citation. It replaces the run time of the catalog. - A device with no run time gives no converter, and a no read. The radio and the flashlight of the catalog are no one model, so their run time is a no read.
- With the input
draws, each need of a device gives one draw at the daily rate of the need. A need with no read of its rate gives no draw, and a no read. - The fragment has no store. The cells come from the stores of the buy list, for example the product
power.aa-alkalineof the catalog.
The hours of light
lightHours gives the dark hours of the awake window of a household on each date of a plan. lightNeed changes them into a read of the need light.see.
- The input is the point of the home, the awake window in local time, the first date and the count of days. The point and the window are input data of the household.
- The light is the time from the sunrise to the sunset of
sunDayof@mark1russell7/geo. A polar day is light, and a polar night is dark. - The awake window is a
TimeWindowof@mark1russell7/algebra/clock. It follows the wall clock, also at a change of the clock. - A local date is the time from its local midnight to the next local midnight. A window across midnight gives its hours to each date by the clock.
- The result gives each day, the most of the worst day and the mean.
- The rate of
lightNeedis the most. One light that is on in those hours is a choice of this model, not of the sources. - The sources are the pages "Position of the Sun" and "Sunrise equation" of Wikipedia (license
cc-by-sa-4.0). The code uses their formulas, not their text.
The read goes into deviceFragment through the input needs. Then the need of light gets a draw.
The heat of a home
warmthHeat gives the space heat that a home needs on each day of a plan. warmthNeed changes it into a read of the need warmth.shelter.
- The heat loss coefficient of the home is in watts for each kelvin.
heatLossOfsums the area times the U-value of each element of the envelope. heatLossFromUsegives the same coefficient from the heat of a past period, divided by its degree days times 24 hours. The heat is the energy of the heaters, not the fuel.- The heat flow of a day is the coefficient times the indoor temperature minus the outdoor temperature, minus the gains of the persons. A flow of 0 or less needs no heat.
- The indoor target, the outdoor temperature of each day and the facts of the building are input data of the household. The package has no default target.
- The rate of
warmthNeedis the heat of the worst day, inkWh/d. - The sources are the pages "Thermal transmittance" and "Degree day" of Wikipedia (license
cc-by-sa-4.0).
The heat of a stored fuel
Since 0.10.16, heatStoveFragment gives the space heat of a home from a stored fuel, as converters of an endurance layer. A wood stove, a propane heater and a kerosene heater each change 1 unit of fuel into the need warmth.shelter, in kWh. The draw of that need comes from warmthNeed.
import { heatStoveFragment, warmthHeat, warmthNeed } from "@mark1russell7/stack-needs";
const heat = heatStoveFragment({
// Made-up amounts: 1 cord of wood for a catalytic stove, and 10 gal of kerosene for a heater with a label efficiency of 0.9.
wood: { cords: 1, rating: "catalytic" },
kerosene: { gallons: 10, efficiency: { value: 0.9, cite: "example.label" } },
});
// heat.layer has the stores heat:wood and heat:kerosene and the converters heat:wood and heat:kerosene.
// heat.lines has the cited use rules of each heater.
const january = warmthNeed(warmthHeat({ heatLossWK: 100, indoorC: 18, outdoorC: [-2] }));
// One draw of the need of each month gives the heat days of that month.The converters:
| Heater | One run takes | One run gives |
| --- | --- | --- |
| wood | 1 cord of wood (fuel.wood, unit {cord}) | WOOD_HEAT_CONTENT times the efficiency, in kWh |
| propane | 1 gal of liquid propane (fuel.propane-liquid), or 1 unit of the propane resource of the catalog of market in a mass | PROPANE_HEAT_CONTENT or the cited fuel energy of the catalog, times the efficiency |
| kerosene | 1 gal of kerosene (fuel.kerosene) | KEROSENE_HEAT_CONTENT times the efficiency |
- The efficiency of a wood stove is the low end of the range of its class in
WOOD_STOVE_EFFICIENCIES. A lower efficiency gives more fuel, so this is the safe side. A cited efficiency of the caller replaces it. - Since 0.11.0, an unvented propane or kerosene heater gets
UNVENTED_HEATER_EFFICIENCY, 1. The DOE test of an unvented heater sets its output equal to its fuel input. - A vented propane heater gets the least efficiency of its row of
VENTED_HEATER_MINIMUMS, from the inputventedRating(class and fuel input inBtu/h). Without a rating, it gets the lowest row, 57%. - The federal table applies to a heater made on or after April 16, 2013. For an older heater, give the efficiency from its label.
- No federal standard that we read gives a least efficiency for a vented kerosene heater. Thus the caller gives the efficiency from the label, with its citation. Without it, the heater is a no read.
- A cited efficiency of the caller replaces each default. The field
efficiencySourceof a line names the source of a default. - Propane in
lbtakes the propane resource of the catalog (defaultfuel.propane) and its cited fuel energy. Then a cook converter can share the store. - A cited rate of a heater, in its fuel for each hour, gives the limit
perDayof its converter: the rate times 24 hours. - The days of each month come from a draw at the rate of that month.
The cited use rules:
- Each line of
lineshas the cited rules of its heater. The rules are data for the caller. They do not change a value. - Each fuel heater gets
CO_ALARM_RULEandFUEL_INSPECTION_RULE. - An unvented heater also gets
UNVENTED_SLEEP_RULE. A propane or a kerosene heater is unvented, but with the inputvented. A wood stove is vented. - A kerosene heater also gets
KEROSENE_GRADE_RULE.
The gate of the fragment:
- With no fuel, no converter has an input, so the days do not change.
- When a fuel is used up first, the field
bindingofenduranceOfnames its resource. A heater with fuel left and a rate that stops the draw is incapped.
The cited constants:
| Name | Value | Source |
| --- | --- | --- |
| WOOD_HEAT_CONTENT | 20,000,000 Btu for each cord | The EIA page British thermal units (Btu): "Wood, 1 cord=20,000,000 Btu", a sample factor. |
| PROPANE_HEAT_CONTENT | 91,333 Btu for each gallon | The DOE notice 89 FR 83672 of October 17, 2024, footnote 8. The EIA page gives 91,452 Btu. The model takes the lower value, because it gives more fuel. |
| KEROSENE_HEAT_CONTENT | 135,000 Btu for each gallon | The DOE notice, footnote 9. The ratio of the carbon factors of kerosene of EIA gives 134,986 Btu. |
| WOOD_STOVE_EFFICIENCIES | Catalytic 63% to 84%, mean 78%. Non-catalytic 60% to 80%, mean 71%. | The EPA page Frequent Questions about Wood-Burning Appliances. The catalytic range is at the higher heating value. The page does not tell the basis of the other range. |
| UNVENTED_HEATER_EFFICIENCY | 1 | 10 CFR Part 430, Subpart B, Appendix G, section 3.4: the rated output of an unvented gas, propane or oil heater equals its fuel input. Section 1.4.4 tests the oil heater with kerosene. |
| VENTED_HEATER_MINIMUMS | Gas wall fan 75% to 76%, wall gravity 65% to 67%, floor 57% to 58%, room 61% to 68%, by fuel input | 10 CFR 430.32(i)(2), for a heater made on or after April 16, 2013. Appendix O, section 2.3.2, tests a vented heater with propane. |
| CO_ALARM_RULE | A rule | The CPSC page Carbon Monoxide Questions and Answers: a battery alarm on each level and outside the sleeping areas. |
| UNVENTED_SLEEP_RULE | A rule | The same CPSC page: no unvented fuel appliance in a room where persons sleep. |
| FUEL_INSPECTION_RULE | A rule | The EPA page of wood appliances gives the CPSC rule of an inspection each year. |
| KEROSENE_GRADE_RULE | A rule | The CPSC page Portable Heaters & Camping Equipment: only water-clear 1-K kerosene, and no gasoline. |
The EIA, DOE, EPA and CPSC pages and the eCFR text of 10 CFR Part 430 are works of the United States federal government (the license us-public-domain of guidebook). The EIA terms tell that its publications are in the public domain, but its photographs can have a copyright. The model takes only facts and short rules, with a citation. The DOE notice comes from govinfo.gov.
The power of a solar panel
solarConverter gives the power of a fixed panel as a source converter of an endurance layer (since 0.10.12). It needs @mark1russell7/stack-endurance 0.8.20 or later.
- The input is the peak power in W and the mean irradiation of one day of each month on the plane of the panel. It also has the performance ratio.
dailyIrradiationgives the 12 daily values from the monthly rows of some years, for example the rows ofgeo.solarAtPointof@procedures/geo. It divides each row by the days of its month.- The energy of one day is the peak power times the irradiation times the ratio. One run of the converter is 1 Wh of the need
power.electric(POWER_NEED). - The limit
perDayis the energy of the best month. The sharesmonthlygive each month as a part of it. - The ratio is one value or 12 values. One value misses the heat loss of each month. At the sample point of PVGIS, the worst month is wrong by approximately 8 %.
pvcalcRatiosgives the 12 ratios from the answer of PVcalc of PVGIS (since 0.10.14). The ratio of a month isE_dof PVcalc divided by the daily irradiation on the same plane. It includes the heat loss of each month at the place. Ask PVcalc withpeakpower=1, the plane of the panel and the losses of the system. A gate holds each month of the sample within 3 % of PVcalc.- A battery is a store with no charge from the panel. This is the safe side. A battery with a capacity and a charge is the item M2-solar-charge.
