Готовые отчеты / ЛиФП. Курсовая работа
.pdf4. Тестирование
Входные данные поступают с клавиатуры либо с CSV-файла, пример содержимого которого приведен в табл. 1.
Таблица 1 — Входные данные в файле (сверху) и описание столбцов (снизу)
P-5C;Piezotite;8;3;4;2;0.0126;-0.0047;-0.0053;0.0128;0.0316;-0.0001;0.00016;0.00027;1230;1550
P-5E;Piezotite;7.8;3;4;2;0.0124;-0.0041;-0.0052;0.0143;0.034;-0.0001;0.0002;0.0003;1490;1510
P-6C;Piezotite;7.7;3;4;2;0.0094;-0.003;-0.003;0.0103;0.0256;-8E-05;0.00019;0.00029;760;800
Название_пьезоматериала; Изготовитель_пьезоматериала; Плотность_пьезоматериала;
Номер elastic constants для ввода (CE=1, CD=2, SE=3, SD=4);
Номер piezoelectric constants для ввода (E=1, D=2, H=3, G=4);
Номер permittivities constants для ввода (ES=1, ET=2);
5 elastic constants;;;;;
3 piezoelectric constants;;;
2 permittivities constants;
Результаты тестирования представлены в табл. 2.
Таблица 2 — Результаты тестирования
Входные данные
P-5C;Piezotite;8;3;4;2;0.0126;-0.0047;-0.0053;0.0128;0.0316;-0.0001;0.00016;0.00027;1230;1550
P-5E;Piezotite;7.8;3;4;2;0.0124;-0.0041;-0.0052;0.0143;0.034;-0.0001;0.0002;0.0003;1490;1510
P-6C;Piezotite;7.7;3;4;2;0.0094;-0.003;-0.003;0.0103;0.0256;-8E-05;0.00019;0.00029;760;800
P-6E;Piezotite;7.6;3;4;2;0.0111;-0.0036;-0.0043;0.0127;0.03;-8E-05;0.00019;0.00028;1260;1380
P-6F;Piezotite;7.9;3;4;2;0.0134;-0.0048;-0.0054;0.0145;0.0342;-9E-05;0.0002;0.00029;1670;1780
P-7;Piezotite;7.8;3;4;2;0.0158;-0.0057;-0.007;0.0181;0.0406;-0.00011;0.00022;0.00032;1930;2100
P-7B;Piezotite;8;3;4;2;0.0167;-0.0059;-0.0075;0.0188;0.0388;-7E-05;0.00014;0.00021;3200;4720
PZT-5A;FEM;7.75;3;2;2;0.0164;-0.00574;-0.00722;0.0188;0.0475;-0.171;0.374;0.584;1730;1700
PMN-30PT;ATILA;8;3;2;2;0.052;-0.0189;-0.0311;0.677;0.14;-0.921;1.981;0.191;2926;1104
Material 38;FEMP;8;1;1;1;122.74;91.034;82.098;116.25;21.053;-0.34665;1.27164;1.22947;813;827
P-10;FDK;7.52;1;1;1;121;77.5;76.5;107;22.4;-4.38;18.6;13.3;1946;2127
P-11;FDK;7.53;1;1;1;118;71.9;75.3;112;23.5;-5.67;19.2;13.2;2004;2334
P-12;FDK;7.36;1;1;1;123;77.3;76.5;111;25.5;-7.75;23.1;15.5;2673;3367
P-15;FDK;7.89;1;1;1;137;88.1;88.3;120;17.1;-10.8;8.7;14.4;2149;1399
P-17;FDK;7.33;1;1;1;128;75.1;78.1;107;25.3;-2.73;35.6;21.5;4548;4504
P-24;FDK;7.66;1;1;1;184;113.1;114.9;171;34.7;-2.82;21.3;10.7;1173;1290
P-31;FDK;7.7;1;1;1;163;100.1;103.2;142;26.1;-3.39;18.7;13.6;1682;1607
P-34;FDK;7.72;1;1;1;170;101.1;105.7;168;35.2;-3.39;14.4;7.9;1025;1215
P-37;FDK;7.784;1;1;1;197;111.8;123.8;208;44.2;-2.61;11;4.6;593;651
C-84;PengXiang;7.67;1;1;1;137;90;91;116;19;-10.4;25.5;21.8;2046;1689
C-92;PengXiang;7.9;1;1;1;141;92;93;122;26;-11;25.4;19.9;2229;1915
C-93;PengXiang;7.91;1;1;1;132;83;87;116;21;-8.4;31.5;23.2;2763;2409
C-94;PengXiang;7.99;1;1;1;142;94;95;126;23;-12.4;28.6;22.2;2584;2196
Выходные данные
P- 5C;Piezotite;8;171.31383913;113.51037092;117.93502448;175.78994215;31.64556962;171.45765931;113.6541911;117.86
710939;175.82201316;31.735621455;0.0126;-0.0047;-0.0053;0.0128;0.0316;0.0125845;-0.0047155;- 0.0052752;0.01276032;0.031510333;-14.899866489;7.0360480641;10.509493671;-0.155;0.248;0.3321;-
0.0096524475389;0.0045581002267;0.0085686177928;-0.0001;0.00016;0.00027;1226.5097972;1543.6361015;1230;1550
P-
5E;Piezotite;7.8;140.96701421;80.3609536;80.482897384;128.46308621;29.411764706;141.02229341;80.416232808;80.3 95017618;128.60279251;29.528227509;0.0124;-0.0041;-0.0052;0.0143;0.034;0.0123849;-0.0041151;-
0.0051698;0.0142396;0.0338659;-9.1146881288;14.490017025;13.147058824;-0.151;0.302;0.447;- 0.0060648490988;0.0096415549775;0.0088584682527;-0.0001;0.0002;0.0003;1484.1232647;1502.871379;1490;1510
P-
6C;Piezotite;7.7;147.79336529;67.148203996;62.604340568;133.55592654;39.0625;147.81590946;67.170748169;62.5390 15719;133.7452143;39.160272186;0.0094;-0.003;-0.003;0.0103;0.0256;0.00939488;-0.00300512;- 0.00298784;0.01027112;0.025536084;-4.2404006678;12.287145242;8.609375;-0.064;0.152;0.2204;- 0.0053165196237;0.015405348201;0.011356478934;-0.00008;0.00019;0.00029;758.10249375;797.58958264;760;800
P- 6E;Piezotite;7.6;142.98906451;74.961853628;73.794405354;128.71117213;33.333333333;143.00522545;74.978014565;73
.734553038;128.93283624;33.443455945;0.0111;-0.0036;-0.0043;0.0127;0.03;0.011091168;-0.003608832;- 0.004279024;0.012650182;0.029901216;-4.7128882787;17.45426463;11.76;-0.1104;0.2622;0.3528;-
11
0.0034290941239;0.012699710399;0.0093641676646;-0.00008;0.00019;0.00028;1255.851072;1374.3828861;1260;1380
P- 6F;Piezotite;7.9;136.69217194;81.747116999;81.349804158;129.55709551;29.239766082;136.71272754;81.767672594;81
.281468223;129.78427453;29.360338346;0.0134;-0.0048;-0.0054;0.0145;0.0342;0.013385582;-0.004814418;- 0.00536796;0.0144288;0.034059553;-6.0334438084;20.05784875;14.160818713;-0.1602;0.356;0.4843;-
0.0034069423673;0.011326190626;0.0085144981204;-0.00009;0.0002;0.00029;1663.1419155;1770.9262904;1670;1780
P-
7;Piezotite;7.8;129.96492844;83.453300538;82.537436623;119.08972998;24.630541872;130.02468245;83.513054542;82. 447076909;119.2263715;24.751024494;0.0158;-0.0057;-0.007;0.0181;0.0406;0.01577459;-0.00572541;-
0.00694918;0.01799836;0.040402368;-11.167315175;16.887159533;15.21182266;-0.231;0.462;0.6176;- 0.0053507941492;0.008091444811;0.0079203278382;-0.00011;0.00022;0.00032;1920.6051783;2087.0388327;1930;2100
P- 7B;Piezotite;8;125.94540916;81.697621547;82.836315441;119.28429423;25.773195876;125.98636708;81.738579474;82.7
65177989;119.40784876;25.8672781;0.0167;-0.0059;-0.0075;0.0188;0.0388;0.016676872;-0.005923128;- 0.007453744;0.018707488;0.03865888;-13.867020102;24.084824387;17.319587629;-0.3304;0.6608;0.672;-
0.0029536213405;0.0051299739072;0.005432128401;-0.00007;0.00014;0.00021;3188.3612371;4694.9214212;3200;4720
PZT5A;FEM;7.75;120.3462496;75.17913126;75.090066479;110.86705106;21.052631579;120.36317061;75.196052269;75.040157 199;111.01426074;21.140371775;0.0164;-0.00574;-0.00722;0.0188;0.0475;0.016382799412;-0.0057572005882;-
0.00718238;0.01871772;0.047302857803;-5.3511552638;15.783474361;12.294736842;-0.171;0.374;0.584;- 0.0031621225409;0.009326823385;0.0071364029577;-
0.00010058823529;0.00022;0.00033757225434;1722.8198737;1692.2668855;1730;1700
PMN30PT;ATILA;8;23.585124088;9.4807517327;1.5189789336;1.6166624663;7.1428571429;24.300659065;10.196286709;1.5084 289204;1.6168180181;7.1434933155;0.052;-0.0189;-0.0311;0.677;0.14;0.051231665761;-0.019668334239;-
0.029447372283;0.67344532518;0.13998753213;-27.444574364;0.40464915006;1.3642857143;-0.921;1.981;0.191;- 0.026072001238;0.00038441161453;0.00046630458758;-
0.00083423913043;0.001794384058;0.000065276828435;2925.7394214;1052.6454841;2926;1104
Material 38;FEMP;8;122.74;91.034;82.098;116.25;21.053;122.7401453;91.034145304;82.097466972;116.25195534;21.054859282;0
.020881544551;-0.010658227101;-0.0072199046538;0.018799823351;0.047499168765;0.020881348762;-0.01065842289;-
0.0072194598073;0.018798812628;0.047494974276;-0.34665;1.27164;1.22947;- 0.012725032548;0.028912167262;0.058398803021;-0.00041916565901;0.0015376541717;0.0015122632226;-
0.00001538613195;0.000034958371917;0.000071824902858;813;827;813.07179958;827.04558813
P- 10;FDK;7.52;121;77.5;76.5;107;22.4;121.00901946;77.509019464;76.461698166;107.16265162;22.490899281;0.01710516 0058;-0.0058833456895;-0.0080230728894;0.020818038804;0.044642857143;0.01708674623;-0.0059017595173;- 0.0079806076564;0.020720107183;0.044462428448;-4.38;18.6;13.3;-0.19838070267;0.45749764027;0.59375;- 0.0020592383639;0.0087447108604;0.0068345323741;-
0.000092820660183;0.00021405929322;0.00030387990666;1946;2127;1953.896875;2137.2472711
P- 11;FDK;7.53;118;71.9;75.3;112;23.5;118.01377416;71.913774165;75.253357326;112.15794344;23.586946108;0.01648624 7162;-0.0052057268077;-0.0075841355596;0.019126525136;0.042553191489;0.016467517692;-0.0052244562775;- 0.0075436308129;0.019038928716;0.042396332083;-5.67;19.2;13.2;-0.20957595315;0.45323337987;0.56170212766;- 0.0024293059126;0.0082262210797;0.0065868263473;-
0.000089368410381;0.00019327001061;0.00027925727719;2004;2334;2011.4144681;2345.0786722
P- 12;FDK;7.36;123;77.3;76.5;111;25.5;123.01783858;77.31783858;76.446829522;111.15848233;25.589880284;0.016212175 021;-0.0056696630536;-0.0072657852747;0.019024010334;0.039215686275;0.01619377099;-0.0056880670842;- 0.0072250694566;0.018933933443;0.039077947567;-7.75;23.1;15.5;-0.24954410759;0.55207431046;0.60784313725;- 0.0023017523018;0.0068607068607;0.005798728021;-
0.000073750611737;0.00016316080758;0.00022660238956;2673;3367;2682.4215686;3383.6208502
P- 15;FDK;7.89;137;88.1;88.3;120;17.1;137.08337384;88.183373838;88.232837741;120.05410293;17.196491391;0.01547970 8374;-0.0049701893768;-0.0077332543952;0.019714106052;0.058479532164;0.015456461109;-0.0049934366419;- 0.0076897191975;0.019632577604;0.058151397122;-10.8;8.7;14.4;-0.1807821184;0.33855101758;0.84210526316;- 0.007719799857;0.0062187276626;0.0067007910656;-
0.00012859272427;0.00024081583976;0.00038966036229;2149;1399;2161.1263158;1405.8502876
P- 17;FDK;7.33;128;75.1;78.1;107;25.3;128.00165473;75.101654729;78.078421847;107.28138544;25.401638083;0.01506418 6321;-0.0038394053615;-0.0081930410554;0.021306102924;0.0395256917;0.015041275113;-0.0038623165696;- 0.0081359449024;0.021163815766;0.039367539871;-2.73;35.6;21.5;-0.32231591359;0.80323126825;0.84980237154;- 0.00060612788632;0.0079040852575;0.0047273526825;-
0.000071083080672;0.00017714345036;0.00018610424521;4548;4504;4566.270751;4534.354878
P- 24;FDK;7.66;184;113.1;114.9;171;34.7;184.00616465;113.10616465;114.85343721;171.35169767;34.797604433;0.010556 27305;-0.0035480993059;-0.0047090009541;0.012176189586;0.028818443804;0.01054515652;-0.003559215835;-
0.0046825290368;0.012113151708;0.028737610427;-2.82;21.3;10.7;-0.12006477028;0.28591160357;0.3083573487;- 0.0021860465116;0.016511627907;0.0091219096334;-
0.000092587768384;0.00022048030632;0.0002621418854;1173;1290;1176.2994236;1296.7670825
P- 31;FDK;7.7;163;100.1;103.2;142;26.1;163.00715128;100.10715128;103.16055196;142.21760423;26.209964328;0.0123701 24219;-0.0035281269735;-0.0064260148994;0.016382601938;0.038314176245;0.012356162363;-0.0035420888291;-
0.006393474955;0.016306763309;0.038153428501;-3.39;18.7;13.6;-0.15014084928;0.34992303726;0.52107279693;- 0.0021095208463;0.011636589919;0.0080856123662;-
0.00009299171807;0.00021672945493;0.0003084938333;1682;1607;1689.08659;1614.5615158
P- 34;FDK;7.72;170;101.1;105.7;168;35.2;170.00945852;101.10945852;105.65982222;168.17066667;35.260887805;0.010877 611796;-0.0036361763024;-0.0045560698316;0.01168543549;0.028409090909;0.010870941119;-0.0036428469796;-
0.004541333854;0.011652882718;0.028360034652;-3.39;14.4;7.9;-0.090155871899;0.19916042452;0.22443181818;- 0.0027901234568;0.011851851852;0.0077073170732;- 0.000073990491053;0.00016345000385;0.00021857977927;1025;1215;1026.7730114;1218.4791669
P- 37;FDK;7.784;197;111.8;123.8;208;44.2;197.01046406;111.81046406;123.75589862;208.1858679;44.235682968;0.008965 8549443;-0.0027712342576;-0.0036869905818;0.0091966291733;0.022624434389;0.0089609245003;-0.0027761647016;- 0.0036765248014;0.0091744136165;0.022606184259;-2.61;11;4.6;-0.056724856392;0.12040901174;0.10407239819;- 0.0040092165899;0.016897081413;0.0077571669477;- 0.000086918580477;0.00018450078225;0.00017535994535;593;651;593.47873303;652.62060288
12
C-
84;PengXiang;7.67;137;90;91;116;19;137.06403789;90.064037892;90.842984014;116.38499112;19.232277615;0.01657483 8302;-0.0047017574425;-0.0093142272262;0.023234390993;0.052631578947;0.016498921324;-0.004777674421;- 0.0091488862504;0.022874291858;0.051995921649;-10.4;25.5;21.8;-0.36099283521;0.78621289662;1.1473684211;- 0.0061574896388;0.015097690941;0.010654936461;-
0.00021030051342;0.00045801733357;0.00055401324142;2046;1689;2071.0126316;1716.5570798
C-
92;PengXiang;7.9;141;92;93;122;26;141.06318538;92.063185379;92.854099217;122.33689817;26.177662629;0.015685749 497;-0.0047224137678;-0.0083572969087;0.020938173976;0.038461538462;0.015628648908;-0.0047795143571;- 0.0082345280212;0.020674215233;0.038200507592;-11;25.4;19.9;-0.33287203451;0.71569015097;0.76538461538;- 0.0057441253264;0.013263707572;0.0089277703006;-
0.00017153916021;0.00036881706704;0.00034104535715;2229;1915;2244.2311538;1940.5017146
C-
93;PengXiang;7.91;132;83;87;116;21;132.02929016;83.029290162;86.890161893;116.4118929;21.194802751;0.016121241 396;-0.0042869218693;-0.008875739645;0.021934299123;0.047619047619;0.016062418052;-0.0043457452133;- 0.0087453573207;0.021645305853;0.04718137799;-8.4;31.5;23.2;-0.37899408284;0.8400428484;1.1047619048;- 0.0034869240349;0.013075965131;0.0083966702859;-
0.00015520913551;0.00034402205785;0.00039616647462;2763;2409;2788.6304762;2441.8284503
C-
94;PengXiang;7.99;142;94;95;126;23;142.07001821;94.070018215;94.838506375;126.37247723;23.190727554;0.01580773 29;-0.0050256004336;-0.0081293855896;0.020195105254;0.04347826087;0.015747526548;-0.0050858067853;- 0.0080012800243;0.019922525445;0.043120682508;-12.4;28.6;22.2;-0.36619887044;0.77918877289;0.9652173913;- 0.0056466302368;0.013023679417;0.0085913312693;-
0.00016440889515;0.00034982512401;0.00037046406799;2584;2196;2605.4278261;2227.3665309
Заключение
Полученные значения свидетельствуют об отсутствии ошибок как со стороны программы, так и со стороны входных данных.
Результаты разработанной программы на Turbo Prolog полностью совпали с результатами предложенной преподавателем Pascal-реализацией.
Выходные данные представлены следующим образом:
1.Name — название пьезоматериала.
2.Source — изготовитель.
3.Density — плотность пьезоматериала.
4.C11E, C12E, C13E, C33E, C44E, C11D, C12D, C13D, C33D, C44D, S11E, S12E, S13E, S33E, S44E, S11D, S12D, S13D, S33D, S44D, E31, E33, E15, D31, D33, D15, H31, H33, H15, G31, G33, G15, E11S, E33S, E11T,
E33T — константы пьезоматериала.
5. Код программы Код программы приведен в табл. 3.
Таблица 3 — Код программы
NOWARNINGS
%Раздел описания доменов
DOMAINS
file = datafile reals = real*
/* const_list = cl(C11E, C12E, C13E, C33E, C44E, C11D, C12D, C13D, C33D, C44D, S11E, S12E, S13E, S33E, S44E,
S11D, S12D, S13D, S33D, S44D, E31, E33, E15, D31, D33, D15, H31, H33, H15, G31, G33, G15, E11S, E33S, E11T, E33T) */
const_list = cl(real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real, real)
/* priv_const_list = pcl(C11E, C12E, C13E, C33E, C44E, E31, E33, E15, E11S, E33S, Reg_C, Reg_e, Reg_s) */ priv_const_list = pcl(real, real, real, real, real, real, real, real, real, real, integer, integer, integer) strings = string*
const_matrix = const_list*
%Раздел описания предикатов
PREDICATES if_x_equals_0_then_1_else_x(real, real)
get_ce(integer, integer, integer, const_list, const_list) get_cd(integer, integer, integer, const_list, const_list) get_se(integer, integer, integer, const_list, const_list) get_sd(integer, integer, integer, const_list, const_list) get_e(integer, integer, integer, const_list, const_list) get_d(integer, integer, integer, const_list, const_list)
13
get_h(integer, integer, integer, const_list, const_list) get_g(integer, integer, integer, const_list, const_list) get_et(integer, integer, integer, const_list, const_list) get_es(integer, integer, integer, const_list, const_list) get_constants(priv_const_list, const_list) get_constants_aux(integer, integer, integer, const_list, const_list) get_constants_aux1(real, const_list, const_list) get_constants_aux2(real, const_list, const_list)
eq1(real, reals, reals, reals, reals, reals) eq2(real, reals, reals, reals, reals, reals) eq3(real, reals, reals, reals)
start() menu() choose(string)
insert_into_database(string, string, const_list, real) dialog_str_delete_from_database_by_name() dialog_str_clear_database()
read_real_greater_0(real)
read_variant(integer, integer, integer, integer) choose_variant(integer, integer, integer, integer, integer) dialog_str_set_elastic_constants_from_console(integer, priv_const_list)
pre_dialog_str_set_elastic_constants_from_console(integer, real, real, real, real, real) enter_elastic_constants(real, real, real, real, real, string, string, string, string, string) dialog_str_set_piezoelectric_constants_from_console(integer, priv_const_list) pre_dialog_str_set_piezoelectric_constants_from_console(integer, real, real, real) enter_piezoelectric_constants(real, real, real, string, string, string) dialog_str_set_permittivities_from_console(integer, priv_const_list) pre_dialog_str_set_permittivities_from_console(integer, real, real) enter_permittivities(real, real, string, string)
dialog_str_read_from_file() dialog_str_read_from_console() dialog_str_read_from_console_1(string, string, real) dialog_str_read_from_console_2(priv_const_list) dialog_str_read_from_console_3(priv_const_list) dialog_str_read_from_console_4(priv_const_list) dialog_str_show_data()
print_database()
print_database(strings, strings, const_matrix, reals) print_enter_rows(strings, strings, const_matrix, reals) print_enter_rows(strings, strings, const_matrix, reals, string) print_consts(const_list)
dialog_str_save_into_file() print_format_consts(const_list) exists(string)
read_rows()
front_string(string, string, string) clear_database() dialog_str_show_by_source()
read_cmd(string, string, const_list, real, string) print_sources(strings, integer) remove_duplicates(strings, strings)
member(string, strings) delete3(string, strings, strings)
material_edit(string, string, const_list, real, string, string, const_list, real) choose_edit(integer, string, string, const_list, real, string, string, const_list, real) material_edited()
should_be_positive(string, real) should_be_negative(string, integer, real, integer, integer) log_str(String)
length(strings, integer) get(strings, integer, string)
%Раздел описания базы данных
DATABASE
piezomaterial(string, string, const_list, real) % piezomaterial(Name, Source, Constants, Density)
%Раздел описания внутренней цели
GOAL |
|
|
|
|
start(). |
|
|
|
|
% Раздел описания предложений |
|
|
|
|
CLAUSES |
|
|
|
|
length([], 0). |
|
|
|
|
length([_|Xs], N) :- |
|
|
|
|
length(Xs, P), |
|
|
|
|
N = P + 1. |
|
|
|
|
get([Head|_], 0, X) :- X = Head. |
|
|
|
|
get([_|Tail], I, X) :- I1 = I - 1, get(Tail, I1, X). |
|
|
||
start() :- makewindow(1, 15, 15, "Piezomaterial", 1, 0, 24, 80), menu(). |
|
|||
menu() :- |
|
|
|
|
clearwindow(), |
|
|
|
|
write(" |
************************* |
"), nl, |
||
write(" |
* |
MENU |
* |
"), nl, |
write(" |
************************* |
"), nl, |
||
write(" |
* |
1. Add from console |
* |
"), nl, |
write(" |
************************* |
"), nl, |
||
write(" |
* |
2. Add from file |
* |
"), nl, |
write(" |
************************* |
"), nl, |
||
write(" |
* |
3. Show data |
* |
"), nl, |
write(" |
************************* |
"), nl, |
||
write(" |
* |
4. Show by source |
* |
"), nl, |
write(" |
************************* |
"), nl, |
||
write(" |
* |
5. Delete by name |
* |
"), nl, |
write(" |
************************* |
"), nl, |
||
write(" |
* |
6. Clear |
* |
"), nl, |
write(" |
************************* |
"), nl, |
14
write(" |
* |
7. |
Save into file |
* |
"), nl, |
|
write(" |
************************* |
"), nl, |
||||
write(" |
* |
0. |
Exit |
* |
"), |
nl, |
write(" |
************************* |
"), |
nl, |
write(" |
int>"), readln(S), clearwindow(), choose(S), menu(); menu(). |
choose(S) :- |
|
S = "0", !, exit; |
|
S = "1", !, dialog_str_read_from_console(); |
|
S = "2", !, dialog_str_read_from_file(); |
|
S = "3", !, dialog_str_show_data(); |
|
S = "4", !, dialog_str_show_by_source(); |
|
S = "5", !, dialog_str_delete_from_database_by_name(); |
|
S = "6", !, dialog_str_clear_database(); |
|
S = "7", !, dialog_str_save_into_file(). |
|
dialog_str_show_by_source() :- |
|
|
|
|
findall(Source, piezomaterial(_, Source, _, _), Sources), not(Sources = []), !, |
|
|||
write(" |
**************************** |
"), nl, |
||
write(" |
|
ENTER SOURCE |
|
"), nl, |
remove_duplicates(Sources, SList), print_sources(SList, 1), |
|
|||
write(" |
**************************** |
"), nl, |
||
length(SList, L), read_variant(N, 1, L, 0), N1 = N - 1, get(SList, N1, S), |
|
|||
findall(Name, piezomaterial(Name, _, _, _), Names), |
|
|
||
findall(Consts, piezomaterial(_, _, Consts, _), ConstsList), |
|
|||
findall(Density, piezomaterial(_, _, _, Density), Densitys), |
|
|||
print_enter_rows(Names, Sources, ConstsList, Densitys, S); |
|
|||
write(" |
*********************** |
"), nl, |
||
write(" |
* |
NO DATA! |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
|
member(Name,[Name |_]) :- !. |
|
|
|
|
member(Name,[_ |Tail]):- |
|
|
|
|
member(Name,Tail). |
|
|
|
|
delete3(_,[],[]) :- !. |
|
|
|
|
delete3(X,[X|T],R):- !, delete3(X,T,R). |
|
|
|
|
delete3(X,[H|T],[H|R]) :- delete3(X,T,R). |
|
|
|
|
remove_duplicates([],[]) :- !. |
|
|
|
|
remove_duplicates([H|T], [H|R]) :- |
|
|
|
|
member(H,T),!, |
|
|
|
|
delete3(H,T,R1), |
|
|
|
|
remove_duplicates(R1,R). |
|
|
|
|
remove_duplicates([H|T],[H|R]):- |
|
|
|
|
remove_duplicates(T,R). |
|
|
|
|
print_sources([], _) :- !. |
|
|
|
|
print_sources([Source|Tail], N) :- |
|
|
|
|
writef(" |
%3d. %s", N, Source), nl, N1 = N + 1, print_sources(Tail, N1). |
|||
print_enter_rows([], [], [], [], TSource) :- |
|
|
|
|
write(" |
*********************** |
"), nl, |
||
write(" |
* |
DONE! |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
|
print_enter_rows([Name|NT], [Source|ST], [Consts|CT], [Density|DT], TSource) :- |
|
|||
Source = TSource, |
|
|
|
|
clearwindow(), write("*****************************************************************************"), nl, write("* Name: ", Name), nl,
write("* Source: ", Source), nl, write("* Density: ", Density), nl, print_format_consts(Consts),
write("*****************************************************************************"), nl,
write(" |
|
next>"), readln(C), read_cmd(Name, Source, Consts, Density, C), |
||
print_enter_rows(NT, ST, CT, DT, TSource); |
|
|
||
Source = TSource, !; |
|
|
|
|
Source <> TSource, print_enter_rows(NT, ST, CT, DT, TSource). |
|
|||
insert_into_database(Name, Source, Consts, Density) :- |
|
|
||
assertz(piezomaterial(Name, Source, Consts, Density)). |
|
|
||
dialog_str_read_from_file() :- |
|
|
|
|
write(" |
**************************** |
"), nl, |
||
write(" |
* |
ENTER FILE NAME |
* |
"), nl, |
write(" |
**************************** |
"), nl, |
||
write(" |
|
string>"), readln(Filename), exists(Filename), |
|
|
openread(datafile, Filename), readdevice(datafile), read_rows(), |
|
|||
closefile(datafile), readdevice(keyboard), |
|
|
||
write(" |
********************** |
"), nl, |
||
write(" |
* |
DONE! |
* |
"), nl, |
write(" |
********************** |
"), nl, |
||
write(" |
|
any>"), !, readln(_); |
|
|
write(" |
************************** |
"), nl, |
||
write(" |
* |
MATERIALS NOT ADDED! |
* |
"), nl, |
write(" |
************************** |
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
|
exists(Filename) :- |
|
|
|
|
existfile(Filename), !; |
|
|
|
|
write(" |
**************************** |
"), nl, |
||
write(" |
* |
FILE NOT FOUND |
* |
"), nl, |
write(" |
**************************** |
"), nl, |
||
write(" |
|
any>"), readln(_), !, fail. |
|
|
read_rows() :- |
|
|
|
|
not(eof(datafile)), |
|
|
|
|
readln(Line), |
|
|
|
|
front_string(Line, Name, Tail1), |
|
|
|
|
front_string(Tail1, Source, Tail2), |
|
|
|
|
front_string(Tail2, Density_STR, Tail3), str_real(Density_STR, Density), |
|
|||
front_string(Tail3, Reg_C_STR, Tail4), str_int(Reg_C_STR, Reg_C), Reg_C >= 1, Reg_C |
<= 4, |
15
front_string(Tail4, Reg_e_STR, Tail5), str_int(Reg_e_STR, Reg_e), Reg_e >= 1, Reg_e <= 4, front_string(Tail5, Reg_s_STR, Tail6), str_int(Reg_s_STR, Reg_s), Reg_s >= 1, Reg_s <= 2, front_string(Tail6, C11E_STR, Tail7), str_real(C11E_STR, C11E), should_be_positive(Line, C11E), front_string(Tail7, C12E_STR, Tail8), str_real(C12E_STR, C12E), should_be_negative(Line, Reg_C, C12E, 3,
4),
front_string(Tail8, C13E_STR, Tail9), str_real(C13E_STR, C13E), should_be_negative(Line, Reg_C, C13E, 3,
4),
front_string(Tail9, C33E_STR, Tail10), str_real(C33E_STR, C33E), should_be_positive(Line, C33E), front_string(Tail10, C44E_STR, Tail11), str_real(C44E_STR, C44E), should_be_positive(Line, C44E), front_string(Tail11, E31_STR, Tail12), str_real(E31_STR, E31), should_be_negative(Line, Reg_e, E31, 1, 1), front_string(Tail12, E33_STR, Tail13), str_real(E33_STR, E33), should_be_positive(Line, E33), front_string(Tail13, E15_STR, Tail14), str_real(E15_STR, E15), should_be_positive(Line, E15), front_string(Tail14, S11_STR, Tail15), str_real(S11_STR, E11S), should_be_positive(Line, E11S), front_string(Tail15, S33_STR, _), str_real(S33_STR, E33S), should_be_positive(Line, E33S), get_constants(pcl(C11E, C12E, C13E, C33E, C44E, E31, E33, E15, E11S, E33S, Reg_C, Reg_e, Reg_s), Consts), insert_into_database(Name, Source, Consts, Density), !, read_rows();
not(eof(datafile)), !, |
|
|
|
|
write(" |
********************************** |
"), nl, |
||
write(" |
* |
READING ERROR! |
* |
"), nl, |
write(" |
* |
REMAINING DATA WAS NOT READ! |
* |
"), nl, |
write(" |
* |
SOME MATERIALS ADDED! |
* |
"), nl, |
write(" |
********************************** |
"), nl; !. |
||
should_be_positive(Line, C1XE) :- |
|
|
|
|
C1XE > 0, !; |
|
|
|
|
write("See: ", Line), nl, |
|
|
|
|
write(" |
|
\'", C1XE, "\' should be > 0!"), nl, fail. |
|
|
should_be_negative(Line, Reg_C, C1XE, T1, T2) :- |
|
|
||
Reg_C = T1, C1XE >= 0, !, |
|
|
|
|
write("See: ", Line), nl, |
|
|
|
|
write(" |
|
\'", C1XE, "\' should be < 0!"), nl, fail; |
|
|
Reg_C = T2, C1XE >= 0, !, |
|
|
|
|
write("See: ", Line), nl, |
|
|
|
|
write(" |
|
\'", C1XE, "\' should be < 0!"), nl, fail; |
|
|
T1 <> T2, Reg_C <> T1, Reg_C <> T2, C1XE <= 0, !, |
|
|
||
write("See: ", Line), nl, |
|
|
|
|
write(" |
|
\'", C1XE, "\' should be > 0!"), nl, fail; !. |
|
|
front_string("", "", "") :- !. |
|
|
|
|
front_string(Line, Param, Tail) :- |
|
|
|
frontchar(Line, LineH, LineT), LineH = ';', !, Param = "", Tail = LineT;
frontchar(Line, LineH, LineT), LineH <> ';', !, front_string(LineT, T, Tail), str_char(LineHS, LineH), concat(LineHS, T, Param).
dialog_str_read_from_console() :- dialog_str_read_from_console_1(Name, Source, Density), dialog_str_read_from_console_2(PrivConsts), dialog_str_read_from_console_3(PrivConsts), dialog_str_read_from_console_4(PrivConsts),
get_constants(PrivConsts, Consts), |
|
|
|
|
|
|
insert_into_database(Name, Source, Consts, Density), !, |
|
|
|
|
||
write(" |
|
********************* |
|
|
"), nl, |
|
write(" |
|
* MATERIAL ADDED! |
* |
|
|
"), nl, |
write(" |
|
********************* |
|
|
"), nl, |
|
write(" |
|
any>"), readln(_); |
|
|
|
|
write(" |
************************* |
|
|
"), nl, |
||
write(" |
* |
MATERIAL NOT ADDED! |
* |
|
|
"), nl, |
write(" |
************************* |
|
|
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
|
|
|
dialog_str_read_from_console_1(Name, Source, Density) :- |
|
|
|
|
||
write(" |
************************************* |
|
"), nl, |
|||
write(" |
* NAME OF PIEZOMATERIAL TO INSERT * |
|
"), nl, |
|||
write(" |
************************************* |
|
"), nl, |
|||
write(" |
|
str>"), readln(Name), Name <> "", clearwindow(), |
||||
write(" |
***************************** |
|
"), nl, |
|||
write(" |
* |
SOURCE OF PIEZOMATERIAL |
* |
|
"), nl, |
|
write(" |
***************************** |
|
"), nl, |
|||
write(" |
|
str>"), readln(Source), Source <> "",clearwindow(), |
||||
write(" |
****************************** |
|
"), nl, |
|||
write(" |
* |
DENSITY OF PIEZOMATERIAL |
* |
|
"), nl, |
|
write(" |
****************************** |
|
"), nl, |
|||
write(" |
|
real>"), read_real_greater_0(Density),clearwindow(). |
||||
dialog_str_read_from_console_2(PrivConsts) :- |
|
|
|
|
||
write(" |
********************************************** |
"), nl, |
||||
write(" |
* |
ELASTIC CONSTANTS |
|
|
* |
"), nl, |
write(" |
********************************************** |
"), nl, |
||||
write(" |
* 1. Set CE (C11E, C12E, C13E, C33E, C44E) |
* |
"), nl, |
|||
write(" |
********************************************** |
"), nl, |
||||
write(" |
* 2. Set CD (C11D, C12D, C13D, C33D, C44D) |
* |
"), nl, |
|||
write(" |
********************************************** |
"), nl, |
||||
write(" |
* 3. Set SE (S11E, S12E, S13E, S33E, S44E) |
* |
"), nl, |
|||
write(" |
********************************************** |
"), nl, |
||||
write(" |
* 4. Set SD (S11D, S12D, S13D, S33D, S44D) |
* |
"), nl, |
|||
write(" |
********************************************** |
"), nl, |
||||
write(" |
* 0. Close |
|
|
|
* |
"), nl, |
write(" |
********************************************** |
"), nl, |
||||
read_variant(N1, 1, 4, 0), clearwindow(), |
|
|
|
|
||
dialog_str_set_elastic_constants_from_console(N1, PrivConsts), clearwindow(). |
|
|||||
dialog_str_read_from_console_3(PrivConsts) :- |
|
|
|
|
||
write(" |
****************************** |
|
"), nl, |
|||
write(" |
* |
PIEZOELECTRIC CONSTANTS |
* |
|
"), nl, |
|
write(" |
****************************** |
|
"), nl, |
|||
write(" |
* |
1. Set E (E31, E33, E15) |
* |
|
"), nl, |
|
write(" |
****************************** |
|
"), nl, |
|||
write(" |
* |
2. Set D (D31, D33, D15) |
* |
|
"), nl, |
|
write(" |
****************************** |
|
"), nl, |
16
write(" |
* |
3. Set H (H31, H33, H15) |
* |
"), |
nl, |
write(" |
****************************** |
"), |
nl, |
||
write(" |
* |
4. Set G (G31, G33, G15) |
* |
"), |
nl, |
write(" |
****************************** |
"), |
nl, |
||
write(" |
* |
0. Close |
* |
"), |
nl, |
write(" |
****************************** |
"), |
nl, |
||
read_variant(N2, 1, 4, 0), clearwindow(), |
|
|
|
||
dialog_str_set_piezoelectric_constants_from_console(N2, PrivConsts), clearwindow(). |
|
|
|||
dialog_str_read_from_console_4(PrivConsts) :- |
|
|
|
||
write(" |
**************************** |
"), |
nl, |
||
write(" |
* |
PERMITTIVITIES |
* |
"), |
nl, |
write(" |
**************************** |
"), |
nl, |
||
write(" |
* |
1. Set ES (E11S, E33S) |
* |
"), |
nl, |
write(" |
**************************** |
"), |
nl, |
||
write(" |
* |
2. Set ET (E11T, E33T) |
* |
"), |
nl, |
write(" |
**************************** |
"), |
nl, |
||
write(" |
* |
0. Close |
* |
"), |
nl, |
write(" |
**************************** |
"), |
nl, |
||
read_variant(N3, 1, 2, 0), clearwindow(), |
|
|
|
||
dialog_str_set_permittivities_from_console(N3, PrivConsts), clearwindow(). |
|
|
|||
read_real_greater_0(D) :- |
|
|
|
|
|
readreal(A), A > 0, !, D = A; |
|
|
|
|
|
nl, write(" |
********** SHOULD BE GREATER THAN 0 ********** |
|
"), nl, |
||
write(" |
|
real>"), read_real_greater_0(D). |
|
|
|
read_variant(N, From, To, ErrorCode) :- |
|
|
|
||
write(" |
|
int>"), |
|
|
|
readint(C), choose_variant(N, C, From, To, ErrorCode). |
|
|
|
||
choose_variant(N, C, From, To, ErrorCode) :- |
|
|
|
||
bound(ErrorCode), C = ErrorCode, !, fail; |
|
|
|
||
From <= C, C <= To, N = C, !; |
|
|
|
|
|
write(" |
********** TRY AGAIN ********** |
"), |
nl, |
||
write(" |
|
int>"), readint(D), choose_variant(N, D, From, To, ErrorCode). |
|||
dialog_str_set_elastic_constants_from_console(N, pcl(C11E, C12E, C13E, C33E, C44E, _, _, _, |
_, _, N, _, _)) :- |
||||
pre_dialog_str_set_elastic_constants_from_console(N, C11E, C12E, C13E, C33E, C44E). |
|
|
|||
pre_dialog_str_set_elastic_constants_from_console(N, C11E, C12E, C13E, C33E, C44E) :- |
|
|
|||
N = 1, !, enter_elastic_constants(C11E, C12E, C13E, C33E, C44E, "C11E", "C12E", "C13E", |
"C33E", "C44E"); |
||||
N = 2, !, enter_elastic_constants(C11E, C12E, C13E, C33E, C44E, "C11D", "C12D", "C13D", |
"C33D", "C44D"); |
||||
N = 3, !, |
enter_elastic_constants(C11E, MC12E, MC13E, C33E, C44E, "S11E", "-S12E", |
"-S13E", "S33E", |
|||
"S44E"), |
|
|
|
|
|
C12E = -MC12E, C13E = -MC13E;
N = 4, !, enter_elastic_constants(C11E, MC12E, MC13E, C33E, C44E, "S11D", "-S12D", "-S13D", "S33D",
"S44D"),
C12E = -MC12E, C13E = -MC13E.
enter_elastic_constants(C11E, C12E, C13E, C33E, C44E, C11E_STR, C12E_STR, C13E_STR, C33E_STR, C44E_STR) :-
write(" |
********************************************** |
"), nl, |
|||
write(" |
* |
ELASTIC CONSTANTS |
* |
"), |
nl, |
write(" |
********************************************** |
"), |
nl, |
write(" |
", C11E_STR, " real>"), read_real_greater_0(C11E), |
||
write(" |
", C12E_STR, " real>"), read_real_greater_0(C12E), |
||
write(" |
", C13E_STR, " real>"), read_real_greater_0(C13E), |
||
write(" |
", C33E_STR, " |
real>"), |
read_real_greater_0(C33E), |
write(" |
", C44E_STR, " |
real>"), |
read_real_greater_0(C44E). |
dialog_str_set_piezoelectric_constants_from_console(N, pcl(_, _, _, _, _, E31, E33, E15, _, _, _, N, _)) :- pre_dialog_str_set_piezoelectric_constants_from_console(N, E31, E33, E15).
pre_dialog_str_set_piezoelectric_constants_from_console(N, E31, E33, E15) :-
N = 1, !, enter_piezoelectric_constants(ME31, E33, E15, "-E31", "E33", "E15"), E31 |
= -ME31; |
||||||||
N = 2, !, enter_piezoelectric_constants(ME31, E33, E15, "-D31", "D33", "D15"), E31 |
= -ME31; |
||||||||
N |
= |
3, !, enter_piezoelectric_constants(ME31, |
E33, |
E15, |
"-H31", |
"H33", |
"H15"), |
E31 |
= -ME31; |
N |
= |
4, !, enter_piezoelectric_constants(ME31, |
E33, |
E15, |
"-G31", |
"G33", |
"G15"), |
E31 |
= -ME31. |
enter_piezoelectric_constants(E31, E33, E15, E31_STR, E33_STR, E15_STR) :- |
|
|
||||
write(" |
********************************************** |
"), |
nl, |
|||
write(" |
* |
PIEZOELECTRIC CONSTANTS |
* |
"), |
nl, |
|
write(" |
********************************************** |
"), |
nl, |
|||
write(" |
|
", E31_STR, " real>"), read_real_greater_0(E31), |
|
|
||
write(" |
|
", E33_STR, " real>"), read_real_greater_0(E33), |
|
|
||
write(" |
|
", E15_STR, " real>"), read_real_greater_0(E15). |
|
|
||
dialog_str_set_permittivities_from_console(N, pcl(_, _, _, _, _, _, _, _, E11S, E33S, _, _, |
N)) :- |
|||||
pre_dialog_str_set_permittivities_from_console(N, E11S, E33S). |
|
|
|
|||
pre_dialog_str_set_permittivities_from_console(N, E11S, E33S) :- |
|
|
|
|||
N = 1, !, enter_permittivities(E11S, E33S, "E11S", "E33S"); |
|
|
|
|||
N = 2, !, enter_permittivities(E11S, E33S, "E11T", "E33T"). |
|
|
|
|||
enter_permittivities(E11S, E33S, E11S_STR, E33S_STR) :- |
|
|
|
|
||
write(" |
********************************************** |
"), |
nl, |
|||
write(" |
* |
PERMITTIVITIES |
|
* |
"), |
nl, |
write(" |
********************************************** |
"), |
nl, |
|||
write(" |
|
", E11S_STR, " real>"), read_real_greater_0(E11S), |
|
|
||
write(" |
|
", E33S_STR, " real>"), read_real_greater_0(E33S). |
|
|
||
dialog_str_delete_from_database_by_name() :- |
|
|
|
|
||
findall(Density, piezomaterial(_, _, _, Density), DensityList), DensityList = [], |
|
|
||||
write(" |
*********************** |
|
"), |
nl, |
||
write(" |
* |
NO DATA! |
* |
|
"), |
nl, |
write(" |
*********************** |
|
"), |
nl, |
||
write(" |
|
any>"), readln(_); |
|
|
|
|
write(" |
************************************* |
"), |
nl, |
|||
write(" |
* NAME OF PIEZOMATERIAL TO REMOVE |
* |
"), |
nl, |
||
write(" |
************************************* |
"), |
nl, |
|||
write(" |
|
str>"), readln(Name), |
|
|
|
|
retract(piezomaterial(Name, _, _, _)), !, |
|
|
|
|
||
write(" |
*********************** |
|
"), |
nl, |
||
write(" |
* |
MATERIAL DELETED! |
* |
|
"), |
nl, |
write(" |
*********************** |
|
"), |
nl, |
||
write(" |
|
any>"), readln(_); |
|
|
|
|
write(" |
************************* |
|
"), |
nl, |
17
write(" |
* |
MATERIAL NOT FOUND! |
* |
"), nl, |
write(" |
************************* |
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
|
dialog_str_clear_database() :- |
|
|
|
|
findall(Density, piezomaterial(_, _, _, Density), DensityList), DensityList = [], |
|
|||
write(" |
*********************** |
"), nl, |
||
write(" |
* |
NO DATA! |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
any>"), readln(_); |
|
|
write(" |
************************************** |
"), nl, |
||
write(" |
* ARE YOU SURE TO DELETE ALL DATA? * |
"), nl, |
||
write(" |
************************************** |
"), nl, |
||
write(" |
|
[y/n]>"), readln(X), X = "y", !, |
|
|
not(clear_database()), |
|
|
|
|
write(" |
|
******************* |
|
"), nl, |
write(" |
|
* DATA DELETED! * |
|
"), nl, |
write(" |
|
******************* |
|
"), nl, |
write(" |
|
any>"), readln(_). |
|
|
clear_database() :- |
|
|
|
|
retract(piezomaterial(_, _, _, _)), fail. |
|
|
||
dialog_str_show_data() :- |
|
|
|
|
findall(Name, piezomaterial(Name, _, _, _), Names), |
|
|
||
findall(Source, piezomaterial(_, Source, _, _), Sources), |
|
|||
findall(Consts, piezomaterial(_, _, Consts, _), ConstsList), |
|
|||
findall(Density, piezomaterial(_, _, _, Density), Densitys), not(Densitys = []), !, |
|
|||
print_enter_rows(Names, Sources, ConstsList, Densitys); |
|
|
||
write(" |
*********************** |
"), nl, |
||
write(" |
* |
NO DATA! |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
|
print_enter_rows([], [], [], []) :- |
|
|
|
|
write(" |
*********************** |
"), nl, |
||
write(" |
* |
DONE! |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
print_enter_rows([Name|NT], [Source|ST], [Consts|CT], [Density|DT]) :- clearwindow(),
write("*****************************************************************************"), nl, write("* Name: ", Name), nl,
write("* Source: ", Source), nl, write("* Density: ", Density), nl, print_format_consts(Consts),
write("*****************************************************************************"), nl,
write(" |
|
next>"), readln(C), read_cmd(Name, Source, Consts, Density, C), |
||
print_enter_rows(NT, ST, CT, DT). |
|
|
|
|
read_cmd(Name, Source, Consts, Density, C) :- |
|
|
||
C <> "delete", C <> "edit", C <> "close", !; |
|
|
||
C = "close", !, fail; |
|
|
|
|
C = "delete", retract(piezomaterial(Name, Source, Consts, Density)), !, |
|
|||
write(" |
*********************** |
"), nl, |
||
write(" |
* |
MATERIAL DELETED! |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
any>"), readln(_); |
|
|
C = "edit", !, material_edit(Name, Source, Consts, Density, _, _, _, _); |
|
|||
write(" |
************************* |
"), nl, |
||
write(" |
* |
MATERIAL NOT FOUND! |
* |
"), nl, |
write(" |
************************* |
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
|
material_edit(Name, Source, Consts, Density, NewName, NewSource, NewConsts, NewDensity) :- |
||||
clearwindow(), |
|
|
|
|
write(" |
*********************** |
"), nl, |
||
write(" |
* |
EDIT MATERIAL |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
Name: ", Name), nl, |
|
|
|
write(" |
Source: ", Source), nl, |
|
||
write(" |
*********************** |
"), nl, |
||
write(" |
* |
1. Edit name |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
* |
2. Edit source |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
* |
3. Edit density |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
* |
4. Edit constants |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
* |
0. Close |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
read_variant(N, 1, 4, 0),
choose_edit(N, Name, Source, Consts, Density, NewName, NewSource, NewConsts, NewDensity), material_edit(NewName, NewSource, NewConsts, NewDensity, _, _, _, _), !; !.
choose_edit(N, Name, Source, Consts, Density, NewName, NewSource, NewConsts, NewDensity) :-
N = 0, !, fail; |
|
|
|
|
N = 1, !, |
|
|
|
|
write(" |
*********************** |
"), nl, |
||
write(" |
* |
EDIT NAME |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
str>"), readln(Nm), Nm <> "", clearwindow(), |
|
|
NewName = Nm, NewSource = Source, NewConsts = Consts, NewDensity = Density, |
|
|||
retract(piezomaterial(Name, Source, Consts, Density)), |
|
|
||
asserta(piezomaterial(NewName, NewSource, NewConsts, NewDensity)), material_edited(); |
||||
N = 2, !, |
|
|
|
|
write(" |
*********************** |
"), nl, |
||
write(" |
* |
EDIT SOURCE |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
18
write(" |
str>"), readln(S), S <> |
"", clearwindow(), |
NewName |
= Name, NewSource = S, NewConsts = Consts, NewDensity = |
Density, |
retract(piezomaterial(Name, Source, Consts, Density)), asserta(piezomaterial(NewName, NewSource, NewConsts, NewDensity)), material_edited();
N = 3, !, |
|
|
|
|
write(" |
*********************** |
"), nl, |
||
write(" |
* |
EDIT DENSITY |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
str>"), read_real_greater_0(D), clearwindow(), |
NewName = Name, NewSource = Source, NewConsts = Consts, NewDensity = D, retract(piezomaterial(Name, Source, Consts, Density)), asserta(piezomaterial(NewName, NewSource, NewConsts, NewDensity)), material_edited(); N = 4, !,
dialog_str_read_from_console_2(PrivNewConsts), dialog_str_read_from_console_3(PrivNewConsts), dialog_str_read_from_console_4(PrivNewConsts), get_constants(PrivNewConsts, CS),
NewName = Name, NewSource = Source, NewConsts = CS, NewDensity = Density, retract(piezomaterial(Name, Source, Consts, Density)), asserta(piezomaterial(NewName, NewSource, NewConsts, NewDensity)), material_edited().
material_edited() :- |
|
|
|
|
write(" |
*********************** |
"), nl, |
||
write(" |
* MATERIAL EDITED |
* |
"), |
nl, |
write(" |
*********************** |
"), |
nl, |
|
write(" |
any>"), readln(_). |
|
|
print_format_consts(cl(C11E, C12E, C13E, C33E, C44E, C11D, C12D, C13D, C33D, C44D, S11E, S12E, S13E, S33E, S44E, S11D, S12D, S13D, S33D, S44D, E31, E33, E15, D31, D33, D15, H31, H33, H15, G31, G33, G15, E11S, E33S,
E11T, E33T)) :-
writef("* C11E: %6.3f\tC11D: %6.3f\tS11E: %6.3f\tS11D: %6.3f\t", C11E, |
C11D, S11E, S11D), nl, |
writef("* C12E: %6.3f\tC12D: %6.3f\tS12E: %6.3f\tS12D: %6.3f\t", C12E, |
C12D, S12E, S12D), nl, |
writef("* C13E: %6.3f\tC13D: %6.3f\tS13E: %6.3f\tS13D: %6.3f\t", C13E, |
C13D, S13E, S13D), nl, |
writef("* C33E: %6.3f\tC33D: %6.3f\tS33E: %6.3f\tS33D: %6.3f\t", C33E, |
C33D, S33E, S33D), nl, |
writef("* C44E: %6.3f\tC44D: %6.3f\tS44E: %6.3f\tS44D: %6.3f\t", C44E, |
C44D, S44E, S44D), nl, |
writef("* E31: %6.3f\tD31: %6.3f\tH31: %6.4f\tG31: %6.6f\t", E31, D31, |
H31, G31), nl, |
writef("* E33: %6.3f\tD33: %6.3f\tH33: %6.4f\tG33: %6.6f\t", E33, D33, |
H33, G33), nl, |
writef("* E15: %6.3f\tD15: %6.3f\tH15: %6.4f\tG15: %6.6f\t", E15, D15, |
H15, G15), nl, |
writef("* E11S: %7.3f\tE11T: %7.3f", E11S, E11T), nl, |
|
|
||
writef("* E33S: %7.3f\tE33T: %7.3f", E33S, E33T), nl. |
|
|
||
dialog_str_save_into_file() :- |
|
|
|
|
findall(Density, piezomaterial(_, _, _, Density), DensityList), DensityList = [], !, |
|
|||
write(" |
*********************** |
"), nl, |
||
write(" |
* |
NO DATA! |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
any>"), readln(_); |
|
|
write(" |
**************************** |
"), nl, |
||
write(" |
* |
ENTER FILE NAME |
* |
"), nl, |
write(" |
**************************** |
"), nl, |
||
write(" |
|
string>"), readln(Filename), |
|
|
openwrite(datafile, Filename), writedevice(datafile), print_database(), |
|
|||
closefile(datafile), writedevice(screen), |
|
|
||
write(" |
*********************** |
"), nl, |
||
write(" |
* |
DONE! |
* |
"), nl, |
write(" |
*********************** |
"), nl, |
||
write(" |
|
any>"), readln(_). |
|
|
print_database() :- |
|
|
|
|
findall(Name, piezomaterial(Name, _, _, _), Names), findall(Source, piezomaterial(_, Source, _, _), Sources), findall(Consts, piezomaterial(_, _, Consts, _), ConstsList), findall(Density, piezomaterial(_, _, _, Density), Densitys), print_database(Names, Sources, ConstsList, Densitys); writedevice(screen).
print_database([], [], [], []) :- !.
print_database([Name|NT], [Source|ST], [Consts|CT], [Density|DT]) :-
write(Name, ";", Source, ";", Density, ";"), print_consts(Consts), nl, print_database(NT, ST, CT, DT). print_consts(cl(C11E, C12E, C13E, C33E, C44E, C11D, C12D, C13D, C33D, C44D, S11E, S12E, S13E, S33E, S44E, S11D, S12D, S13D, S33D, S44D, E31, E33, E15, D31, D33, D15, H31, H33, H15, G31, G33, G15, E11S, E33S, E11T, E33T)) :-
write(C11E, ";", C12E, ";", C13E, ";", C33E, ";", C44E, ";", C11D, ";", C12D, ";", C13D, ";", C33D, ";", C44D, ";", S11E, ";", S12E, ";", S13E, ";", S33E, ";"), write(S44E, ";", S11D, ";", S12D, ";", S13D, ";", S33D, ";", S44D, ";", E31, ";", E33, ";", E15, ";", D31, ";", D33, ";", D15, ";", H31, ";", H33, ";", H15, ";", G31, ";", G33, ";", G15, ";", E11S, ";", E33S, ";", E11T, ";", E33T).
% Алгоритм, переписанный с программы на Pascal if_x_equals_0_then_1_else_x(T, Temp) :-
abs(T) <= 0, Temp = 1.0, !; Temp = T.
get_ce(RC, Re, Rs, cl(CL1_C11E, CL1_C12E, CL1_C13E, CL1_C33E, CL1_C44E, CL1_C11D, CL1_C12D, CL1_C13D, CL1_C33D, CL1_C44D, CL1_S11E, CL1_S12E, CL1_S13E, CL1_S33E, CL1_S44E, CL1_S11D, CL1_S12D, CL1_S13D, CL1_S33D, CL1_S44D, CL1_E31, CL1_E33, CL1_E15, CL1_D31, CL1_D33, CL1_D15, CL1_H31, CL1_H33, CL1_H15, CL1_G31, CL1_G33,
CL1_G15, CL1_E11S, CL1_E33S, CL1_E11T, CL1_E33T), cl(CL2_C11E, CL2_C12E, CL2_C13E, CL2_C33E, CL2_C44E, CL1_C11D, CL1_C12D, CL1_C13D, CL1_C33D, CL1_C44D, CL1_S11E, CL1_S12E, CL1_S13E, CL1_S33E, CL1_S44E, CL1_S11D,
CL1_S12D, CL1_S13D, CL1_S33D, CL1_S44D, CL1_E31, CL1_E33, CL1_E15, CL1_D31, CL1_D33, CL1_D15, CL1_H31, CL1_H33, CL1_H15, CL1_G31, CL1_G33, CL1_G15, CL1_E11S, CL1_E33S, CL1_E11T, CL1_E33T)) :-
RC = 2, Re = 1, Rs = 1, !,
CL2_C11E = CL1_C11D - CL1_H31 * CL1_E31,
CL2_C12E = CL1_C12D - CL1_H31 * CL1_E31,
CL2_C13E = CL1_C13D - CL1_H31 * CL1_E33,
CL2_C33E = CL1_C33D - CL1_H33 * CL1_E33,
CL2_C44E = CL1_C44D - CL1_H15 * CL1_E15; RC = 1, Re = 3, Rs = 1, !,
CL2_C11E = CL1_C11D - CL1_H31 * CL1_H31 / CL1_E33S,
CL2_C12E = CL1_C12D - CL1_H31 * CL1_H31 / CL1_E33S,
CL2_C13E = CL1_C13D - CL1_H31 * CL1_H33 / CL1_E33S,
CL2_C33E = CL1_C33D - CL1_H33 * CL1_H33 / CL1_E33S,
CL2_C44E = CL1_C44D - CL1_H15 * CL1_H15 / CL1_E11S;
19
RC = 2, Re = 3, Rs = 2, !,
T1 = CL1_S33E * (CL1_S11E + CL1_S12E) - 2 * CL1_S13E * CL1_S13E, T2 = (CL1_S11E - CL1_S12E) * T1,
if_x_equals_0_then_1_else_x(T1, Temp1), if_x_equals_0_then_1_else_x(T2, Temp2),
CL2_C11E = |
(CL1_S11E * CL1_S33E - CL1_S13E * CL1_S13E) / Temp2, |
CL2_C12E = |
(CL1_S13E * CL1_S13E - CL1_S12E * CL1_S33E) / Temp2, |
CL2_C13E = |
-CL1_S13E / Temp1, |
CL2_C33E = |
(CL1_S11E + CL1_S12E) / Temp1, |
CL2_C44E = |
1.0 / CL1_S44E; |
CL2_C11E = |
CL1_C11E, CL2_C12E = CL1_C12E, CL2_C13E = CL1_C13E, CL2_C33E = CL1_C33E, CL2_C44E = CL1_C44E. |
get_cd(RC, Re, |
Rs, cl(CL1_C11E, CL1_C12E, CL1_C13E, CL1_C33E, CL1_C44E, CL1_C11D, CL1_C12D, CL1_C13D, |
CL1_C33D, CL1_C44D, CL1_S11E, CL1_S12E, CL1_S13E, CL1_S33E, CL1_S44E, CL1_S11D, CL1_S12D, CL1_S13D, CL1_S33D, |
CL1_S44D, CL1_E31, CL1_E33, CL1_E15, CL1_D31, CL1_D33, CL1_D15, CL1_H31, CL1_H33, CL1_H15, CL1_G31, CL1_G33,
CL1_G15, CL1_E11S, CL1_E33S, CL1_E11T, CL1_E33T), cl(CL1_C11E, CL1_C12E, CL1_C13E, CL1_C33E, CL1_C44E, CL2_C11D, CL2_C12D, CL2_C13D, CL2_C33D, CL2_C44D, CL1_S11E, CL1_S12E, CL1_S13E, CL1_S33E, CL1_S44E, CL1_S11D, CL1_S12D, CL1_S13D, CL1_S33D, CL1_S44D, CL1_E31, CL1_E33, CL1_E15, CL1_D31, CL1_D33, CL1_D15, CL1_H31, CL1_H33, CL1_H15, CL1_G31, CL1_G33, CL1_G15, CL1_E11S, CL1_E33S, CL1_E11T, CL1_E33T)) :-
RC = 1, Re = 1, Rs = 1, !, |
|
|
CL2_C11D = |
CL1_C11E + CL1_E31 * CL1_E31 |
/ CL1_E33S, |
CL2_C12D = |
CL1_C12E + CL1_E31 * CL1_E31 |
/ CL1_E33S, |
CL2_C13D = |
CL1_C13E + CL1_E31 * CL1_E33 |
/ CL1_E33S, |
CL2_C33D = |
CL1_C33E + CL1_E33 * CL1_E33 |
/ CL1_E33S, |
CL2_C44D = |
CL1_C44E + CL1_E15 * CL1_E15 |
/ CL1_E11S; |
RC = 1, Re = 3, Rs = 1, !, |
|
|
CL2_C11D = |
CL1_C11E + CL1_H31 * CL1_H31 |
/ CL1_E33S, |
CL2_C12D = |
CL1_C12E + CL1_H31 * CL1_H31 |
/ CL1_E33S, |
CL2_C13D = |
CL1_C13E + CL1_H31 * CL1_H33 |
/ CL1_E33S, |
CL2_C33D = |
CL1_C33E + CL1_H33 * CL1_H33 |
/ CL1_E33S, |
CL2_C44D = |
CL1_C44E + CL1_H15 * CL1_H15 |
/ CL1_E11S; |
RC = 1, Re = 3, Rs = 2, !, |
|
|
CL2_C11D = |
CL1_C11E + CL1_H31 * CL1_E31, |
|
CL2_C12D = |
CL1_C12E + CL1_H31 * CL1_E31, |
|
CL2_C13D = |
CL1_C13E + CL1_H31 * CL1_E33, |
|
CL2_C33D = |
CL1_C33E + CL1_H33 * CL1_E33, |
|
CL2_C44D = |
CL1_C44E + CL1_H15 * CL1_E15; |
|
RC = 0, Re = 0, Rs = 0, !, |
|
|
T1 = CL1_S33D * (CL1_S11D + CL1_S12D) - |
2 * CL1_S13D * CL1_S13D, |
|
T2 = (CL1_S11D - CL1_S12D) * T1, |
|
|
if_x_equals_0_then_1_else_x(T1, Temp1), if_x_equals_0_then_1_else_x(T2, Temp2), |
||
CL2_C11D = |
(CL1_S11D * CL1_S33D - CL1_S13D * CL1_S13D) / Temp2, |
|
CL2_C12D = |
(CL1_S13D * CL1_S13D - CL1_S12D * CL1_S33D) / Temp2, |
|
CL2_C13D = |
-CL1_S13D / Temp1, |
|
CL2_C33D = |
(CL1_S11D + CL1_S12D) / Temp1, |
|
CL2_C44D = |
1.0 / CL1_S44D; |
|
CL2_C11D = |
CL1_C11D, CL2_C12D = CL1_C12D, CL2_C13D = CL1_C13D, CL2_C33D = CL1_C33D, CL2_C44D = CL1_C44D. |
|
get_se(RC, Re, |
Rs, cl(CL1_C11E, CL1_C12E, CL1_C13E, CL1_C33E, CL1_C44E, CL1_C11D, CL1_C12D, CL1_C13D, |
CL1_C33D, CL1_C44D, CL1_S11E, CL1_S12E, CL1_S13E, CL1_S33E, CL1_S44E, CL1_S11D, CL1_S12D, CL1_S13D, CL1_S33D, CL1_S44D, CL1_E31, CL1_E33, CL1_E15, CL1_D31, CL1_D33, CL1_D15, CL1_H31, CL1_H33, CL1_H15, CL1_G31, CL1_G33, CL1_G15, CL1_E11S, CL1_E33S, CL1_E11T, CL1_E33T), cl(CL1_C11E, CL1_C12E, CL1_C13E, CL1_C33E, CL1_C44E,
CL1_C11D, CL1_C12D, CL1_C13D, CL1_C33D, CL1_C44D, CL2_S11E, CL2_S12E, CL2_S13E, CL2_S33E, CL2_S44E, CL1_S11D, CL1_S12D, CL1_S13D, CL1_S33D, CL1_S44D, CL1_E31, CL1_E33, CL1_E15, CL1_D31, CL1_D33, CL1_D15, CL1_H31,
CL1_H33, CL1_H15, CL1_G31, CL1_G33, CL1_G15, CL1_E11S, CL1_E33S, CL1_E11T, CL1_E33T)) :- RC = 1, Re = 1, Rs = 1, !,
T1 = CL1_C33E * (CL1_C11E + CL1_C12E) - 2 * CL1_C13E * CL1_C13E, T2 = (CL1_C11E - CL1_C12E) * T1,
if_x_equals_0_then_1_else_x(T1, Temp1), if_x_equals_0_then_1_else_x(T2, Temp2), CL2_S11E = (CL1_C11E * CL1_C33E - CL1_C13E * CL1_C13E) / Temp2,
CL2_S12E = (CL1_C13E * CL1_C13E - CL1_C12E * CL1_C33E) / Temp2, CL2_S13E = -CL1_C13E / Temp1,
CL2_S33E = (CL1_C11E + CL1_C12E) / Temp1, CL2_S44E = 1.0 / CL1_C44E;
RC = 2, Re = 4, Rs = 1, !,
T1 = CL1_C33E * (CL1_C11E + CL1_C12E) - 2 * CL1_C13E * CL1_C13E, T2 = (CL1_C11E - CL1_C12E) * T1,
if_x_equals_0_then_1_else_x(T1, Temp1), if_x_equals_0_then_1_else_x(T2, Temp2), CL2_S11E = (CL1_C11E * CL1_C33E - CL1_C13E * CL1_C13E) / Temp2,
CL2_S12E = (CL1_C13E * CL1_C13E - CL1_C12E * CL1_C33E) / Temp2, CL2_S13E = -CL1_C13E / Temp1,
CL2_S33E = (CL1_C11E + CL1_C12E) / Temp1, CL2_S44E = 1.0 / CL1_C44E;
RC = 2, Re = 3, Rs = 2, !,
CL2_S11E = CL1_S11D + CL1_D31 * CL1_G31,
CL2_S12E = CL1_S12D + CL1_D31 * CL1_G31,
CL2_S13E = CL1_S13D + CL1_D31 * CL1_G33,
CL2_S33E = CL1_S33D + CL1_D33 * CL1_G33,
CL2_S44E = CL1_S44D + CL1_D15 * CL1_G15;
CL2_S11E = CL1_S11E, CL2_S12E = CL1_S12E, CL2_S13E = CL1_S13E, CL2_S33E = CL1_S33E, CL2_S44E = CL1_S44E. get_sd(RC, Re, Rs, cl(CL1_C11E, CL1_C12E, CL1_C13E, CL1_C33E, CL1_C44E, CL1_C11D, CL1_C12D, CL1_C13D, CL1_C33D, CL1_C44D, CL1_S11E, CL1_S12E, CL1_S13E, CL1_S33E, CL1_S44E, CL1_S11D, CL1_S12D, CL1_S13D, CL1_S33D,
CL1_S44D, CL1_E31, CL1_E33, CL1_E15, CL1_D31, CL1_D33, CL1_D15, CL1_H31, CL1_H33, CL1_H15, CL1_G31, CL1_G33, CL1_G15, CL1_E11S, CL1_E33S, CL1_E11T, CL1_E33T), cl(CL1_C11E, CL1_C12E, CL1_C13E, CL1_C33E, CL1_C44E,
CL1_C11D, CL1_C12D, CL1_C13D, CL1_C33D, CL1_C44D, CL1_S11E, CL1_S12E, CL1_S13E, CL1_S33E, CL1_S44E, CL2_S11D, CL2_S12D, CL2_S13D, CL2_S33D, CL2_S44D, CL1_E31, CL1_E33, CL1_E15, CL1_D31, CL1_D33, CL1_D15, CL1_H31,
CL1_H33, CL1_H15, CL1_G31, CL1_G33, CL1_G15, CL1_E11S, CL1_E33S, CL1_E11T, CL1_E33T)) :- RC = 1, Re = 1, Rs = 1, !,
T1 = CL1_C33D * (CL1_C11D + CL1_C12D) - 2 * CL1_C13D * CL1_C13D, T2 = (CL1_C11D - CL1_C12D) * T1,
if_x_equals_0_then_1_else_x(T1, Temp1), if_x_equals_0_then_1_else_x(T2, Temp2), CL2_S11D = (CL1_C11D * CL1_C33D - CL1_C13D * CL1_C13D) / Temp2,
CL2_S12D = (CL1_C13D * CL1_C13D - CL1_C12D * CL1_C33D) / Temp2, CL2_S13D = -CL1_C13D / Temp1,
CL2_S33D = (CL1_C11D + CL1_C12D) / Temp1, CL2_S44D = 1.0 / CL1_C44D;
20