Food in ScienceSuit is assumed to be composed of macronutrients, ash and salt:
In order to create a variable of type Food, we run the following command:
>>myfood=Food.new{Water=30, CHO=70}
>> myfood
Weight (unit weight)=1.00
Temperature (C)=20.00
Water (%)=30.00
CHO (%)=70.00
Aw=0.751
pH=6.00
This command creates a food material and assigns it to variable myfood. The keys for Lua table are water, CHO, protein, lipid or oil or fat, ash and salt and are case-insensitive. The variable myfood has the following properties: Its temperature is 20 °C and pH is 6 by default (unless changed, it remains as 6.0). Its weight is 1 unit and 30% of it is water and 70% is carbohydrate (please note that if the total percentage in the above command-line was not 100, it would have been adjusted to 100).
Please note that in the following example, although the sum of percentages in myfood2 is not equal to 100%, it will be automatically adjusted to 100% and therefore the percentages of water and carbohydrate in myfood and myfood2 are same.
>>myfood2=Food.new{Water=15, CHO=35
>>myfood2
Weight (unit weight)=1.00
Temperature (C)=20.00
Water (%)=30.00
CHO (%)=70.00
Aw=0.751
pH=6.00
Food data structure supports some arithmetic operations: Let f_{1}, f_{2} and f_{3} denote Food and a and b an arbitrary numbers.
A) Addition: Addition operation can be considered as the unit operation of mixing of food materials. The data structure allows mixing of different food materials at different temperatures. Mass and energy balances are performed automatically.
Following equation is used for energy balance:
$${m}_{\mathit{total}}\cdot {\mathit{Cp}}_{\mathit{mix}}\cdot {T}_{\mathit{mix}}={m}_{1}\cdot {\mathit{Cp}}_{1}\cdot {T}_{1}+{m}_{2}\cdot {\mathit{Cp}}_{2}\cdot {T}_{2}$$
Here one can quickly notice that Cp_{mix} and T_{mix} are unknown and furthermore Cp_{mix}=f(T_{mix}). Knowing that specific heat capacity of foods hardly changes within a specific temperature range (a phase change is not considered), the following equation was used:
$${\mathit{Cp}}_{\mathit{mix}}={\mathit{Cp}}_{\mathit{average}}=\frac{{\mathit{Cp}}_{1}+{\mathit{Cp}}_{2}}{2.0}$$
Let's create two food materials:
>> f1=Food.new{Water=30, CHO=70}
>>f2=Food.new{oil=40, protein=60}
Say, we would like to mix equal proportions of f_{1} and f_{2}:
>>f3 = f1 + f2
>>f3
Weight (unit weight)=2.00
Temperature (C)=20.00
Water (%)=15.00
Protein (%)=30.00
CHO (%)=35.00
Lipid (%)=20.00
Aw=0.334
pH=6.00
Here, the addition operation yielded a new food material and as expected the new food material f_{3} is composed of water, protein, carbohydrate and lipid. Its weight is 2 units (please see member function normalize() and its temperature is 20°C.
Instead of equal proportions, say we want to mix 20% f_{1} and 80% f_{2}:
>>f4 = 0.2*f1 + 0.8*f2
>>f4
Weight (unit weight)=1.00
Temperature (C)=20.00
Water (%)=6.00
Protein (%)=48.00
CHO (%)=14.00
Lipid (%)=32.00
Aw=0.085
pH=6.00
It should be noticed that although f_{1} and f_{2} are mixed, we have named the variable as f_{4} instead of f_{3}. This is due to the fact that two food materials are considered to be equivalent if they contain the same amount of each macro-components.
B) Subtraction: Subtraction can be considered as the unit operation evaporation or extraction. Therefore, it is only allowed to subtract f_{2} from f_{1}, if and only if, f_{2} is at the same temperature with f_{1} and contains exactly the same, but to a lesser amount of, macro-components.
In the following example our goal is to make a powder out of milk. We know that we need to remove water from the milk to achieve this goal. Therefore, we create two food materials, namely milk and water.
>>milk=Food.new{water=88.13, protein=3.15, CHO=4.80, lipid=3.25, ash=0.67}
>>water=Food.new{water=100}
>>powder=milk-0.87*water
>>powder
Weight (unit weight)=0.13
Temperature (C)=20.00
Water (%)=8.69
Protein (%)=24.23
CHO (%)=36.92
Lipid (%)=25.00
Ash (%)=5.15
Aw=0.192
pH=6.00
A few things should be noted here:
C) Multiplication: Unlike addition or subtraction, which yielded new food materials, multiplication does not yield a new food material. It only changes the weight of the food material. This is necessary to be able to perform addition or subtraction operations:
Taking the previous example:
>>f4 = 0.2*f1 + 0.8*f2
To be able to perform this addition, behind the scenes Lua first creates a temporary food material from 0.2*f1, say temp1, and then another temporary food material from 0.8*f2, say temp2. f_{4} is actually f_{4}=temp_{1}+temp_{2}.
Calculates the water activity of the food material. Argument arg can be either a nil value, a valid number or a function which returns a valid number. Solute is defined as: Solute=CHO+lipid+protein+ash+salt.
The following assumptions were made:
For non-electrolyte solutions (% salt <0.00001):
For both MoneyBorn and Norrish equation, the amount of fructose was considered as the amount of CHO. For Norrish equation amounts of glycerol and alanine were considered to be equal to amounts of lipid and protein, respectively.
If the argument arg is provided as an acceptable valid number, then the above-mentioned calculations are skipped and the provided value is used thereafter:
>>milk=Food.new{water=88.13, protein=3.15, CHO=4.80, lipid=3.25, ash=0.67}
>>milk
Aw=0.920 --value computed using above-mentioned assumptions
>>milk:aw(0.95) --explicitly setting the value
>>milk
Aw=0.950
>>milk:aw() --calling the water activity returns the set value
0.95
If a different function is better suited to compute the water activity of a specific food material, then the argument arg must be of type function. When such a function is provided, ScienceSuit uses the provided function to calculate the water activity. The provided function must be in the following format:
function ComputeAw (myfood)
Here, the function name ComputeAw is arbitrarily chosen for the example. The argument, myfood, whose name is also arbitrarily chosen, is the food material that calls the member function, to calculate aw. Therefore, ComputeAw has access to all of the properties of the calling food material.
Let's first define a rather simple function which will compute the water activity:
function ComputeAw(myfood)
if(myfood:get().water>85) then
return 0.95
end
end
Let's define a food variable, namely milk, and use the above function to calculate water activity:
>>milk=Food.new{water=88.13, protein=3.15, CHO=4.80, lipid=3.25, ash=0.67}
>>milk:aw() --returns the value computed using system's assumptions
0.92
>>milk:aw(ComputeAw) --explicitly setting the value using ComputeAw function
>>milk:aw() --calling the water activity returns the value set by ComputeAw function
0.95
Returns the specific heat capacity (kJ/kgK) of the food material. The following predictive equation is used to calculate specific heat capacity:
If a different function or value is better suited to compute the specific heat capacity of a specific food material, then the argument arg needs to be provided (see member function aw() for more info).
Returns a Lua table containing the macronutrients, ash and salt.
>>milk=Food.new{water=88.13, protein=3.15, CHO=4.80, lipid=3.25, ash=0.67}
>>tbl=milk:get()
>>type(tbl)
table
If argument arg is not provided then returns the thermal conductivity (W/mK) of the food material. The following predictive equations is used to calculate thermal conductivity:
If a different function or value is better suited to compute the thermal conductivity of a specific food material, then the argument arg needs to be provided (see member function aw() for more info).
Only sets the weight to 1.0. However, this is a rather important function as the food material that is a result of an addition or a subtraction operation can have a weight different than 1.0 as shown in the following example:
>>milk=Food.new{water=88.13, protein=3.15, CHO=4.80, lipid=3.25, ash=0.67}
>>water=Food.new{water=100}
>>powder=milk-0.87*water
>>powder
Weight (unit weight)=0.13
If you were to use the variable powder as is in another mathematical operation, its weight would be considered as 0.13 units. As an example, in a mixing operation where you, say, mix milk and powder: Mathematically we would express the mixing operation as an addition and it might be expected that the variable mymix has a weight of 2.0 units. However, its weight is equal to 1.13 units, since powder is a mathematical result of an addition operation. To be able to use it conceptually as an independent food material, it needs to be normalized, prior to any mathematical operation.
By default the pH is 6.0 and no predictive equations are currently provided to calculate otherwise.
If argument arg is provided as a number in the range of (0-14) then sets the pH value of the food material. If arg is not provided the function returns the pH value.
If a different function or value is better suited to compute the pH of a specific food material, then the argument arg needs to be provided (see member function aw() for more info).
If argument func is not provided then returns the density (kg/m^{3}) of the food material. The following predictive equations are used to calculate density:
If
a different value or a function is better suited to compute the density of a
specific food material, then the argument arg needs to be provided (see
member function aw() for more info).
If argument num is provided as a number then the function sets the temperature value of the food material. If num is not provided the function returns the temperature of the food material.