forked from jvail/dairy.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
requirements.py
1169 lines (1032 loc) · 53.2 KB
/
requirements.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Energy and protein requirements according to a selection of evaluation systems (DE, FI, GB, FR).
#
# REFERENCES
#
# AFRC (Agricultural Food and Research Council). 1993. Energy and protein requirements of ruminants. An advisory
# manual prepared by the AFRC Technical Committee on Responses to Nutrients. CAB International, Wallingford, UK.
#
# Agabriel, J. 2010. Alimentation des bovins, ovins et caprins. Besoins des animaux - Valeurs des aliments. Tables INRA
# 2010. Editions Quae, France.
#
# Dong, L.F., Yan, T., Ferris, C.P. and McDowell, D.A. 2014. Comparison of energy utilisation and energetic efficiency
# of dairy cows under different input systems. In: Proceedings of the 65th Conference of European Association of
# Animal Production. p. 395, Copenhagen, Denmark.
#
# Feed into Milk Consortium. 2004. Feed into Milk. A new applied feeding system for dairy cows. An advisory manual.
# Ed. Thomas, C. Nottingham University Press, UK.
#
# GfE [Society of Nutrition Physiology] 2001. Empfehlungen zur Energie- und Nährstoffversorgung der Milchkühe und
# Aufzuchtrinder [Recommendations on the energy and nutrient supply for dairy cows and heifers]. DLG-Verlag, Frankfurt/
# Main, Germany.
#
# Jarrige, R. 1989. Ruminant nutrition: recommended allowances and feed tables. John Libbey Eurotext, France.
#
# MTT. 2006. Rehutaulukot ja ruokintasuositukset [Feed tables and feeding recommendations]. Agrifood Research Finland,
# Jokioninen, Finland.
#
# MTT 2014. Rehutaulukot ja ruokintasuositukset [Feed tables and feeding recommendations] [online]. Agrifood
# Research Finland, Jokioinen. Accessed last on November 20, 2014, available at:
# https://portal.mtt.fi/portal/page/portal/Rehutaulukot/feed_tables_english
#
# NRC (National Research Council). 2001. Nutrient requirements of dairy cattle. 7th edition. National Academy Press,
# Washington, D.C. USA.
#
# Sjaunja, L.-O., Baevre, L., Junkarinen, L., Pedersen, J. and Setala, J. 1990. A Nordic proposal for an energy corrected
# milk (ECM) formula. In: in Proceedings of the 27th Biennial Session of the International Committee for Animal Recording.
# Paris, France. p. 156-157.
#
# Tyrrell, H.F. and Reid, J.T. 1965. Prediction of the energy value of cow's milk. Journal of Dairy Science 48(9):
# 1215-1223.
#
# LICENSE
#
# Copyright 2014 Jan Vaillant <[email protected]>
# Copyright 2014 Lisa Baldinger <[email protected]>
#
# Distributed under the MIT License. See accompanying file LICENSE or copy at http://opensource.org/licenses/MIT
#
# Any publication for which this file or a derived work is used must include an a reference to:
#
# Vaillant, J. and Baldinger, L. 2016.
# Application note: An open-source JavaScript library to simulate dairy cows and young stock,
# their growth, requirements and diets.
# Computers and Electronics in Agriculture, Volume 120, January 2016, Pages 7–9
import math
log = math.log
LN10 = math.log(10)
exp = math.exp
pow = math.pow
log10 = math.log10
WEEKS_IN_MONTH = 30.5 / 7
WEEKS_GESTATION_PERIOD = 40
def requirements(DMI, f, p, WG, DIM, BW, BWC, milk, fat, protein, d, d_v, ME_total, ME_ferm, diet_fat, type, WL, WB):
# NRC (2001) p. 18 ff, AFRC (1993) p. 159
#
# Adjustment of maintenance requirements for energy needed for grazing activity:
#
# In comparison to cows housed indoors, cows that are grazing have a higher energy requirement for maintenance. The
# increase is a function of the distance walked, the topography of the pasture, and the body weight of the cow.
# Of the feed evaluation systems of Germany, France, UK and Finland, both the French and the British system offer a
# simple activity-related addition to the energy requirements for maintenance. Because SOLID-DSS will deal with a lot
# of grazing cows, the more detailed energy addition for grazing offered by the NRC was chosen.
#
# Energy requirement for maintenance when grazing =
# Basic maintenance requirement
# + extra requirement for walking
# + extra requirement for grazing
# + extra requirement for hilly pastures
#
# Regarding the extra requirement for hilly pastures, we chose to use the original version by AFRC (1993) that NRC is
# quoting on page 21, because it can cover differing slopes.
#
# NRC (2001) expresses the basic maintenance requirements of dairy heifers in Mcal NEM, but the extra requirements are
# calculated using the same equations as for the dairy cows, which are expressed in Mcal NEL. Because the NRC (2001)
# assumes that NEL and NEM are equivalent (in this case), both the basic maintenance requirements and all additions will
# be calculated as described by the NRC, and then the sum of all additions will be expressed in % of the basic
# requirement. So the output of this calculation is the addition in %, which is then used in the national requirements
# to upscale the energy requirements for maintenance accordingly.
#
# activity [ME ME-1] additional maintenance requirements as fraction of total requirements
# BW [kg] body weight
# f [kg kg-1] fraction pasture in diet
# d [km] distance between barn and pasture
# d_v [m] vertical distance between barn and pasture or on pasture
# */
#
def activity(BW, f, d, d_v):
SBW = BW * 0.96 # shrunk body weight (equation taken from NRC (2001) p. 234) */
maintenance = 0.08 * pow(SBW, 0.75)
walking = 0.00045 * BW * d
grazing = 0.002 * BW * f
hilly = 0.00003 * BW * d_v * 4
return (walking + grazing + hilly) / maintenance
# GfE (2001)
#
# Nutrient requirements of dairy cows and young stock according to GfE.
#
# cows
#
# Energy is expressed in MJ NEL (net energy lactation) and protein is expressed in uCP (utilizable crude protein at the
# duodenum, the German abbreviation is nXP).
#
# Because DMI is predicted according to GrazeIn, the unit of IC (intake capacity) is UEL. For calculating the German
# protein requirements, IC is used as if it was expressed in kg, which means that an average fill value of 1 is assumed.
#
# young stock
#
# Energy is expressed in MJ ME (metabolizable energy) and protein is expressed in g uCP (utilizable crude protein at the
# duodenum, the German abbreviation is nXP).
#
# Because DMI is predicted according to GrazeIn, the unit of IC (intake capacity) is UEB. For calculating the German
# protein requirements, IC is used as if it was expressed in kg, which means that an average fill value of 1 is assumed.
# */
#
def GermanSystem(DMI, f, p, WG, DIM, BW, BWC, milk, fat, protein, d, d_v):
# maintenance [{NEL or ME, uCP}] Adjusted for share of forages in diet (by AFBI) if p > 0
# BW [kg] Body weight
# DMI [kg] Dry matter intake (if unknow assume IC ~ DMI @ FV = 1)
# f [kg (DM) kg-1 (DM)] Share of forage in diet
# p [#] parity
def maintenance(BW, DMI, f, p):
if (p > 0): # cows
# Dong et. al. (2014)
#
# The equation for the energy requirements for maintenance was formulated using a regression method (feeding at
# different energy levels and extrapolating to an energy balance of zero). (eq. 1.4.1)
#
# Energy requirements for maintenance are adjusted to forage proportion based on results from SOLID Task 3.3,
# conducted by AFBI:
#
# AFBI derived estimates of energy utilization by dairy cows on high forage diets. Using a database of calorimetric
# chamber experiments, the effects of total energy intake and diet quality forage proportion and contents of energy,
# protein and fibre on the energy requirements for maintenance and on the efficiency of using energy for maintenance
# and lactation were evaluated.
#
# The energy requirement for maintenance was found to be influenced by forage proportion:
#
# forage proportion < 30% --> ME_m, MJ british = 0.65 * LW^0.75 k_l = 0.62
# forage proportion 30%-99% --> ME_m, MJ british = 0.68 * LW^0.75 k_l = 0.62
# forage proportion = 100% --> ME_m, MJ british = 0.74 * LW^0.75 k_l = 0.62
#
# No influence of forage proportion on the efficiency of using energy for milk production (k_l) was found.
#
# Within an energy evaluation system, energy evaluation and energy requirements form a unit, and energy requirements
# are a unit of maintenance requirements and k_l:
# energy system = energy evaluation + maintenance requirement + k_l
#
# Therefore the AFBI-results cannot be ABSOLUTELY incorporated in a system of energy evaluation and requirement
# different from the British system, and the incorporation will be in RELATIVE terms.
#
# The equation for protein requirements for maintenance (equations 2.1.1, 2.1.2, 2.1.3, 2.1.5) summarizes the
# endogenous N losses via urine (5.9206 * log10 BW - 6.76), feces (2.19 * DMI) and skin (0.018 * BW^0.75),
# transforms that into protein (*6.25) and then multiplies with 2.1 to get the uCP requirement. (Assuming an
# efficiency of using absorbed amino acid N of 75%, an absorbability of amino acid N of 85% and a proportion of
# amino acid N of non-ammonia-N in chyme of 73%.)
NEL = 0.293 * pow(BW, 0.75)
uCP = ((5.9206 * log10(BW) - 6.76) + (2.19 * DMI) + (0.018 * pow(BW, 0.75))) * 6.25 * 2.1
if (f):
if (f < 0.3):
NEL = 0.280 * pow(BW, 0.75)
elif (f >= 0.3 and f <= 0.99):
NEL = 0.293 * pow(BW, 0.75)
else:
NEL = 0.319 * pow(BW, 0.75)
return {
"E": NEL,
"P": uCP
}
else:
# Equation for energy requirement for maintenance taken from GfE (2001) p. 27, chapter 1.5.1
#
# The protein requirement for maintenance is calculated with the same equations as for the dairy cows. The only
# difference is that the efficiency of using absorbed amino acid N is 70% for heifers instead of 75% for dairy cows.
# The equation (equations 2.1.1, 2.1.2, 2.1.3, 2.1.5) summarizes the endogenous N losses via urine (5.9206 *
# log10 BW - 6.76), feces (2.19 * DMI) and skin (0.018 * BW^0.75), transforms that into protein (*6.25) and then
# multiplies with 2.3 to get the uCP requirement. (Assuming an efficiency of using absorbed amino acid N of 70%, an
# absorbability of amino acid N of 85% and a proportion of amino acid N of non-ammonia-N in chyme of 73%.)
ME = 0.530 * pow(BW, 0.75)
uCP = ((5.9206 * log10(BW) - 6.76) + (2.19 * DMI) + (0.018 * pow(BW, 0.75))) * 6.25 * 2.3
return {
"E": ME,
"P": uCP
}
# GfE (2001) eqs. 1.4.3, 2.1.5
#
# Equation for energy requirement for milk production taken from GfE (2001) equation 1.4.3. Equation for protein
# requirement for milk production taken from GfE (2001) equation 2.1.5.
#
# The multiplication with 2.1 in the protein requirement equation is again a result of assuming an efficiency of using
# absorbed amino acid N of 75%, an absorbability of amino acid N of 85% and a proportion of amino acid N of
# non-ammonia-N in chyme of 73%.
#
# production [{NEL, uCP}]
# milk [kg]
# fat [%]
# protein [%]
# p [#] parity
def production (milk, fat, protein, p):
if (p > 0):
NEL = milk * (0.38 * fat + 0.21 * protein + 0.95 + 0.1)
uCP = milk * protein * 10 * 2.1
return{
"E": NEL,
"P": uCP
}
else:
return{
"E": 0,
"P": 0
}
# GfE (2001) eqs 1.4.5, 2.2.2, Jeroch (2008) p. 410
#
# cows
#
# Equation for energy requirement for gestation taken from GfE (2001) equation 1.4.5. Equation for protein requirement
# for gestation taken from GfE (2001) equation 2.2.2.
#
# The equation for energy requirements summarizes the energetic value of the developed tissue in the uterus and the
# foetus (0.044 * e^(0.0165*d)) and the developed tissue of the udder (0.8 and 1.5 MJ, respectively) and then
# multiplies with 5.71 to get the requirement. (Assuming an efficiency of using energy for gestation of 17.5%.)
#
# GfE recommends to link the protein requirements of dry cows not to the N requirement of the cow but to the N
# requirement of the ruminal microbes: uCP supply for dry cows should be a minimum of 1080 [g day-1] during 42-21 days
# before calving and 1170 uCP [g day-1] during the last 21 days before calving, respectively.
#
# young stock
#
# GfE (2001) doesn´t mention additional energy and protein requirements for gestation. For energy, the recommendation
# from Jeroch (2008), who recommends adding extra energy during the last 6 weeks of gestation, was implemented.
#
# GfE (2001) doesn´t give information on protein requirement for gestation, rather the requirement for gestation is
# included in the requirement for body weight gain.
#
# gestation [{NEL or ME, uCP}]
# WG [week] Week of gestation (1-40)
# DIM [day] Days in milk (assume cow dry if zero)
# p [#] parity
def gestation(WG, DIM, p):
if (p > 0):
NEL = 0
uCP = 0
if (WG > 0):
if (WEEKS_GESTATION_PERIOD - WG < 3):
NEL = ((0.044 * exp(0.0165 * WG * 7)) + 1.5) * 5.71
elif (WEEKS_GESTATION_PERIOD - WG < 8):
NEL = ((0.044 * exp(0.0165 * WG * 7)) + 0.8) * 5.71
else:
NEL = ((0.044 * exp(0.0165 * WG * 7)) + 0.0) * 5.71
uCP = (1.9385 * exp(0.0108 * WG * 7)) * 6.25 * 2.3
# minimum recommended protein requirements for dry cows */
if (DIM == 0):
if (uCP < 1170 and WG > WEEKS_GESTATION_PERIOD - 3):
uCP = 1170
elif (uCP < 1080 and WG > WEEKS_GESTATION_PERIOD - 6):
uCP = 1080
return{
"E": NEL,
"P": uCP
}
else:
ME = 0
uCP = 0
if (WG > 0):
if (WEEKS_GESTATION_PERIOD - WG < 3):
ME = 30
elif (WEEKS_GESTATION_PERIOD - WG < 6):
ME = 20
return{
"E": ME
, "P": uCP
}
# GfE (2001)
#
# cows
#
# Equations for energy mobilization and weight gain taken from GfE (2001) page 22 and 23, respectively. Equation for
# protein mobilization taken from GfE (2001) chapter 2.1.1.3.
#
# The GfE does not give information in which stages of lactation mobilization and reconstitution of body reserves is
# to be expected. 80-85% of the energy content of body reserves is assumed to be used for milk production.
#
# Mobilization of protein at the beginning of lactation is not included in calculations. Net protein content of 1 kg
# body weight gain is assumed to be 138 g if body weight of the cow exceeds 550 kg and daily body weight gain is less
# than 500 g. Multiplication with 2.3 results from assuming an efficiency of using absorbed amino acid N of 70%, an
# absorbability of amino acid N of 85% and a proportion of amino acid N of non-ammonia-N in chyme of 73%.
#
# young stock
#
# Equation for energy requirements for body weight gain taken from GfE (2001) p. 28 equ. 1.5.1
#
# Information on protein requirement for body weight gain taken from GfE (2001) p. 48 and 50
#
# Both the energy and protein requirements for body weight gain are based on the net energy and protein retention of
# the heifer. GfE (2001) doesn´t supply equations for the calculation of energy and protein retention, but gives a
# Table (1.5.1) with discrete values depending on body weigth and body weight gain. Based on these discrete values
# from Table 1.5.1, linear regressions for the calculation of energy and protein retention were produced which are
# valid for heifers with body weights between 150 and 550 kg and body weight gains between 400 and 800 g per day, and
# which had coefficients of determination of 0.94 (energy) and 0.92 (protein).
#
# TODO:
# - Die GfE gibt zwei Untergrenzen für die Proteinversorgung der Aufzuchtrinder an: die Proteinzufuhr soll 12 g XP
# MJ-1 ME nicht unterschreiten, und die Ration soll mindestens 9 % XP enthalten. Blöderweise geben sie diese
# Empfehlungen in Rohprotein an, nicht in uCP. Können wir (zum. eines davon) das trotzdem irgendwie einbauen?
#
# weight [{NEL or ME, uCP}]
# BWC [kg] body weight change
# BW [kg] body weight
# p [#] parity
def weight(BWC, BW, p):
if (p > 0):
NEL = 0
uCP = 0
if (BWC < 0):
NEL = BWC * 20.5
else:
NEL = BWC * 25.5
uCP = BWC * 317.4
return{
"E": NEL,
"P": uCP
}
else:
ME = 0
uCP = 0
# RE [MJ] energy retention, expressed in MJ per day */
RE = -10.729 + BW * 0.02059 + BWC * 17.8868
# RN [g] protein retention, expressed in g per day */
RN = 61.1959 - BW * 0.08728 + BWC * 89.8389
ME = RE * 2.5
uCP = RN * 2.3
return{
"E": ME,
"P": uCP
}
return {
"main":maintenance(BW, DMI, f, p),
"prod":production(milk, fat, protein, p),
"gest":gestation(WG, DIM, p),
"weit":weight(BWC, BW, p),
"activ":activity(BW, f, d, d_v),
}
de = GermanSystem(DMI, f, p, WG, DIM, BW, BWC, milk, fat, protein, d, d_v)
# MTT (2014)
#
# cows
#
# Nutrient requirements of dairy cows according to the Finnish system of feed evaluation and requirements. Latest print
# version using "feed values" instead of ME, which is used now. The last description of the Finnish system of feed evaluation
# published in print is MTT (2006). Since then all updates have been published online, hereafter quoted as MTT (2014).
#
# Energy is expressed in MJ ME (metabolisable energy) and protein is expressed in g MP (metabolisable protein).
#
# young stock
#
# Nutrient requirements of dairy heifers according to the Finnish system of feed evaluation and requirements.
# The latest print version still used "feed values" instead of ME, which is used now.
#
# Energy is expressed in MJ ME (metabolisable energy) and protein is expressed in g MP (metabolisable protein).
#
# MTT doesn´t mention an energy addition due to grazing for the heifers, but the NRC approach as described above will be
# used nonetheless.
def FinishSystem(DMI, f, p, BW, BWC, type, milk, fat, protein):
# MTT (2014)
#
# cows
#
# All equations for energy requirements taken from website, chapter "Energy requirements of dairy cows".
# All equations for protein requirements taken from website, chapter "Protein requirements of dairy cows".
#
# young stock
#
# Information taken from website, chapter "Energy requirements of growing heifers".
#
# The MTT website provides a Table which gives the sum of the energy requirements of heifers for maintenance and
# growth. The original equations (separated into requirements for maintenance and growth) which were used to calculate
# the energy requirements were provided by Rinne (2014), who states that the equations used for young cattle ME
# requirements in Finland are based on AFRC (1990) and were modified by Mikko Tuori (University of Helsinki, 1955) and
# further by Arto Huuskonen (MTT Agrifood Research Finland, 2010).
#
# For the protein requirements for maintenance and growth, MTT only provides a Table for heifers smaller than 200 kg
# (see website, chapter "Protein requirements of growing cattle"). From the values in this Table, a linear regression
# for calculating protein requirements depending on body weight and body weight change was produced, which is valid
# for heifers with body weights between 100 and 200 kg and body weight gains between 0.5 and 1.6 kg per day, and which
# had a coefficient of determination of 0.99.
# For all heifers heavier than 200 kg, protein intake is assumed to be adequate if the protein balance in the rumen
# (PBV) of the total diet is not lower than -10 g per kg feed. In SOLID-DSS, the PBV values will not be used. Instead,
# Rinne (2014) recommended to use a minimum recommendation of 90 g CP in the total diet.
# k_m (efficiency of using ME for maintenance) is assumed as 0.712.
#
# TODO:
# - Wie bauen wir die Mindestempfehlung von 90 g XP in der Gesamtration für die heifers > 200 kg ein?
#
# maintenance [{ME, MP}] adjusted for share of forages in diet (acc. to AFBI, see explanation above)
# BW [kg] body weight
# DMI [kg] Dry matter intake (if unknow assume IC ~ DMI @ FV = 1)
# f [kg (DM) kg-1 (DM)] share of forage in diet
# BWC [kg] body weight change
# type [enum] type of cow, dairy or dual (purpose)
# p [#] parity
# */
#
def maintenance(BW, DMI, f, BWC, type, p):
if (p > 0):
ME = 0.515 * pow(BW, 0.75)
MP = 1.8 * pow(BW, 0.75) + 14 * DMI
if (f):
if (f < 0.3):
ME = 0.492 * pow(BW, 0.75)
elif (f >= 0.3 and f <= 0.99):
ME = 0.515 * pow(BW, 0.75)
else:
ME = 0.560 * pow(BW, 0.75)
return{
"E": ME,
"P": MP
}
else:
ME = (0.53 * pow(BW / 1.08, 0.67) + 0.0071 * BW ) / 0.712
MP = -36.3373 + BW * 0.8879 + BWC * 247.1739
if(type == 'dual'):
ME = ME * 0.9
#if (BW > 200) XP should be at least 90 g
return{
"E": ME,
"P": MP
}
# MTT (2014)
#
# ECM is calculated according to Sjaunja et al. (1990)
#
# production [{ME, MP}]
# milk [kg]
# fat [%]
# protein [%]
# p [#]
#
# TODO: there is a correction equation for energy intake!
# jv: Hm, I would argue that we do not need it if use INRA intake. Because feed interaction is covered there, isn't it?
# On the other hand that might mean that we also have to remove ME from gb maint. requirements????
def production(milk, fat, protein, p):
if (p > 0):
ECM = milk * (383 * fat + 242 * protein + 783.2) / 3140
ME = 5.15 * ECM
MP = (1.47 - 0.0017 * ECM) * (milk * protein * 10 )# to g kg-1
return{
"E": ME,
"P": MP
}
else:
return{
"E": 0,
"P": 0
}
# MTT (2014)
#
# According to Rinne (2014), the energy and protein requirements for young stock gestation are calculated similar to
# the older cows.
#
# gestation [{ME, MP}]
# WG [1-40] week of gestation
def gestation(WG):
ME = 0
MP = 0
if (WG > 0):
if (WG / WEEKS_IN_MONTH > 8):
ME = 34.0
MP = 205.0
elif (WG / WEEKS_IN_MONTH > 7):
ME = 19.0
MP = 135.0
elif (WG / WEEKS_IN_MONTH > 6):
ME = 11.0
MP = 75.0
return{
"E": ME,
"P": MP
}
# MTT (2014)
#
# young stock
#
# The equation for calculating the energy requirements for weight gain is not provided on the website, but was
# supplied by Rinne (2014), details see above. k_f, the efficiency of using ME for body weight gain, is assumed as
# 0.474.
#
# The protein requirement for body weight gain is included in the requirements for maintenance, details see above.
#
# weight [{ME, MP}]
# BWC [kg] body weight change
# BW [kg] body weight
# type [enum] type of cow, dairy or dual (purpose)
# p [#] parity
def weight(BWC, BW, type, p):
if (p > 0):
ME = 0
MP = 0
if (BWC < 0):
ME = BWC * 28.0
MP = BWC * 138.0
else:
ME = BWC * 34.0
MP = BWC * 233.0
return{
"E": ME,
"P": MP
}
else:
ME = (((4.1 + 0.0332 * BW - 0.000009 * BW * BW) / (1 - 0.1475 * BWC)) * 1.15 * BWC) / 0.474
MP = 0
if type == 'dual':
ME *= 0.9
return{
"E": ME,
"P": MP
}
# # FOR THE SAKE OF COMPLETENESS: fi energy correction
#
# The Finnish nutrient requirements for dairy cows includes a correction equation for energy intake, which in SOLID-DSS
# is probably not usable, because it requires knowledge of the total diet when calculating intake. (Which in SOLID-DSS
# is calculated before diets are formulated.) However, we want to estimate feed intake according to the Finnish equation
# and correct it using their correction equation after the solver has produced the diets and then check to see how big
# the difference between the Finnish energy intake and the energy intake based on the results from the solver is.
#
# The last description of the Finnish system of feed evaluation published in print is MTT (2006). Since then all updates
# have been published online, quoted as MTT (2014).
#
# Energy values of feeds are expressed in Finnish MJ ME, details see feed.evaluation.js
#
# REFERENCES
#
# MTT 2006. Rehutaulukot ja ruokintasuositukset (Feed tables and feeding recommendations). Agrifood Research Finland,
# Jokioninen, Finland, 84 p.
#
# MTT 2014. Rehutaulukot ja ruokintasuositukset (Feed tables and feeding recommendations) [online]. Agrifood
# Research Finland, Jokioinen. Accessed last on November 20, 2014, available at:
# https://portal.mtt.fi/portal/page/portal/Rehutaulukot/feed_tables_english
#
#
# Estimation of feed intake according to MTT (2014)
#
# In Finland, feed intake of dairy cows is estimated using the energy requirements and an average diet energy
# concentration, assuming that energy supply is adequate and the cow is neither mobilizing nor reconstituting body
# reserves.
#
# f_intake [kg (DM)] Estimated feed intake, kg DM
# ME_req [MJ ME] Total energy requirements of a cow per day
# ME_avg [MJ kg-1 (DM)] Average energy concentration of the total diet
def f_intake(ME_req, ME_avg):
return ME_req / ME_avg
# Calculation of corrected energy intake according to MTT (2014)
#
# The Finnish feed evaluation system uses constant energy values for feeds and doesn´t take associative effects of feeds
# and effects of feeding level into account. As a remedy, the energy intake of the cow is corrected in order to consider
# effects of increased dry matter intake, high energy diets and diets with low crude protein concentration.
#
# f_intake_corr [MJ ME] Corrected energy intake
# f_intake [kg (DM)] Estimated feed intake, kg DM
# ME_avg [MJ kg-1 (DM)] Average energy concentration of the total diet
# CP_avg [g kg-1 (DM)] Average crude protein concentration of the total diet
def f_intake_corr(f_intake, ME_avg, CP_avg):
return f_intake * ME_avg - (-56.7 + 6.99 * ME_avg + 1.621 * f_intake - 0.44595 * CP_avg + 0.00112 * CP_avg * CP_avg)
return {
"main": maintenance(BW, DMI, f, BWC, type, p),
"prod": production(milk, fat, protein, p),
"gest": gestation(WG),
"weit": weight(BWC, BW, type, p),
"activ": activity(BW, f, d, d_v),
}
fi = FinishSystem(DMI, f, p, BW, BWC, type, milk, fat, protein)
# FiM (2004), AFRC (1993)
#
# cows
#
# Nutrient requirements of dairy cows according to the British system of feed evaluation and requirements.
#
# Energy is expressed in MJ ME (metabolisable energy) and protein is expressed in g MP (metabolisable protein). Feed
# into Milk (FiM) recommends adding a 5 % safety margin to the total energy and protein requirements. This is not
# included in the following equations.
#
# young stock
#
# While the energy and protein requirements of the dairy cows are calculated as described in Feed into Milk (FiM 2004),
# FiM doesn´t mention heifers, therefore all information about the energy and protein requirements of dairy heifers is
# taken from AFRC (1993).
#
# Energy is expressed in MJ ME (metabolisable energy) and protein is expressed in g MP (metabolisable protein).
#
# AFRC doesn´t mention an activity addition because of grazing for the dairy heifers, but the NRC approach as described
# above will be used nonetheless.
def BritishSystem(DMI, f, p, WG, BW, BWC, milk, fat, protein, ME_total, ME_ferm=None, diet_fat=None):
# cows
#
# Instead of the original FiM equation to calculate energy requirements for maintenance, the equations produced by
# SOLID Task 3.3 (Dong et al. 2014, see above) are used. In this case, incorporating the new AFBI equations in a TOTAL
# way is appropriate, because they were developed within the British system of feed evaluation and requirements.
#
# Assuming an average fill value of 1, the IC (FV) value produced by GrazeIn is used instead of DMI (kg)
#
# young stock
#
# AFRC (1993) doesn´t differentiate between the energy requirements for maintenance, growth and gestation, instead
# a Table giving the total energy and protein requirements for growing heifers depending on body weight, daily weight
# gain and (for energy requirement only) energy density of the diet is supplied (Table 5.5)
# Based on the values from Table 5.5, linear regressions for calculating energy and protein requirements for
# maintenance and body weight gain depending on body weight, body weight gain and energy density of the diet were
# produced which are valid for heifers with body weight between 100 and 600 kg and body weight gains between 0.5 and
# 1.0 kg per day, and which had coefficients of determination of 0.98 (energy) and 0.99 (protein).
#
# Assuming an average fill value of 1, the IC (FV) value produced by GrazeIn is used instead of DMI (kg)
#
# maintenance [{ME, MP}] Adjusted for share of forages in diet (by AFBI)
# BW [kg] Body weight
# DMI [kg] Dry matter intake (if unknow assume IC ~ DMI @ FV = 1)
# ME_total [MJ kg-1 (DM)] Energy supply of the total diet
# f [kg (DM) kg (DM)] Share of forage in diet (optional)
# fat [kg d-1] Amount of fat supplied by the total diet
# ME_ferm [MJ kg-1 (DM)] Energy contribution of fermentation acids in the feeds, sum of the total diet
# BWC [kg] body weight change
# p [#] parity
def maintenance(BW, DMI, ME_total, f, diet_fat, ME_ferm, BWC, p):
if (p > 0):
# ME_fat [MJ kg-1 (DM)] energy contribution of oils and fat in the feeds, sum of the total diet.
# If fat is not available we assume 3.5% fat in ration i.e. the average in relevant fresh forages */
if diet_fat is None:
ME_fat = 0.035 * 35
else:
ME_fat = 35 * diet_fat
# ME_ferm is the energy contribution of the fermentation acids, so this part only applies to silage. When the
# amounts of fermentation acids are not know, an average value of 0.10 * ME is used.
# If ME_ferm is not available we assume 10% fermentation acids in silage, and 6.5 kg silage in the diet, with an
# energy content of 11.2 MJ ME
if ME_ferm is None:
ME_ferm = 6.5 * 11.2 * 0.1 # kg (DM) silage * ME kg-1 * fraction of fermentation acids kg-1
ME = 0.68 * pow(BW, 0.75)
# FiM (2004) p. 23f, NRC (2001) p. 18ff
#
# The equation for protein requirements for maintenance summarizes the endogenous N losses via urine (4.1 *W^0.5),
# hair and scurf (0.3 * W^0.6) and feces (metabolic fecal protein, MFP = 30 * DMI). Also an adjustment is included
# for the fraction of intestinally indigestible rumen-synthesized microbial protein that is degraded from the hind
# gut and absorbed as ammonia (0.5 * ((DMTP/0.8) - DMTP). FiM adopted these four equations from NRC (2001).
#
# Endogenous protein supply at the intestine is estimated to be about 15% of NAN flow, and the efficiency of
# synthesis of endogenous protein from MP is assumed to be 0.67. The net effect of endogenous protein is modeled
# with the term 2.34*DMI.
#
# DMTP (digestible microbial true protein, g d-1) is calculated acc. to equation 3.19 in FiM (2004):
#
# DMTP = 0.6375 * MCP
#
# MCP = microbial crude protein, g d-1
#
# MCP is calculated acc. to AFRC (1993) page 16:
#
# MCP, g d-1 = 11 * FME
#
# FME = fermentable metabolisable energy, MJ kg-1 DM = ME - ME_fat - ME_ferm
DMTP = 0.6375 * 11 * (ME_total - ME_fat - ME_ferm)
MP = 4.1 * pow(BW, 0.5) + 0.3 * pow(BW, 0.6) + 30.0 * DMI - 0.5 * ((DMTP / 0.8) - DMTP) + 2.34 * DMI
if f:
if (f < 0.3):
ME = 0.65 * pow(BW, 0.75)
elif (f >= 0.3 and f <= 0.99):
ME = 0.68 * pow(BW, 0.75)
else:
ME = 0.74 * pow(BW, 0.75)
return{
"E": ME
, "P": MP
}
else:
# TODO: exclude feed level adjustment in SOLID-DSS. Use 11 MJ ME/kg TM instead of ME_total / DMI
ME = 22.2136 - ME_total / DMI * 3.3290 + BW * 0.1357 + BWC * 48.5855
MP = 80.7936 + BW * 0.3571 + BWC * 223.1852
return{
"E": ME,
"P": MP
}
# AFRC (1993), Tyrell (1965)
#
# The energy requirements for milk production are not calculated acc. to FiM (2004), because FiM calculates energy
# requirements for maintenance and milk production together and uses an efficiency of using energy for lactation (k_l)
# that changes with increasing energy intake. Because in SOLID-DSS energy requirements for maintenance are calculated
# acc. to Dong et al. (2014), energy requirements for milk production cannot be calculated acc. to FiM (2004).
#
# The k_l value of 0.62 is taken from Dong et al. (2014). The equation for calculating the energy value of milk is
# taken from Tyrell and Reid (1965), which is used both by AFRC (1993) and FiM (2004).
#
# production [{ME, MP}]
# milk [kg]
# fat [%]
# protein [%]
# p [#] parity
def production(milk, fat, protein, p):
if (p > 0):
energy_value_of_milk = 0.0376 * fat * 10.0 + 0.0209 * protein * 10.0 + 0.948 # fat and protein in g per kg */
ME = (milk * energy_value_of_milk) / 0.62
# ARFC (1993) eqs. 87, 88
#
# The crude protein of milk contains 0.95 true protein. The efficiency of utilization of absorbed amino acids for
# milk protein synthesis is assumed to be 0.68.
MP = (milk * protein * 10.0 * 0.95 ) / 0.68 # protein in g per kg
return{
"E": ME,
"P": MP
}
else:
return{
"E": 0,
"P": 0
}
# Equation for energy requirement for gestation taken from FiM (2004) p. 16 and accompanying CD p., adapted from
# AFRC (1993) equations 70, 71, 72
#
# Equation for protein requirement for gestation taken from FiM (2004) p. 24 and accompanying CD p. 16, adapted from
# AFRC (1993), equations 109 and 110. The efficiency of utilizing MP for pregnancy is assumed to be 0.85.
#
# gestation [{ME, MP}]
# WG [week] Week of gestation (1-40)
# p [#] parity
def gestation(WG, p):
if (p > 0):
ME = 0
MP = 0
# EGU (FiM 2004) = E_t (AFRC 1993) = energy retention in the gravid foetus */
EGU = exp(((151.665 - (151.64 * exp(-0.0000576 * WG * 7)))) * 2.30258)
# TtT (FiM 2004) = TP_t (AFRC 1993) = net protein retention for pregnancy to produce a 40 kg calf */
TtT = 1000 * exp(log(10) * (3.707 - (5.698 * exp(-0.00262 * WG * 7))))
if (WG > 0):
if (WG * 7 >= 250):
ME = EGU * (0.0201 * exp(-0.0000576 * WG * 7)) / 0.133
MP = TtT * (0.03437 * exp(-0.00262 * WG * 7)) / 0.85
return{
"E": ME,
"P": MP
}
else:
return{
"E": 0,
"P": 0
}
# FiM (2004) eqs. 2.2, 2.3, AFRC (1993) eqs. 114, 115
#
# Equation for energy supply from weight loss and gain from FiM (2004).
#
# Feed into Milk does not give any information in which stages of lactation mobilization and reconstitution of body
# reserves is to be expected. For weight loss, an efficiency of utilizing mobilized body protein for milk production
# of 1.0 is assumed. The net energy value of 1 kg live weight gain is assumed to be 19.3 MJ, and the efficiency of
# utilizing ME for weight gain is assumed to be 65%. This equation is different from AFRC (1993), where older
# equations based on castrated males of medium-sized cattle breeds were used.
#
# Equation for protein supply from weight loss and gain from AFRC (1993).
#
# The net protein content of empty body weight change is 150 g / kg, which is equivalent to 138 g kg-1 live weight
# gain. The efficiency of utilizing MP for weight gain is assumed to be 0.59, and 138 / 0.59 = 233. The efficiency of
# utilizing MP for pregnancy is assumed to be 0.85.
#
# weight [{ME, MP}]
# BWC [kg] body weight change
# p [#] parity
def weight(BWC, p):
if (p > 0):
if (BWC < 0):
ME = 19.3 * BWC * 0.78
MP = BWC * 138.0
else:
ME = 19.3 * BWC / 0.65
MP = BWC * 233.0
return{
"E": ME,
"P": MP
}
else:
return{
"E": 0,
"P": 0
}
# AFRC (1993)
#
# The calculation of energy required for activity is the same as in AFRC 1993. We do not use this function but add
# it for the sake of completeness. Adjustment for activity is done with equations from NRC.
#
# activity_ [{ME, MP}]
# BW [kg] Body weight
# DMI [kg] Total dry matter intake
# ME_intake [MJ] Total intake of ME
def activity_alt_formula(BW, DMI, ME_intake):
MP = 0
# efficiency of utilization of ME for maintenance */
k_m = 0.019 * (ME_intake / DMI) + 0.503
ME = (0.0013 * BW) / k_m
return{
"E": ME,
"P": MP
}
return {
"main": maintenance(BW, DMI, ME_total, f, diet_fat, ME_ferm, BWC, p),
"prod": production(milk, fat, protein, p),
"gest": gestation(WG, p),
"weit": weight(BWC, p),
"activ": activity(BW, f, d, d_v),
}
gb = BritishSystem(DMI, f, p, WG, BW, BWC, milk, fat, protein, ME_total, ME_ferm, diet_fat)
# Agabriel, J. (ed.) (2010)
#
# cows
#
# Energy and protein requirements according to the French system of feed evaluation and requirements. Energy is
# expressed as UFL (unité fourragere lait) and protein is expressed as g PDI, true protein.
#
# Information about energy mobilization is taken from Jarrige (1989).
#
# young stock
#
# Energy and protein requirements according to the French system of feed evaluation and requirements.
#
# Agabriel (2010) mostly refers to Jarrige (1988) with regard to the energy and protein requirements for dairy heifers,
# therefore most of the references are from Jarrige (1989).
#
# Energy is expressed as UFL (unité fourragere lait) and protein is expressed as g PDI (true protein).
#
# INRA doesn´t mention an activity addition due to grazing for heifers, but the NRC approach as described
# above will be used nonetheless.
#
# The energy and protein requirements for gestation are not calculated separately, but are included in the
# requirements for growth.
def FrenchSystem(DMI, f, p, WG, BW, BWC, WL, WB, milk, fat, protein):
# Agabriel (2010) eqs. 2.7, 2.16, Dong (2014)
#
# cows
#
# Energy requirements for maintenance adjusted for forage proportion acc. to Dong et al. (2014), see above.
#
# young stock
#
# Equation for energy requirement for maintenance taken from Agabriel (2010) p. 94, 95 and Table 5.1.
# Equation for protein requirement for maintenance taken from Agabriel (2010) p. 94.
# For calculating k_m and k_l according to Agabriel (2010) Table 8.1, q (ME/GE) is assumed to be 0.57.
#
# maintenance [{UFL, PDI}] Adjusted for share of forages in diet (by AFBI)
# BW [kg] Body weight
# DMI [kg] Dry matter intake (if unknow assume IC ~ DMI @ FV = 1)
# f [kg (DM) kg (DM)] Share of forage in diet
# p [#] parity
def maintenance(BW, DMI, f, p):
if (p > 0):
UFL = 0.041 * pow(BW, 0.75)
PDI = 3.25 * pow(BW, 0.75)
if (f):
if (f < 0.3):
UFL = 0.039 * pow(BW, 0.75) # k_l = 0.60 */
elif (f >= 0.3 and f <= 0.99):
UFL = 0.041 * pow(BW, 0.75)
else:
UFL = 0.045 * pow(BW, 0.75)
return{
"E": UFL,
"P": PDI
}
else:
# k_m [0-1] efficency of using ME for maintenance */
k_m = 0.287 * 0.57 + 0.554
# k_l [0-1] efficency of using ME for lactation TODO: (0.57-0.57)? */
k_l = 0.60 + 0.24 * (0.57-0.57)
UFL = (((90 * pow(BW, 0.75)) * k_l ) / k_m) / 1700
PDI = 3.25 * pow(BW, 0.75)
return{
"E": UFL,
"P": PDI
}
# Agabriel (2010) eqs. 2.9, 2.18
#
# production [{UFL, PDI}]
# milk [kg] Milk yield in kg raw milk
# fat [%] Milk fat content
# protein [%] Milk protein content
# p [#] parity
def production(milk, fat, protein, p):
if (p > 0):
# % to g kg-1 */