fork download
  1. // 3 kwietnia 2015.cpp
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <conio.h>
  6. #include <iostream>
  7. #include <string>
  8. #include <fstream>
  9.  
  10. using namespace std;
  11.  
  12.  
  13. //deklaracje nowego typu, paru funkcji oraz struktury
  14. #pragma region deklaracje
  15. typedef long double ld;
  16. struct MEDIUM
  17. {
  18. //caly czas w mg/l
  19. ld nitrogen;
  20. ld phosphorus;
  21. ld potassium;
  22. ld calcium;
  23. ld magnesium;
  24. ld chlorine;
  25. ld sulfur;
  26. ld carbonates; //im wyzsze pH, tym wiecej woda zawiera weglanow (nie pomyl, najpierw ph potem weglany)
  27. ld sodium;
  28. ld iron;
  29. ld boron;
  30. ld zinc;
  31. ld manganese;
  32. ld copper;
  33. ld molybdenum;
  34. double pH;
  35. double EC;
  36. };
  37. bool maxForElements(MEDIUM Initial_medium);
  38. MEDIUM loadInitialtMedium();
  39. ld acid_ratio(double weglany, ld &quantityOfNitrogenIn1dm4);
  40. ld acid_dose(ld W, double weglany, ld &dawka_kwasu);
  41. ld nitrogen_introduced_f(ld dk, ld quantityOfNitrogenIn1dm4);
  42. MEDIUM loadDesiredMedium();
  43. void mediumReplenishment(ld nitrogen_introduced, MEDIUM Initial_medium2, MEDIUM desired_medium2, MEDIUM fixed_medium, ld dawka_kwasu);
  44. MEDIUM loadInitialMedium();
  45. void showHowManyFertilizersAreNeeded(
  46. ld calcium_nitrate,
  47. ld potassium_phosphate,
  48. ld magnessium_nitrate,
  49. ld potassium_nitrate,
  50. ld amonium_nitrate);
  51.  
  52. #pragma endregion
  53.  
  54.  
  55. int _tmain(int argc, _TCHAR* argv[])
  56. {
  57. cout << "******************************************\n\n\trk 10 lipca 2015:\n\tMedium Composition Program\n\n******************************************\n\n\n";
  58.  
  59. //wprowadzanie danych
  60. cout << "\n\n------------\n\tProsze podawac wartosci w jednostkach miligramow na litr [mg/l]" << endl;
  61. MEDIUM Initial_medium2 = loadInitialMedium();
  62.  
  63.  
  64. //sprawdzenie czy zaden ze skladnikow nie przekracza dozwolonego pulapu
  65. if (!(maxForElements(Initial_medium2)))
  66. {
  67. cout << "\n\n------------\n\tJeden z elementow przekracza dozwolona wartosc." << endl;
  68. cout << "\tKontynuowac? Wpisz 'y' lub 'n' i zatwierdz enterem\t";
  69. char znak;
  70. cin >> znak;
  71. if (znak == 'n')
  72. {
  73. cout << "\n\n\t>>program sequence aborted<<";
  74. _getch();
  75. return 0;
  76. }
  77. }
  78.  
  79.  
  80.  
  81. ld dawka_kwasu; //brzydkie rozwiązanie, ale potrzebowalem tej wartosci w poznym etapie pisania kodu (8 lipca 2015)
  82. ld quantityOfNitrogenIn1dm4 = 0; //jw lol
  83.  
  84.  
  85.  
  86. //uwaga, 3 funkcje zagniezdzone acid_ratio -> acid_dose -> nitrogen_introduced
  87. //dobra, skoncze na 3 zagniezdzeniu funkcji bo to źle wygląda
  88. ld dawka_kwasu222 = acid_dose(acid_ratio(Initial_medium2.carbonates, quantityOfNitrogenIn1dm4), Initial_medium2.carbonates, dawka_kwasu);
  89.  
  90. ld nitrogen_introduced = nitrogen_introduced_f(dawka_kwasu222, quantityOfNitrogenIn1dm4);
  91.  
  92.  
  93. //zapytanie usera, ile chce miec skladnikow w pozywce
  94. MEDIUM desired_medium2 = loadDesiredMedium();
  95.  
  96.  
  97. //fixed medium jest strukturą danych, na której będą dokonywane faktyczne zmiany
  98. MEDIUM fixed_medium = Initial_medium2;
  99.  
  100. //wyslanie do funkcji tego ile juz azotu zostalo wprwoadzonego + aktualne parametry pozywki
  101. mediumReplenishment(nitrogen_introduced, Initial_medium2, desired_medium2, fixed_medium, dawka_kwasu);
  102.  
  103. return 0;
  104. }
  105.  
  106. void mediumReplenishment(ld nitrogen_introduced, MEDIUM Initial_medium2, MEDIUM desired_medium2, MEDIUM fixed_medium, ld dawka_kwasu)
  107. {
  108. //dodanie do wartosci pola struktury .nitrogen ilosci wprowadzonego juz azotu z kwasem azotowym
  109. fixed_medium.nitrogen += nitrogen_introduced;
  110.  
  111.  
  112. struct percentage_of_nutrient_in_fertilizer //ponf
  113. {
  114. //calcium nitrate - saletra wapniowa
  115. //EC 1.24
  116. double calcium_nitrate_Ca = 0.19; //19%
  117. double calcium_nitrate_N = 0.155; //15.5%
  118. double calcium_nitrate_EC = 1.24;
  119.  
  120. //potassium phosphate - fosforan potasu
  121. //EC 0.68 //albo 0.56, ale raczej 0.68, nie idzie tego odczytac
  122. double potassium_phosphate_P = 0.23; //23%
  123. double potassium_phosphate_K = 0.28; //28%
  124. double potassium_phosphate_EC = 0.68;
  125.  
  126. ////ferticare
  127. ////EC 1.0
  128. //double ferticare_N = 0.07; //7%
  129. //double ferticare_P = 0.048;
  130. //double ferticare_K = 0.21; //21%
  131. //double ferticare_Mg = 0.028;
  132. //double ferticare_S = 0.05; //5%
  133.  
  134. //potassium nitrate - saletra potasowa Multi Top
  135. //ruru, siarczan potasu, nie mam saletry potasowej
  136. //EC 1.54
  137. double potassium_nitrate_N = 0.135; //13.5%
  138. double potassium_nitrate_K = 0.386; //38.6%
  139. double potassium_nitrate_EC = 1.54;
  140.  
  141. //magnesium nitrate - saletra magnezowa
  142. //ruru, zastepczo podaje EC dla innej saletry magnezowej (inne %)
  143. //EC 0.54
  144. double magnesium_nitrate_N = 0.11; //11%
  145. double magnesium_nitrate_Mg = 0.081; //8.1%
  146. double magnesium_nitrate_EC = 0.54;
  147.  
  148. //magnesium sulfate - siarczan magnezu
  149. //EC 0.94
  150. double magnesium_sulfate_Mg = 0.1; //10%
  151. double magnesium_sulfate_S = 0.27; //27%
  152. double magnessium_sulfate_EC = 0.94;
  153.  
  154. //amonium nitrate - saletra amonowa
  155. //EC 0.86
  156. //double amonium_nitrate_N = 0.34; //34%
  157. //double amonium_nitrate_EC = 0.86;
  158.  
  159. //potassium sulfate - siarczan potasu
  160. //EC zapozyczone od siarczanu magnezu
  161. double potassium_sulfate_K = 0.415; //41.5%
  162. double potassium_sulfate_S = 0.18;
  163. double potassium_sulfate_EC = 0.94;
  164.  
  165. //superba czerwona
  166. double superba_N = 0.073; //7.3%
  167. double superba_P = 0.04; //4%
  168. double superba_K = 0.214; //21.4%
  169. double superba_Mg = 0.035; //3.5%
  170. double superba_EC = 1.0;
  171.  
  172. }percent; //uzycie: percent.potassium_sulfate_K
  173.  
  174.  
  175. enum
  176. {
  177. ZBIORNIK_A = 1,
  178. ZBIORNIK_B = 2,
  179. ZBIORNIK_C = 3
  180. };
  181. //2 tablice typu
  182. //string przechowywujaca nazwe nawozu
  183. //ld przechowywujaca ilosc nawozu
  184. const int maksiumum_fertilizers_that_can_be_used = 7;
  185. string fertilizer_name[maksiumum_fertilizers_that_can_be_used];
  186. ld fertilizer_quantity[maksiumum_fertilizers_that_can_be_used] = { 0 }; //inicjalizacja wstepna
  187. double fertilizer_EC[maksiumum_fertilizers_that_can_be_used];
  188. int ktory_zbiornik[maksiumum_fertilizers_that_can_be_used];
  189.  
  190. //test
  191. //cout << "\ntest\t\tKwas azotowy" << endl;
  192. //cout << "fixed_medium.nitrogen\t\t" << fixed_medium.nitrogen << endl;
  193. //cout << "fixed_medium.phosphorus\t\t" << fixed_medium.phosphorus << endl;
  194. //cout << "fixed_medium.potassium\t\t" << fixed_medium.potassium << endl;
  195. //cout << "fixed_medium.calcium\t\t" << fixed_medium.calcium << endl;
  196. //cout << "fixed_medium.magnesium\t\t" << fixed_medium.magnesium << endl;
  197. //_getch();
  198.  
  199. #pragma region Saletra_wapniowa
  200. int counter = 0;
  201. //saletra wapniowa - wapń (100%) i azot
  202. ld quantity_of_calcium_nitrate_fertilizer = (desired_medium2.calcium - fixed_medium.calcium) / percent.calcium_nitrate_Ca;
  203. fertilizer_name[counter] = "Saletra wapniowa\t\t";
  204. fertilizer_quantity[counter] = quantity_of_calcium_nitrate_fertilizer;
  205. fertilizer_EC[counter] = percent.calcium_nitrate_EC;
  206. ktory_zbiornik[counter] = ZBIORNIK_A;
  207. //wapń
  208. fixed_medium.calcium += quantity_of_calcium_nitrate_fertilizer * percent.calcium_nitrate_Ca;
  209. //azot
  210. fixed_medium.nitrogen += quantity_of_calcium_nitrate_fertilizer * percent.calcium_nitrate_N;
  211. //ok
  212. //test
  213. //cout << "\ntest\t\tSaletra wapniowa" << endl;
  214. //cout << "fixed_medium.nitrogen\t\t" << fixed_medium.nitrogen << endl;
  215. //cout << "fixed_medium.phosphorus\t\t" << fixed_medium.phosphorus << endl;
  216. //cout << "fixed_medium.potassium\t\t" << fixed_medium.potassium << endl;
  217. //cout << "fixed_medium.calcium\t\t" << fixed_medium.calcium << endl;
  218. //cout << "fixed_medium.magnesium\t\t" << fixed_medium.magnesium << endl;
  219. //_getch();
  220.  
  221.  
  222.  
  223. #pragma endregion
  224.  
  225. #pragma region Superba_czerwona
  226.  
  227. ++counter;
  228. //superba czerwona
  229. //uzupelnic potas pierwszy -> brak mozliwosci uzupelnienia fosforu
  230. //uzupelnic fosfor pierwszy -> mozliwosc uzupelnienia potasu innym nawozem (jezeli wartosc K nie przekroczona)
  231. ld quantity_of_superba_czerwona_fertilizer = (desired_medium2.phosphorus - fixed_medium.phosphorus) / percent.superba_P;
  232. fertilizer_name[counter] = "Superba czerwona\t\t";
  233. fertilizer_quantity[counter] = quantity_of_superba_czerwona_fertilizer;
  234. fertilizer_EC[counter] = percent.superba_EC;
  235. ktory_zbiornik[counter] = ZBIORNIK_B;
  236. //fosfor
  237. fixed_medium.phosphorus += quantity_of_superba_czerwona_fertilizer * percent.superba_P;
  238. //azot
  239. fixed_medium.nitrogen += quantity_of_superba_czerwona_fertilizer * percent.superba_N;
  240. //potas
  241. fixed_medium.potassium += quantity_of_superba_czerwona_fertilizer * percent.superba_K;
  242. //magnez
  243. fixed_medium.magnesium += quantity_of_superba_czerwona_fertilizer * percent.superba_Mg;
  244. if (fixed_medium.potassium > desired_medium2.potassium ||
  245. fixed_medium.nitrogen > desired_medium2.nitrogen ||
  246. fixed_medium.magnesium > desired_medium2.magnesium)
  247. {
  248. cout << "\n\n------------\n\tUzycie superby czerwonej niemozliwe, poniewaz jej uzycie " << endl;
  249. cout << "\tspowoduje przekroczenie dopuszczalnej ilosci";
  250.  
  251. if (fixed_medium.potassium > desired_medium2.potassium)
  252. {
  253. cout << "\n\tpotasu o " << fixed_medium.potassium - desired_medium2.potassium << endl;
  254. cout << "\t-> Aktualna ilosc potasu\t" << fixed_medium.potassium << endl;
  255. cout << "\t-> Pozadana ilosc potasu\t" << desired_medium2.potassium << endl;
  256. }
  257. if (fixed_medium.nitrogen > desired_medium2.nitrogen)
  258. {
  259. cout << "\n\tazotu o " << fixed_medium.nitrogen - desired_medium2.nitrogen << endl;
  260. cout << "\t-> Aktualna ilosc azotu\t\t" << fixed_medium.nitrogen << endl;
  261. cout << "\t-> Pozadana ilosc azotu\t\t" << desired_medium2.nitrogen << endl;
  262. }
  263. if (fixed_medium.magnesium > desired_medium2.magnesium)
  264. {
  265. cout << "\n\tmagnezu o " << fixed_medium.magnesium - desired_medium2.magnesium << endl;
  266. cout << "\t-> Aktualna ilosc magnezu\t" << fixed_medium.magnesium << endl;
  267. cout << "\t-> Pozadana ilosc magnezu\t" << desired_medium2.magnesium << endl;
  268. }
  269.  
  270. //odwracanie skutkow poprzedniej operacji
  271. //fosfor
  272. fixed_medium.phosphorus -= quantity_of_superba_czerwona_fertilizer * percent.superba_P;
  273. //azot
  274. fixed_medium.nitrogen -= quantity_of_superba_czerwona_fertilizer * percent.superba_N;
  275. //potas
  276. fixed_medium.potassium -= quantity_of_superba_czerwona_fertilizer * percent.superba_K;
  277. //magnez
  278. fixed_medium.magnesium -= quantity_of_superba_czerwona_fertilizer * percent.superba_Mg;
  279. //wyzerowanie ilosci superby - teraz, bo inaczej powyzsze przeliczniki nie mialyby sensu
  280. quantity_of_superba_czerwona_fertilizer = 0;
  281. fertilizer_quantity[counter] = quantity_of_superba_czerwona_fertilizer;
  282. }
  283.  
  284. //test
  285. //cout << "\ntest\t\tSuperba czerwona" << endl;
  286. //cout << "fixed_medium.nitrogen\t\t" << fixed_medium.nitrogen << endl;
  287. //cout << "fixed_medium.phosphorus\t\t" << fixed_medium.phosphorus << endl;
  288. //cout << "fixed_medium.potassium\t\t" << fixed_medium.potassium << endl;
  289. //cout << "fixed_medium.calcium\t\t" << fixed_medium.calcium << endl;
  290. //cout << "fixed_medium.magnesium\t\t" << fixed_medium.magnesium << endl;
  291. //_getch();
  292. #pragma endregion
  293.  
  294. #pragma region Fosforan_potasu
  295.  
  296. ++counter;
  297. //fosforan potasu - fosfor (100%) i potas
  298. ld quantity_of_potassium_phosphate_fertilizer = (desired_medium2.phosphorus - fixed_medium.phosphorus) / percent.potassium_phosphate_P;
  299. fertilizer_name[counter] = "Fosforan potasu\t\t\t";
  300. fertilizer_quantity[counter] = quantity_of_potassium_phosphate_fertilizer;
  301. fertilizer_EC[counter] = percent.potassium_phosphate_EC;
  302. ktory_zbiornik[counter] = ZBIORNIK_B;
  303. //fosfor
  304. fixed_medium.phosphorus += quantity_of_potassium_phosphate_fertilizer * percent.potassium_phosphate_P;
  305. //potas
  306. fixed_medium.potassium += quantity_of_potassium_phosphate_fertilizer * percent.potassium_phosphate_K;
  307. //ok
  308. //test
  309. //cout << "\ntest\t\tFosforan potasu" << endl;
  310. //cout << "fixed_medium.nitrogen\t\t" << fixed_medium.nitrogen << endl;
  311. //cout << "fixed_medium.phosphorus\t\t" << fixed_medium.phosphorus << endl;
  312. //cout << "fixed_medium.potassium\t\t" << fixed_medium.potassium << endl;
  313. //cout << "fixed_medium.calcium\t\t" << fixed_medium.calcium << endl;
  314. //cout << "fixed_medium.magnesium\t\t" << fixed_medium.magnesium << endl;
  315. //_getch();
  316. #pragma endregion
  317.  
  318. #pragma region Saletra_magnezowa
  319.  
  320. ++counter;
  321. //saletra magnezowa - azot (100%) i magnez
  322. ld quantity_of_magnesium_nitrate_fertilizer = (desired_medium2.nitrogen - fixed_medium.nitrogen) / percent.magnesium_nitrate_N;
  323. fertilizer_name[counter] = "Saletra magnezowa\t\t";
  324. fertilizer_quantity[counter] = quantity_of_magnesium_nitrate_fertilizer;
  325. fertilizer_EC[counter] = percent.magnesium_nitrate_EC;
  326. ktory_zbiornik[counter] = ZBIORNIK_A;
  327. //azot
  328. fixed_medium.nitrogen += quantity_of_magnesium_nitrate_fertilizer * percent.magnesium_nitrate_N;
  329. //magnez
  330. fixed_medium.magnesium += quantity_of_magnesium_nitrate_fertilizer * percent.magnesium_nitrate_Mg;
  331. //sprawdz czy wartosc magnezu nie zostala przekroczona
  332. if (fixed_medium.magnesium > desired_medium2.magnesium)
  333. {
  334. //odejmij dwa powyzsze wyniki: -= zamiast +=
  335. //azot
  336. fixed_medium.nitrogen -= quantity_of_magnesium_nitrate_fertilizer * percent.magnesium_nitrate_N;
  337. //magnez
  338. fixed_medium.magnesium -= quantity_of_magnesium_nitrate_fertilizer * percent.magnesium_nitrate_Mg;
  339.  
  340. //saletra magnezowa - magnez (100%) i azot
  341. ld quantity_of_magnesium_nitrate_fertilizer = (desired_medium2.magnesium - fixed_medium.magnesium) / percent.magnesium_nitrate_Mg;
  342. fertilizer_name[counter] = "Saletra magnezowa\t\t";
  343. fertilizer_quantity[counter] = quantity_of_magnesium_nitrate_fertilizer;
  344. //magnez
  345. fixed_medium.magnesium += quantity_of_magnesium_nitrate_fertilizer * percent.magnesium_nitrate_Mg;
  346. //azot
  347. fixed_medium.nitrogen += quantity_of_magnesium_nitrate_fertilizer * percent.magnesium_nitrate_N;
  348. }
  349.  
  350. //test
  351. //cout << "\ntest\t\tSaletra magnezowa" << endl;
  352. //cout << "fixed_medium.nitrogen\t\t" << fixed_medium.nitrogen << endl;
  353. //cout << "fixed_medium.phosphorus\t\t" << fixed_medium.phosphorus << endl;
  354. //cout << "fixed_medium.potassium\t\t" << fixed_medium.potassium << endl;
  355. //cout << "fixed_medium.calcium\t\t" << fixed_medium.calcium << endl;
  356. //cout << "fixed_medium.magnesium\t\t" << fixed_medium.magnesium << endl;
  357. //_getch();
  358. #pragma endregion
  359.  
  360. #pragma region Saletra_potasowa
  361. ++counter;
  362. //potassium nitrate, saletra potasowa - azot 100% + potas
  363. ld quantity_of_potassium_nitrate_fertilizer = (desired_medium2.nitrogen - fixed_medium.nitrogen) / percent.potassium_nitrate_N;
  364. fertilizer_name[counter] = "Saletra potasowa\t\t";
  365. fertilizer_quantity[counter] = quantity_of_potassium_nitrate_fertilizer;
  366. fertilizer_EC[counter] = percent.potassium_nitrate_EC;
  367. ktory_zbiornik[counter] = ZBIORNIK_A;
  368. //azot
  369. fixed_medium.nitrogen += quantity_of_potassium_nitrate_fertilizer * percent.potassium_nitrate_N;
  370. //potas
  371. fixed_medium.potassium += quantity_of_potassium_nitrate_fertilizer * percent.potassium_nitrate_K;
  372. //ok
  373. if (fixed_medium.potassium > desired_medium2.potassium)
  374. {
  375. //odejmij dwa powyzsze wyniki: -= zamiast +=
  376. fixed_medium.nitrogen -= quantity_of_potassium_nitrate_fertilizer * percent.potassium_nitrate_N;
  377. //potas
  378. fixed_medium.potassium -= quantity_of_potassium_nitrate_fertilizer * percent.potassium_nitrate_K;
  379.  
  380. //potassium nitrate, saletra potasowa - potas 100% + azot
  381. ld quantity_of_potassium_nitrate_fertilizer = (desired_medium2.potassium - fixed_medium.potassium) / percent.potassium_nitrate_K;
  382. fertilizer_name[counter] = "Saletra potasowa\t\t";
  383. fertilizer_quantity[counter] = quantity_of_potassium_nitrate_fertilizer;
  384. //potas
  385. fixed_medium.potassium += quantity_of_potassium_nitrate_fertilizer * percent.potassium_nitrate_K;
  386. //azot
  387. fixed_medium.nitrogen += quantity_of_potassium_nitrate_fertilizer * percent.potassium_nitrate_N;
  388. }
  389. //test
  390. //cout << "\ntest\t\tSaletra potasowa" << endl;
  391. //cout << "fixed_medium.nitrogen\t\t" << fixed_medium.nitrogen << endl;
  392. //cout << "fixed_medium.phosphorus\t\t" << fixed_medium.phosphorus << endl;
  393. //cout << "fixed_medium.potassium\t\t" << fixed_medium.potassium << endl;
  394. //cout << "fixed_medium.calcium\t\t" << fixed_medium.calcium << endl;
  395. //cout << "fixed_medium.magnesium\t\t" << fixed_medium.magnesium << endl;
  396. //_getch();
  397. #pragma endregion
  398.  
  399. #pragma region Siarczan_potasu
  400.  
  401. //jezeli brakuje jeszcze potasu, uzupelnij go
  402. if (fixed_medium.potassium < desired_medium2.potassium)
  403. {
  404. ++counter;
  405. //potassium sulfate, siarczan potasu - potas 100% + siarczany
  406. ld quantity_of_potassium_sulfate_fertilizer = (desired_medium2.potassium - fixed_medium.potassium) / percent.potassium_sulfate_K;
  407. fertilizer_name[counter] = "Siarczan potasu\t\t\t";
  408. fertilizer_quantity[counter] = quantity_of_potassium_sulfate_fertilizer;
  409. fertilizer_EC[counter] = percent.potassium_sulfate_EC;
  410. ktory_zbiornik[counter] = ZBIORNIK_B;
  411. //potas
  412. fixed_medium.potassium += quantity_of_potassium_sulfate_fertilizer * percent.potassium_sulfate_K;
  413. //siarczany
  414. fixed_medium.sulfur += quantity_of_potassium_sulfate_fertilizer * percent.potassium_sulfate_S;
  415. }
  416. //test
  417. //cout << "\ntest\t\tSiarczan potasu" << endl;
  418. //cout << "fixed_medium.nitrogen\t\t" << fixed_medium.nitrogen << endl;
  419. //cout << "fixed_medium.phosphorus\t\t" << fixed_medium.phosphorus << endl;
  420. //cout << "fixed_medium.potassium\t\t" << fixed_medium.potassium << endl;
  421. //cout << "fixed_medium.calcium\t\t" << fixed_medium.calcium << endl;
  422. //cout << "fixed_medium.magnesium\t\t" << fixed_medium.magnesium << endl;
  423. //_getch();
  424. #pragma endregion
  425.  
  426. #pragma region Siarczan_magnezu
  427.  
  428. //jezeli brakuje jeszcze magnezu, uzupelnij go
  429. if (fixed_medium.magnesium < desired_medium2.magnesium)
  430. {
  431. ++counter;
  432. //siarczan magnezu - magnez (100%) i siarczany
  433. ld quantity_of_magnesium_sulfate_fertilizer = (desired_medium2.magnesium - fixed_medium.magnesium) / percent.magnesium_sulfate_Mg;
  434. fertilizer_name[counter] = "Siarczan magnezu\t\t";
  435. fertilizer_quantity[counter] = quantity_of_magnesium_sulfate_fertilizer;
  436. fertilizer_EC[counter] = percent.magnessium_sulfate_EC;
  437. ktory_zbiornik[counter] = ZBIORNIK_B;
  438. //magnez
  439. fixed_medium.magnesium += quantity_of_magnesium_sulfate_fertilizer * percent.magnesium_sulfate_Mg;
  440. //siarczany
  441. fixed_medium.sulfur += quantity_of_magnesium_sulfate_fertilizer * percent.magnesium_sulfate_S;
  442. }
  443. //test
  444. //cout << "\ntest\t\tSiarczan magnezu" << endl;
  445. //cout << "fixed_medium.nitrogen\t\t" << fixed_medium.nitrogen << endl;
  446. //cout << "fixed_medium.phosphorus\t\t" << fixed_medium.phosphorus << endl;
  447. //cout << "fixed_medium.potassium\t\t" << fixed_medium.potassium << endl;
  448. //cout << "fixed_medium.calcium\t\t" << fixed_medium.calcium << endl;
  449. //cout << "fixed_medium.magnesium\t\t" << fixed_medium.magnesium << endl;
  450. //_getch();
  451. #pragma endregion
  452.  
  453. //109 nie ma mikroelementow, bo nie wiem skad je wziac
  454.  
  455. cout << "\n\n------------\n\tPodsumowanie wartosci skladnikow w mg/dm^3\n\tPozywka poczatkowa \\ Pozywka pozadana \\ Pozywka ustalona" << endl;
  456. cout << "\tAzot\t\t" << Initial_medium2.nitrogen << "\t" << desired_medium2.nitrogen << "\t" << fixed_medium.nitrogen << endl;
  457. cout << "\tFosfor\t\t" << Initial_medium2.phosphorus << "\t" << desired_medium2.phosphorus << "\t" << fixed_medium.phosphorus << endl;
  458. cout << "\tPotas\t\t" << Initial_medium2.potassium << "\t" << desired_medium2.potassium << "\t" << fixed_medium.potassium << endl;
  459. cout << "\tWapn\t\t" << Initial_medium2.calcium << "\t" << desired_medium2.calcium << "\t" << fixed_medium.calcium << endl;
  460. cout << "\tMagnez\t\t" << Initial_medium2.magnesium << "\t" << desired_medium2.magnesium << "\t" << fixed_medium.magnesium << endl;
  461. //cout << "\tChlor\t\t" << Initial_medium2.chlorine << "\t" << desired_medium2.chlorine << "\t" << fixed_medium.chlorine << endl;
  462. cout << "\tSiarczany\t" << Initial_medium2.sulfur << "\t" << desired_medium2.sulfur << "\t" << fixed_medium.sulfur << endl;
  463. // ponieważ zneutralizowane cout << "\tWeglany\t\t" << Initial_medium2.carbonates << "\t" << desired_medium2.carbonates << "\t" << fixed_medium.carbonates << endl;
  464. cout << "\tSod\t\t" << Initial_medium2.sodium << "\t" << desired_medium2.sodium << "\t" << fixed_medium.sodium << endl;
  465. cout << "\tZelazo\t\t" << Initial_medium2.iron << "\t" << desired_medium2.iron << "\t" << fixed_medium.iron << endl;
  466. cout << "\tBor\t\t" << Initial_medium2.boron << "\t" << desired_medium2.boron << "\t" << fixed_medium.boron << endl;
  467. cout << "\tCynk\t\t" << Initial_medium2.zinc << "\t" << desired_medium2.zinc << "\t" << fixed_medium.zinc << endl;
  468. cout << "\tMangan\t\t" << Initial_medium2.manganese << "\t" << desired_medium2.manganese << "\t" << fixed_medium.manganese << endl;
  469. cout << "\tMiedz\t\t" << Initial_medium2.copper << "\t" << desired_medium2.copper << "\t" << fixed_medium.copper << endl;
  470. cout << "\tMolibden\t" << Initial_medium2.molybdenum << "\t" << desired_medium2.molybdenum << "\t" << fixed_medium.molybdenum << endl;
  471. //cout << "\tpH\t\t" << Initial_medium2.pH << "\t" << desired_medium2.pH << "\t" << fixed_medium.pH << endl;
  472. //cout << "\tEC\t\t" << Initial_medium2.EC << "\t" << desired_medium2.EC << "\t" << fixed_medium.EC << endl;
  473.  
  474.  
  475. ofstream write_data;
  476. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::app);
  477.  
  478. write_data << "\n\n------------\n\tPodsumowanie wartosci skladnikow w mg/dm^3\n\tPozywka poczatkowa \\ Pozywka pozadana \\ Pozywka ustalona" << endl;
  479. write_data << "\tAzot\t\t" << Initial_medium2.nitrogen << "\t" << desired_medium2.nitrogen << "\t" << fixed_medium.nitrogen << endl;
  480. write_data << "\tFosfor\t\t" << Initial_medium2.phosphorus << "\t" << desired_medium2.phosphorus << "\t" << fixed_medium.phosphorus << endl;
  481. write_data << "\tPotas\t\t" << Initial_medium2.potassium << "\t" << desired_medium2.potassium << "\t" << fixed_medium.potassium << endl;
  482. write_data << "\tWapn\t\t" << Initial_medium2.calcium << "\t" << desired_medium2.calcium << "\t" << fixed_medium.calcium << endl;
  483. write_data << "\tMagnez\t\t" << Initial_medium2.magnesium << "\t" << desired_medium2.magnesium << "\t" << fixed_medium.magnesium << endl;
  484. //cout << "\tChlor\t\t" << Initial_medium2.chlorine << "\t" << desired_medium2.chlorine << "\t" << fixed_medium.chlorine << endl;
  485. write_data << "\tSiarczany\t" << Initial_medium2.sulfur << "\t" << desired_medium2.sulfur << "\t" << fixed_medium.sulfur << endl;
  486. // ponieważ zneutralizowane cout << "\tWeglany\t\t" << Initial_medium2.carbonates << "\t" << desired_medium2.carbonates << "\t" << fixed_medium.carbonates << endl;
  487. write_data << "\tSod\t\t" << Initial_medium2.sodium << "\t" << desired_medium2.sodium << "\t" << fixed_medium.sodium << endl;
  488. write_data << "\tZelazo\t\t" << Initial_medium2.iron << "\t" << desired_medium2.iron << "\t" << fixed_medium.iron << endl;
  489. write_data << "\tBor\t\t" << Initial_medium2.boron << "\t" << desired_medium2.boron << "\t" << fixed_medium.boron << endl;
  490. write_data << "\tCynk\t\t" << Initial_medium2.zinc << "\t" << desired_medium2.zinc << "\t" << fixed_medium.zinc << endl;
  491. write_data << "\tMangan\t\t" << Initial_medium2.manganese << "\t" << desired_medium2.manganese << "\t" << fixed_medium.manganese << endl;
  492. write_data << "\tMiedz\t\t" << Initial_medium2.copper << "\t" << desired_medium2.copper << "\t" << fixed_medium.copper << endl;
  493. write_data << "\tMolibden\t" << Initial_medium2.molybdenum << "\t" << desired_medium2.molybdenum << "\t" << fixed_medium.molybdenum << endl;
  494.  
  495. write_data.close();
  496.  
  497. cout << "\n\n------------\n\tAby uzyskac wartosci skladnikow podanych powyzej jako \n\t\"pozywka ustalona\", nalezy wprowadzic nastepujace ilosci nawozow:" << endl;
  498. cout << "\n\tJednostka:\tmiligramy na litr [mg/dm^3]" << endl;
  499. for (int a = 0; a <= counter; ++a)
  500. {
  501. cout << "\t" << fertilizer_name[a] << fertilizer_quantity[a] << " mg/l" << endl;
  502. }
  503. cout << "\n\n------------\n" << endl;
  504.  
  505. //zamiana z miligramow na gramy
  506. for (int a = 0; a <= counter; ++a)
  507. {
  508. fertilizer_quantity[a] /= 1000;
  509. }
  510. //cout i ofstream
  511. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::app);
  512.  
  513. cout << "\n\n\tJednostka:\tgramy na litr [g/dm^3]" << endl;
  514. write_data << "\n\n------------\n\tJednostka:\tgramy na litr [g/dm^3]" << endl;
  515. for (int a = 0; a <= counter; ++a)
  516. {
  517. cout << "\t" << fertilizer_name[a] << fertilizer_quantity[a] << " g/l" << endl;
  518. write_data << "\t" << fertilizer_name[a] << fertilizer_quantity[a] << " g/l" << endl;
  519. }
  520. write_data.close();
  521.  
  522. //przeliczanie EC dla kazdego nawozu, uwzgledniajac ilosc wprowadzonych gramow
  523. ld suma = 0;
  524. for (int a = 0; a <= counter; ++a)
  525. {
  526. suma += fertilizer_quantity[a] * fertilizer_EC[a];
  527. }
  528. cout << "\n\n------------\n" << endl;
  529. cout << "\tSuma EC wprowadzonych nawozow:\t" << suma << " mS/cm^2" << endl;
  530. fixed_medium.EC += suma;
  531. cout << "\tSuma EC calej pozywki:\t\t" << fixed_medium.EC << " mS/cm^2" << endl;
  532.  
  533. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::app);
  534. write_data << "\n\n------------\n" << endl;
  535. write_data << "\tSuma EC wprowadzonych nawozow:\t" << suma << " mS/cm^2" << endl;
  536. write_data << "\tSuma EC calej pozywki:\t\t" << fixed_medium.EC << " mS/cm^2" << endl;
  537. write_data.close();
  538.  
  539. #pragma region A_BARREL
  540. cout << "\n------------\n" << endl;
  541. cout << "\n\tPodaj pojemnosc beczki A w litrach (nawozy wapniowe): ";
  542. double volumeA;
  543. cin >> volumeA;
  544. cin.sync();
  545. cin.clear();
  546.  
  547. cout << "\tPodaj zatezenie nawozow w beczce A: ";
  548. double concentrationA;
  549. cin >> concentrationA;
  550. cin.sync();
  551. cin.clear();
  552.  
  553. //obliczenia tylko dla zbiornika A = 1
  554. //pętla która przerobi wszystkie nawozy, zależna od var counter
  555. for (int a = 0; a <= counter; ++a)
  556. {
  557. //warunek przepusci tyko te, ktorych wartosc jest rowna 1, czyli nawozy przypisane
  558. if (ktory_zbiornik[a] == 1)
  559. {
  560. fertilizer_quantity[a] = fertilizer_quantity[a] * volumeA * concentrationA;
  561. }
  562. }
  563.  
  564. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::app);
  565. cout << "\n\tDo beczki A o pojemnosci " << volumeA << " litrow \n\ti o zatezeniu " << concentrationA << "x nalezy wsypac " << endl;
  566. write_data << "\n------------\n\tDo beczki A o pojemnosci " << volumeA << " litrow \n\ti o zatezeniu " << concentrationA << "x nalezy wsypac " << endl;
  567. for (int a = 0; a <= counter; ++a)
  568. {
  569. if (ktory_zbiornik[a] == 1)
  570. {
  571. cout << "\t\t" << fertilizer_name[a] << "" << (fertilizer_quantity[a] / 1000) << " kg" << endl;
  572. write_data << "\t\t" << fertilizer_name[a] << "" << (fertilizer_quantity[a] / 1000) << " kg" << endl;
  573. }
  574. }
  575. write_data.close();
  576.  
  577. #pragma endregion
  578.  
  579. #pragma region B_BARREL
  580. cout << "\n------------\n" << endl;
  581. cout << "\n\tPodaj pojemnosc beczki B w litrach (fosforany i siarczany): ";
  582. double volumeB;
  583. cin >> volumeB;
  584. cin.sync();
  585. cin.clear();
  586.  
  587. cout << "\tPodaj zatezenie nawozow w beczce B: ";
  588. double concentrationB;
  589. cin >> concentrationB;
  590. cin.sync();
  591. cin.clear();
  592.  
  593. //obliczenia tylko dla zbiornika B = 2
  594. //pętla która przerobi wszystkie nawozy, zależna od var counter
  595. for (int a = 0; a <= counter; ++a)
  596. {
  597. //warunek przepusci tyko te, ktorych wartosc jest rowna 2, czyli nawozy przypisane
  598. if (ktory_zbiornik[a] == 2)
  599. {
  600. fertilizer_quantity[a] = fertilizer_quantity[a] * volumeB * concentrationB;
  601. }
  602. }
  603.  
  604. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::app);
  605. cout << "\n\tDo beczki B o pojemnosci " << volumeB << " litrow \n\ti o zatezeniu " << concentrationB << "x nalezy wsypac " << endl;
  606. write_data << "\n\tDo beczki B o pojemnosci " << volumeB << " litrow \n\ti o zatezeniu " << concentrationB << "x nalezy wsypac " << endl;
  607. for (int a = 0; a <= counter; ++a)
  608. {
  609. if (ktory_zbiornik[a] == 2)
  610. {
  611. cout << "\t\t" << fertilizer_name[a] << "" << (fertilizer_quantity[a] / 1000) << " kg" << endl;
  612. write_data << "\t\t" << fertilizer_name[a] << "" << (fertilizer_quantity[a] / 1000) << " kg" << endl;
  613. }
  614. }
  615. write_data.close();
  616.  
  617. #pragma endregion
  618.  
  619. #pragma region C_BARREL
  620. cout << "\n------------\n\tPodaj pojemnosc beczki C w litrach (kwas azotowy): ";
  621. double volumeC;
  622. cin >> volumeC;
  623. cin.sync();
  624. cin.clear();
  625.  
  626. cout << "\tPodaj zatezenie kwasu w beczce C: ";
  627. double concentrationC;
  628. cin >> concentrationC;
  629. cin.sync();
  630. cin.clear();
  631.  
  632. dawka_kwasu = (dawka_kwasu * volumeC * concentrationC) / 1000; //z cm^3 na dm^3
  633. cout << "\n\tDo beczki C o pojemnosci " << volumeC << " litrow \n\ti o zatezeniu " << concentrationC << "x nalezy wlac\t\t" << dawka_kwasu << " dm^3 kwasu" << endl;
  634.  
  635. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::app);
  636. write_data << "\n\tDo beczki C o pojemnosci " << volumeC << " litrow \n\ti o zatezeniu " << concentrationC << "x nalezy wlac\t\t" << dawka_kwasu << " dm^3 kwasu" << endl;
  637. write_data.close();
  638. #pragma endregion
  639.  
  640. //dotąd, wszystko jest w porządku, 22:24, 8 lipiec 2015
  641.  
  642.  
  643. //napisy końcowe
  644. cout << "\n------------\n\tProgram automatycznie utworzy oraz zapisze dane do pliku tekstowego" << endl;
  645. cout << "\tNacisnij dowolny klawisz, aby zamknac";
  646. _getch();
  647. }
  648.  
  649. MEDIUM loadDesiredMedium()
  650. {
  651. //108 usunąć lub skomentować wartości do testów
  652. MEDIUM desired_medium = { 0 };
  653. //usunac przed oddaniem programu, nie chce mi sie wpisywac caly czas te wartosci
  654. //0.02 to najmniejsza dopuszczalna wartosc
  655.  
  656. //1azot 2fosfor 3potas 4wapn 5magnez 6chlor 7siarczany 8weglany 9sod 10zelazo 11bor 12cynk 13mangan 14miedz 15molibden 16odczyn 17EC
  657. //mininum desired medium
  658. //desired_medium = { 200, 40, 200, 160, 30, 50, 180, 50, 0, 0.7, 0.3, 0.26, 0.1, 0.03, 0.03, 5.5, 3.0 };
  659. //maximum desired medium
  660. //desired_medium = { 410, 60, 400, 500, 140, 50, 180, 50, 0, 2.5, 1.0, 0.78, 0.9, 0.15, 0.21, 5.5, 3.0 };
  661.  
  662.  
  663. //wersja z moich notatek
  664. //desired_medium = { 230, 50, 230, 190, 60, 0.02, 0.02, 220.0, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 4, 0.5 };
  665.  
  666.  
  667. //wersja kowalskiej - brak (podala tylko ile jej woda zrodlana ma zwykle jonow)
  668.  
  669. //wersja metodyki
  670. //desired_medium = { 220, 60, 340, 210, 70, 50, 180 /*<180*/, 50, 0 /*zawartosc Na bez zmian*/, 2.5, 0.33, 0.33, 0.8, 0.15, 0.05, 5.5/*odczyn ma wynosic 5.5 zawsze po traktowaniu kwasem*/, 3.0 };
  671.  
  672. cout << "\n------------\n\tWprowadz pozadane wartosci skladnikow pokarmowych\n\tktore maja znajdowac sie w pozywce" << endl;
  673. cout << "\tAzot:\t\t";
  674. cin >> desired_medium.nitrogen;
  675. cin.sync();
  676. cout << "\tFosfor:\t\t";
  677. cin >> desired_medium.phosphorus;
  678. cin.sync();
  679. cout << "\tPotas:\t\t";
  680. cin >> desired_medium.potassium;
  681. cin.sync();
  682. cout << "\tWapn:\t\t";
  683. cin >> desired_medium.calcium;
  684. cin.sync();
  685. cout << "\tMagnez:\t\t";
  686. cin >> desired_medium.magnesium;
  687. cin.sync();
  688. //cout << "\tChlor:\t\t";
  689. //cin >> desired_medium.chlorine;
  690. //cin.sync();
  691. //cout << "\tSiarczany:\t";
  692. //cin >> desired_medium.sulfur;
  693. //cin.sync();
  694. //cout << "\tWeglany:\t";
  695. //cin >> desired_medium.carbonates;
  696. //cin.sync();
  697. //cout << "\tSod:\t\t";
  698. //cin >> desired_medium.sodium;
  699. //cin.sync();
  700. //cout << "\tZelazo:\t\t";
  701. //cin >> desired_medium.iron;
  702. //cin.sync();
  703. //cout << "\tBor:\t\t";
  704. //cin >> desired_medium.boron;
  705. //cin.sync();
  706. //cout << "\tCynk:\t\t";
  707. //cin >> desired_medium.zinc;
  708. //cin.sync();
  709. //cout << "\tMangan:\t\t";
  710. //cin >> desired_medium.manganese;
  711. //cin.sync();
  712. //cout << "\tMiedz:\t\t";
  713. //cin >> desired_medium.copper;
  714. //cin.sync();
  715. //cout << "\tMolibden:\t";
  716. //cin >> desired_medium.molybdenum;
  717. //cin.sync();
  718.  
  719.  
  720. //cout << "\tpH:\t\t";
  721. //cin >> desired_medium.pH;
  722. //cin.sync();
  723. //cout << "\tEC:\t\t";
  724. //cin >> desired_medium.EC;
  725. //cin.sync();
  726.  
  727. return desired_medium;
  728. }
  729.  
  730. ld nitrogen_introduced_f(ld dk, ld quantityOfNitrogenIn1dm4)
  731. {
  732. /*
  733. uwaga, poniewaz zastosowano kwas % wagowo 63.23%, co odpowiada 195.36 mg czystego N w 1cm^3 kwasu,
  734. bedzie to stala - ale w przyszlosci ew. moze byc wsadzona do tablicy typu struct
  735.  
  736.  
  737. */
  738.  
  739. //105, w zależności od wcześniej wybranego stężenia kwasu azotowego, przesłać tutaj (do tej funkcji) dane, jakiej ilości azotu odpowiada to
  740.  
  741. //103
  742. //const double mgNin1cm3ofAcid = 195.36; //mg N w 1cm^3 kwasu WYŁĄCZNIE dla 63.23% wagowo kwasu //106
  743. const int oneCm3ofAcid = 1; //1cm^3 HNO
  744. //tak wiem, moglem po prostu 1, ale magic numbers
  745.  
  746. ld nitrogen_introduced = (dk * quantityOfNitrogenIn1dm4) / oneCm3ofAcid;
  747.  
  748. ofstream write_data;
  749. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::app);
  750.  
  751. cout << "\n\n------------\n\tAzot wprowadzony wraz z kwasem azotowym = " << nitrogen_introduced << "mg / dm^3" << endl;
  752. write_data << "\n\n------------\n\tAzot wprowadzony wraz z kwasem azotowym = " << nitrogen_introduced << "mg / dm^3" << endl;
  753.  
  754. write_data.close();
  755.  
  756.  
  757. return nitrogen_introduced;
  758. }
  759.  
  760. ld acid_dose(ld W, double weglany, ld &dawka_kwasu) //ten 3 argument to brzydkie rozwiazanie.. ale koniecznosc, bo musze miec ta wartosc gdzies indziej
  761. {
  762. /*
  763. dawka kwasu (dk) = (((ilość_węglanów : 61) - 0.7) * W) 1000
  764. cout << DK << " cm^3 / dm^3" << endl;
  765.  
  766.  
  767. 61 - magic number
  768. */
  769. const int magic_number = 61;
  770. const double cNumber = 0.7; //milimole HCO3- pozostawione w wodzie dla roslin
  771. const int cNumber2 = 1000;
  772.  
  773. ld dk = (((weglany / magic_number) - cNumber) * W) / cNumber2; //104
  774.  
  775. ofstream write_data;
  776. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::app);
  777.  
  778. cout << "\n\n------------\n\tDawka kwasu = " << dk << "cm^3 / dm^3" << endl;
  779. write_data << "\n\n------------\n\tDawka kwasu = " << dk << "cm^3 / dm^3" << endl;
  780.  
  781. write_data.close();
  782.  
  783. dawka_kwasu = dk;
  784. return dk;
  785. //ok
  786. }
  787.  
  788. ld acid_ratio(double weglany, ld &quantityOfNitrogenIn1dm4) //wspolczynnik przeliczeniowy dla kwasu
  789. {
  790. const int ilosc_elementow_kolumny = 14;
  791. const int ilosc_kolumn = 5;
  792. ld tabela[ilosc_kolumn][ilosc_elementow_kolumny] =
  793. {
  794. //"procent_wagowy" kwas azotowy HNO3 w % wagowym
  795. { 20.23, 30.88, 32.36, 35.28, 36.78, 38.29, 50.71, 57.57, 59.39, 61.27, 63.23, 65.30, 67.50, 69.80 },
  796. //"gestosc_kwasu" gestosc kwasu (symbol d w przeliczeniach) w 15 stopniach celsjusza, w gramach na cm^3
  797. { 1.120, 1.190, 1.200, 1.220, 1.230, 1.240, 1.320, 1.360, 1.370, 1.380, 1.390, 1.400, 1.410, 1.420 },
  798. //"ilosc_miligramow" azotu w 1cm^3 kwasu
  799. { 50.36, 81.68, 86.32, 95.67, 100.56, 148.79, 174.04, 180.86, 187.95, 195.36, 203.21, 211.56, 220.32 },
  800. //ilosc kwasu w cm3 potrzebna do uzyskania stezenia 1mg N/dm3 w
  801. //1dm3 wody
  802. { 0.0199, 0.0122, 0.0116, 0.0105, 0.0099, 0.0095, 0.0067, 0.0057, 0.0055, 0.0053, 0.0051, 0.0049, 0.0047, 0.0045 },
  803. //1000dm3 wody
  804. { 19.86, 12.24, 11.59, 10.45, 0.94, 9.48, 6.72, 5.75, 5.53, 5.32, 5.12, 4.92, 4.73, 4.54 }
  805. };
  806. const int procent_wagowy = 0;
  807. const int gestosc_kwasu = 1;
  808. const int ilosc_miligramow = 2;
  809. /*kolejne kolumny niedostepne - i tak nie beda potrzebne w obliczeniach*/
  810.  
  811. //program prosi usera o podanie % wagowego kwasu azotowego
  812. cout << "\n\n------------\n\tWprowadzanie % wagowego kwasu azotowego" << endl;
  813. cout << "\tNalezy wprowadzic wartosci podane z ponizszych " << endl;
  814. cout << "\t20.23, 30.88, 32.36, 35.28, 36.78, 38.29, 50.71, \n\t57.57, 59.39, 61.27, 63.23, 65.30, 67.50, 69.80" << endl;
  815. cout << "\tNalezy pamietac o podaniu cyfr z kropka (nie przecinkiem)" << endl;
  816.  
  817. // [odkomentowac]
  818. ld choice;
  819. bool is_input_correct = false;
  820. int index;
  821. do
  822. {
  823. cout << "\tWartosc: ";
  824. cin >> choice;
  825. for (index = 0; index <= ilosc_elementow_kolumny; ++index)
  826. {
  827. if (choice == tabela[procent_wagowy][index])
  828. {
  829. is_input_correct = true;
  830. break;
  831. }
  832. }
  833. if (is_input_correct == false)
  834. {
  835. cout << "\tW tabeli nie ma takiej wartosci. Podaj wartosc ponownie." << endl;
  836. }
  837. } while (!(is_input_correct));
  838.  
  839.  
  840. //cout << "is_input_correct\t\t" << is_input_correct << endl;
  841. //cout << "index\t\t" << index << endl;
  842. //cout << "tabela[procent_wagowy][index]\t\t" << tabela[procent_wagowy][index] << endl;
  843. //_getch();
  844. // [/odkomentowac]
  845.  
  846. //do funkcji jest przesylana np. 220mg HCO3- na 1 litr
  847. /*
  848. wzór
  849. W = a : b : d
  850. gdzie
  851. W - współczynnik przeliczeniowy dla kwasu
  852. a - ciężar cząsteczkowy HNO3 (63.01287g)
  853. b - procentowość wagowa HNO3 np. 63,23% zamieniamy na mozliwe do uzycia w obliczeniach 0,6323 (dzielimy przez 100)
  854. d - gęstość HNO3- w g*cm-3
  855. */
  856. const ld a = 63.01287; //stała, masa molowa HNO3 w gramach na 1 mol
  857. //wartosciami zmiennymi, mozliwymi do wyboru przez usera sa b i d
  858. ld b = ( tabela[procent_wagowy][index] / 100); //przelicznik z 63.23% na 0.6323
  859. ld d = tabela[gestosc_kwasu][index];
  860. //ld b = 0.6323; //101 //107
  861. //ld d = 1.390; //102
  862.  
  863. ld W = a / b / d;
  864.  
  865. ofstream write_data;
  866. write_data.open("wartosci liczbowe dla pozywki.txt", std::ios::out | std::ios::trunc);
  867.  
  868. cout << "\n\n------------\n\tStezenie kwasu wynosi " << (b *100) << " %"<< endl;
  869. write_data << "\n\n------------\n\tStezenie kwasu wynosi " << (b * 100) << " %" << endl;
  870.  
  871. cout << "\n\n------------\n\tWspolczynnik przeliczeniowy dla kwasu = " << W << endl;
  872. write_data << "\n\n------------\n\tWspolczynnik przeliczeniowy dla kwasu = " << W << endl;
  873.  
  874. write_data.close();
  875.  
  876. quantityOfNitrogenIn1dm4 = tabela[ilosc_miligramow][index];
  877.  
  878. return W;
  879. }
  880.  
  881. MEDIUM loadInitialMedium()
  882. {
  883. MEDIUM Initial_medium = { 0 };
  884. //usunac przed oddaniem programu, nie chce mi sie wpisywac caly czas te wartosci
  885.  
  886. //1azot 2fosfor 3potas 4wapn 5magnez 6chlor 7siarczany 8weglany 9sod 10zelazo 11bor 12cynk 13mangan 14miedz 15molibden 16odczyn 17EC
  887.  
  888. //minimum initial medium
  889. //Initial_medium = { 0, 0, 0, 75, 0, 0, 0, 210, 0, 0, 0, 0, 0, 0, 0, 7.5, 0.5 };
  890.  
  891. //maxium initial medium
  892. //Initial_medium = { 4, 0, 10, 150, 15, 23, 38, 230, 10, 0.1, 0.03, 0.2, 0.2, 0.2, 0.2, 8.0, 0.65 };
  893.  
  894.  
  895.  
  896. //wersja z moich notatek
  897. //Initial_medium = { 4, 0, 10, 75, 5, 0.02, 0.02, 220.0, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 7.5, 0.5 };
  898.  
  899. //wersja Kowalskiej
  900. //Initial_medium = { 4, 0, 8, 75, 10, 23, 12, 230.0 /*210-230*/, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 8.0, 0.5 };
  901.  
  902. //wersja metodyki
  903. //Initial_medium = { 0.28, 0.9, 2.37, 98, 14.5, 14, 38, 234, 10.1, 0.01, 0.03, 0.21, 0.01, 0.01, 0, 6.7, 0.65 };
  904.  
  905. cout << "\n\n------------\tWprowadz aktualne wartosci skladnikow pokarmowych \n\tznajdujacych sie w pozywce" << endl;
  906. cout << "\tAzot:\t\t";
  907. cin >> Initial_medium.nitrogen;
  908. cout << "\tFosfor:\t\t";
  909. cin >> Initial_medium.phosphorus;
  910. cout << "\tPotas:\t\t";
  911. cin >> Initial_medium.potassium;
  912. cout << "\tWapn:\t\t";
  913. cin >> Initial_medium.calcium;
  914. cout << "\tMagnez:\t\t";
  915. cin >> Initial_medium.magnesium;
  916. //cout << "\tChlor:\t\t";
  917. //cin >> Initial_medium.chlorine;
  918. //cout << "\tSiarczany:\t";
  919. //cin >> Initial_medium.sulfur;
  920. cout << "\tWeglany:\t";
  921. cin >> Initial_medium.carbonates;
  922. //cout << "\tSod:\t\t";
  923. //cin >> Initial_medium.sodium;
  924. //cout << "\tZelazo:\t\t";
  925. //cin >> Initial_medium.iron;
  926. //cout << "\tBor:\t\t";
  927. //cin >> Initial_medium.boron;
  928. //cout << "\tCynk:\t\t";
  929. //cin >> Initial_medium.zinc;
  930. //cout << "\tMangan:\t\t";
  931. //cin >> Initial_medium.manganese;
  932. //cout << "\tMiedz:\t\t";
  933. //cin >> Initial_medium.copper;
  934. //cout << "\tMolibden:\t";
  935. //cin >> Initial_medium.molybdenum;
  936. //cout << "\tpH:\t\t";
  937. //cin >> Initial_medium.pH;
  938. //cout << "\tEC:\t\t";
  939. //cin >> Initial_medium.EC;
  940.  
  941. return Initial_medium;
  942. }
  943.  
  944. bool maxForElements(MEDIUM Initial_medium2)
  945. {
  946. //1azot 2fosfor 3potas 4wapn 5magnez 6chlor 7siarczany 8weglany 9sod 10zelazo 11bor 12cynk 13mangan 14miedz 15molibden 16odczyn 17EC
  947. MEDIUM allowed_quantity = { 5, 5, 5, 120, 25, 100, 200, 350, 30, 5, 0.5, 0.5, 1.0, 0.2, 0.02, 7.5, 1.0 };
  948.  
  949. if (allowed_quantity.nitrogen < Initial_medium2.nitrogen)
  950. return false;
  951. if (allowed_quantity.phosphorus < Initial_medium2.phosphorus)
  952. return false;
  953. if (allowed_quantity.potassium < Initial_medium2.potassium)
  954. return false;
  955. if (allowed_quantity.calcium < Initial_medium2.calcium)
  956. return false;
  957. if (allowed_quantity.magnesium < Initial_medium2.magnesium)
  958. return false;
  959. if (allowed_quantity.chlorine < Initial_medium2.chlorine)
  960. return false;
  961. if (allowed_quantity.carbonates < Initial_medium2.carbonates)
  962. return false;
  963. if (allowed_quantity.sodium < Initial_medium2.sodium)
  964. return false;
  965. if (allowed_quantity.iron < Initial_medium2.iron)
  966. return false;
  967. if (allowed_quantity.boron < Initial_medium2.boron)
  968. return false;
  969. if (allowed_quantity.zinc < Initial_medium2.zinc)
  970. return false;
  971. if (allowed_quantity.manganese < Initial_medium2.manganese)
  972. return false;
  973. if (allowed_quantity.copper < Initial_medium2.copper)
  974. return false;
  975. if (allowed_quantity.molybdenum < Initial_medium2.molybdenum)
  976. return false;
  977. if (allowed_quantity.pH < Initial_medium2.pH)
  978. return false;
  979. if (allowed_quantity.EC < Initial_medium2.EC)
  980. return false;
  981.  
  982. //jezeli dojdziesz tutaj, zaden ze skladnikow lub wlasciwosci pozywki nie przekracza dopuszczalnej wartosci
  983. return true;
  984. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:20: fatal error: stdafx.h: No such file or directory
 #include "stdafx.h"
                    ^
compilation terminated.
stdout
Standard output is empty