61 ok_fermentables = 1, // Fermentables are in stock |
61 ok_fermentables = 1, // Fermentables are in stock |
62 ok_hops = 1, // Hops are in stock |
62 ok_hops = 1, // Hops are in stock |
63 ok_miscs = 1, // Miscs are in stock |
63 ok_miscs = 1, // Miscs are in stock |
64 ok_yeasts = 1, // Yeasts are in stock |
64 ok_yeasts = 1, // Yeasts are in stock |
65 ok_waters = 1, // Waters are in stock |
65 ok_waters = 1, // Waters are in stock |
|
66 |
|
67 error_count = 0; |
66 |
68 |
67 hop_flavour = 0, |
69 hop_flavour = 0, |
68 hop_aroma = 0, |
70 hop_aroma = 0, |
69 mash_infuse = 0, |
71 mash_infuse = 0, |
70 last_base = '', |
72 last_base = '', |
2401 maybe_starter = 0; |
2403 maybe_starter = 0; |
2402 console.log('calcYeast() pitchrate:' + pitchrate + ' start:' + initcells + ' needed:' + needed + ' volume:' + volume + ' maybe_starter:' + maybe_starter); |
2404 console.log('calcYeast() pitchrate:' + pitchrate + ' start:' + initcells + ' needed:' + needed + ' volume:' + volume + ' maybe_starter:' + maybe_starter); |
2403 |
2405 |
2404 if (maybe_starter != dataRecord.starter_enable) { |
2406 if (maybe_starter != dataRecord.starter_enable) { |
2405 dataRecord.starter_enable = maybe_starter; |
2407 dataRecord.starter_enable = maybe_starter; |
|
2408 showStarter(); |
2406 } |
2409 } |
2407 |
2410 |
2408 if (dataRecord.starter_enable) { |
2411 if (dataRecord.starter_enable) { |
2409 calcSteps(dataRecord.starter_type, initcells, needed); |
2412 calcSteps(dataRecord.starter_type, initcells, needed); |
2410 |
2413 |
2768 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) |
2771 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) |
2769 Result += x * row.f_amount; |
2772 Result += x * row.f_amount; |
2770 } |
2773 } |
2771 } |
2774 } |
2772 } else { |
2775 } else { |
2773 console.log('ProtonDeficit(' + pHZ + ') invalid grist, return ' + Result); |
2776 error_count++; |
|
2777 if (error_count < 5) |
|
2778 console.log('ProtonDeficit(' + pHZ + ') invalid grist, return ' + Result); |
2774 } |
2779 } |
2775 return Result; |
2780 return Result; |
2776 } |
2781 } |
2777 |
2782 |
2778 function MashpH() { |
2783 function MashpH() { |
|
2784 console.log('MashpH()'); |
2779 var n = 0, pH = 5.4, deltapH = 0.001, deltapd = 0.1, pd = ProtonDeficit(pH); |
2785 var n = 0, pH = 5.4, deltapH = 0.001, deltapd = 0.1, pd = ProtonDeficit(pH); |
2780 while (((pd < -deltapd) || (pd > deltapd)) && (n < 2000)) { |
2786 while (((pd < -deltapd) || (pd > deltapd)) && (n < 2000)) { |
2781 n++; |
2787 n++; |
2782 if (pd < -deltapd) |
2788 if (pd < -deltapd) |
2783 pH -= deltapH; |
2789 pH -= deltapH; |
3101 frac = CalcFrac(pHa, pK1, pK2, pK3); |
3107 frac = CalcFrac(pHa, pK1, pK2, pK3); |
3102 protonDeficit = Acid * frac; |
3108 protonDeficit = Acid * frac; |
3103 |
3109 |
3104 deltapH = 0.001; |
3110 deltapH = 0.001; |
3105 deltapd = 0.1; |
3111 deltapd = 0.1; |
|
3112 console.log('in calcWater() manual'); |
3106 pd = ProtonDeficit(pHa); |
3113 pd = ProtonDeficit(pHa); |
3107 n = 0; |
3114 n = 0; |
3108 while (((pd < (protonDeficit - deltapd)) || (pd > (protonDeficit + deltapd))) && (n < 2000)) { |
3115 while (((pd < (protonDeficit - deltapd)) || (pd > (protonDeficit + deltapd))) && (n < 2000)) { |
3109 n++; |
3116 n++; |
3110 if (pd < (protonDeficit - deltapd)) |
3117 if (pd < (protonDeficit - deltapd)) |
3687 calcMashEfficiency(); |
3694 calcMashEfficiency(); |
3688 calcEfficiencyBeforeBoil(); |
3695 calcEfficiencyBeforeBoil(); |
3689 calcEfficiencyAfterBoil(); |
3696 calcEfficiencyAfterBoil(); |
3690 |
3697 |
3691 $('#starter_try').click(function() { |
3698 $('#starter_try').click(function() { |
3692 $('#prop1_volume,#prop2_volume,#prop3_volume,#prop4_volume').val(0); |
3699 $('#prop1_volume').val(0); |
|
3700 $('#prop2_volume').val(0); |
|
3701 $('#prop3_volume').val(0); |
|
3702 $('#prop4_volume').val(0); |
|
3703 dataRecord.prop1_volume = dataRecord.prop2_volume = dataRecord.prop3_volume = dataRecord.prop4_volume = 0; |
3693 calcYeast(); |
3704 calcYeast(); |
3694 }); |
3705 }); |
3695 $('#starter_type').on('change', function(event) { |
3706 $('#starter_type').on('select', function(event) { |
3696 if (event.args) { |
3707 if (event.args) { |
3697 dataRecord.starter_type = event.args.index; |
3708 dataRecord.starter_type = event.args.index; |
3698 calcYeast(); |
3709 calcYeast(); |
3699 } |
3710 } |
3700 }); |
3711 }); |
3811 setWaterAgent('NaCl', 0); |
3822 setWaterAgent('NaCl', 0); |
3812 setWaterAgent('NaCl', event.args.value); |
3823 setWaterAgent('NaCl', event.args.value); |
3813 calcWater(); |
3824 calcWater(); |
3814 } |
3825 } |
3815 }); |
3826 }); |
3816 $('#wa_base_name').on('change', function(event) { |
3827 $('#wa_base_name').on('select', function(event) { |
3817 if (event.args) { |
3828 if (event.args) { |
3818 var index = event.args.index; |
3829 var index = event.args.index; |
3819 console.log('wa_base_name ' + index); |
3830 console.log('wa_base_name ' + index); |
3820 setWaterAgent(last_base, 0); |
3831 setWaterAgent(last_base, 0); |
3821 last_base = BaseTypeData[index].nl; |
3832 last_base = BaseTypeData[index].nl; |
3827 $('#wa_base').on('change', function(event) { |
3838 $('#wa_base').on('change', function(event) { |
3828 var name = BaseTypeData[$('#wa_base_name').val()].nl; |
3839 var name = BaseTypeData[$('#wa_base_name').val()].nl; |
3829 setWaterAgent(name, parseFloat(event.args.value)); |
3840 setWaterAgent(name, parseFloat(event.args.value)); |
3830 calcWater(); |
3841 calcWater(); |
3831 }); |
3842 }); |
3832 $('#wa_acid_name').on('change', function(event) { |
3843 $('#wa_acid_name').on('select', function(event) { |
3833 if (event.args) { |
3844 if (event.args) { |
3834 var index = event.args.index; |
3845 var index = event.args.index; |
3835 console.log('wa_acid_name ' + index); |
3846 console.log('wa_acid_name ' + index); |
3836 setWaterAgent(last_acid, 0); |
3847 setWaterAgent(last_acid, 0); |
3837 last_acid = AcidTypeData[index].nl; |
3848 last_acid = AcidTypeData[index].nl; |
3845 setWaterAgent(name, parseFloat(event.args.value)); |
3856 setWaterAgent(name, parseFloat(event.args.value)); |
3846 calcWater(); |
3857 calcWater(); |
3847 }); |
3858 }); |
3848 $('#wa_acid_perc').on('change', function(event) { calcWater(); }); |
3859 $('#wa_acid_perc').on('change', function(event) { calcWater(); }); |
3849 |
3860 |
3850 $('#color_method').on('change', function(event) { |
3861 $('#color_method').on('select', function(event) { |
3851 dataRecord.color_method = event.args.index; |
3862 dataRecord.color_method = event.args.index; |
3852 calcFermentables(); |
3863 calcFermentables(); |
3853 }); |
3864 }); |
3854 $('#ibu_method').on('change', function(event) { |
3865 $('#ibu_method').on('select', function(event) { |
3855 dataRecord.ibu_method = event.args.index; |
3866 dataRecord.ibu_method = event.args.index; |
3856 calcFermentables(); |
3867 calcFermentables(); |
3857 calcIBUs(); |
3868 calcIBUs(); |
3858 }); |
3869 }); |
3859 |
3870 |
3928 }); |
3939 }); |
3929 $('#sparge_temp').on('change', function(event) { |
3940 $('#sparge_temp').on('change', function(event) { |
3930 dataRecord.sparge_temp = parseFloat(event.args.value); |
3941 dataRecord.sparge_temp = parseFloat(event.args.value); |
3931 $('#brew_sparge_temperature').val(dataRecord.sparge_temp); |
3942 $('#brew_sparge_temperature').val(dataRecord.sparge_temp); |
3932 }); |
3943 }); |
3933 $('#sparge_source').on('change', function(event) { |
3944 $('#sparge_source').on('select', function(event) { |
3934 if (event.args) { |
3945 if (event.args) { |
3935 dataRecord.sparge_source = event.args.index; |
3946 dataRecord.sparge_source = event.args.index; |
3936 calcSparge(); |
3947 calcSparge(); |
3937 } |
3948 } |
3938 }); |
3949 }); |
3939 $('#sparge_acid_type').on('change', function(event) { |
3950 $('#sparge_acid_type').on('select', function(event) { |
3940 if (event.args) { |
3951 if (event.args) { |
3941 dataRecord.sparge_acid_type = event.args.index; |
3952 dataRecord.sparge_acid_type = event.args.index; |
3942 console.log('new sparge_acid_type: ' + dataRecord.sparge_acid_type); |
3953 console.log('new sparge_acid_type: ' + dataRecord.sparge_acid_type); |
3943 calcSparge(); |
3954 calcSparge(); |
3944 } |
3955 } |