Food Class

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

Mathematical Operations

Food data structure supports some arithmetic operations: Let f1, f2 and f3 denote Food and a and b an arbitrary numbers.

  1. Addition: f1+f2=f3     a*f1+b*f2=f3
  2. Subtraction: f1-f2=f3
  3. Multiplication: a*f1 =b*f1 = f1*a = f1

 

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 total Cp mix T mix = m 1 Cp 1 T 1 + m 2 Cp 2 T 2 m sub total cdot Cp sub mix cdot T sub mix=m sub 1 cdot Cp sub 1 cdot T sub 1 +m sub 2 cdot Cp sub 2 cdot T sub 2

 

Here one can quickly notice that Cpmix and Tmix are unknown and furthermore Cpmix=f(Tmix). 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:

Cp mix = Cp average = Cp 1 + Cp 2 2.0 Cp sub mix=Cp sub average={ Cp sub 1+ Cp sub 2 } over 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 f1 and f2:

>>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 f3 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% f1 and 80% f2:

>>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 f1 and f2 are mixed, we have named the variable as f4 instead of f3. 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 f2 from f1, if and only if, f2 is at the same temperature with f1 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:

  1. We obtain a new food material, namely powder, of weight 0.13 units since we have subtracted 0.87 units of water from 1 unit of milk. If you were to use the variable powder as is, its weight will be 0.13 units in any operation, therefore, please see the member function normalize to prevent pitfalls.
  2. Had we run a command such as powder=milk - water, it would not have been successful as 1 unit of milk does not have 1 unit of water.
  3. The obtained food material, namely powder, has higher percentage of lipid, protein, CHO and ash but a lower percentage of water, as expected.

 

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. f4 is actually f4=temp1+temp2.

 

 

Member Functions

 

aw(arg):

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:

  1. %Water < 0.00001 → aw=0.01
  2. %Solute <1 → aw=0.99

For non-electrolyte solutions (% salt <0.00001):

  1. %water >99.0 → aw=0.98
  2. %CHO>98 and all others <1% → aw=0.70
  3. % water (1,5) & %CHO>5 → aw=MoneyBorn equation
  4. %water >5 & %CHO>5 → aw=Norrish equation

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

 

 

cp(arg):

Returns the specific heat capacity (kJ/kgK) of the food material. The following predictive equation is used to calculate specific heat capacity:

water = 4.1289 9.0864 10 5 T + 5.4731 10 6 T 2 protein = 2.0082 + 1.2089 10 3 T 1.3129 10 6 T 2 lipid = 1.9842 + 1.4733 10 3 T 4.8008 10 6 T 2 CHO = 1.5488 + 1.9625 10 3 T 5.9399 10 6 T 2 ash = 1.0926 + 1.8896 10 3 T 3.6817 10 6 T 2 salt = 0.88

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).


get():

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

 

 

k(arg):

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:

water = 0.457109 + 1.7625 10 3 T 6.7036 10 6 T 2 protein = 0.17881 + 1.1958 10 3 T 2.7178 10 6 T 2 lipid = 0.18071 2.7604 10 4 T 1.7749 10 7 T 2 CHO = 0.20141 + 1.3874 10 3 T 4.3312 10 6 T 2 ash = 0.32962 + 1.4011 10 3 T 2.9069 10 6 T 2 salt = 0.574

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).

 

 

normalize():

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.

 

ph(arg):

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).

 

 

rho(arg):

If argument func is not provided then returns the density (kg/m3) of the food material. The following predictive equations are used to calculate density:

water = 997.18 + 3.1439 10 3 T 3.7574 10 3 T 2 protein = 1329.9 5.1840 10 1 T lipid = 925.59 4.1757 10 1 T CHO = 1599.1 3.1046 10 1 T ash = 2423.8 2.8063 10 1 T salt = 2165

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).

 

 

T(num):

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.