ÌÈÍÈÑÒÅÑÒÂÎ ÎÁÀÇÎÂÀÍÈß È ÍÀÓÊÈ ÎÑÑÈÉÑÊÎÉ

ÔÅÄÅÀÖÈÈ
ÔÈËÈÀË ÔÅÄÅÀËÜÍÎ Î ÎÑÓÄÀÑÒÂÅÍÍÎ Î
ÀÂÒÎÍÎÌÍÎ Î ÎÁÀÇÎÂÀÒÅËÜÍÎ Î Ó×ÅÆÄÅÍÈß
ÂÛÑØÅ Î ÏÎÔÅÑÑÈÎÍÀËÜÍÎ Î ÎÁÀÇÎÂÀÍÈß
¾ÊÀÇÀÍÑÊÈÉ (ÏÈÂÎËÆÑÊÈÉ) ÔÅÄÅÀËÜÍÛÉ
ÓÍÈÂÅÑÈÒÅÒ¿
 . ÍÀÁÅÅÆÍÛÅ ×ÅËÍÛ
ÔÀÊÓËÜÒÅÒ ÏÈÊËÀÄÍÎÉ ÌÀÒÅÌÀÒÈÊÈ È
ÈÍÔÎÌÀÖÈÎÍÍÛÕ ÒÅÕÍÎËÎ ÈÉ

ÊÀÔÅÄÀ ÏÈÊËÀÄÍÎÉ ÌÀÒÅÌÀÒÈÊÈ È
ÈÍÔÎÌÀÒÈÊÈ
Ñïåöèàëüíîñòü: 010501.65  Ïðèêëàäíàÿ ìàòåìàòèêà è èíîðìàòèêà

ÂÛÏÓÑÊÍÀß ÊÂÀËÈÔÈÊÀÖÈÎÍÍÀß ÀÁÎÒÀ
(Äèïëîìíàÿ ðàáîòà)

×èñëåííîå ìîäåëèðîâàíèå ïëîñêîãî
âçðûâà çàêðóãë¼ííîãî çàðÿäà
ýëëèïòè÷åñêîé îðìû ñ èñïîëüçîâàíèåì
òåõíîëîãèè ìíîãîïîòî÷íîñòè 
åãèñòðàöèîííûé íîìåð 
àáîòà çàâåðøåíà:
¾
¿
2011 ã.

Ì. À. Ñàðîíîâ, ãð. 4606 

àáîòà äîïóùåíà ê çàùèòå:

Íàó÷íûé ðóêîâîäèòåëü
ä. .-ì. í., ïðîåññîð
¾
¿
2011 ã.

Ë. Ì. Êîòëÿð

Çàâ. êàåäðîé
ä. -ì. í., ïðîåññîð
¿
2011 ã.
¾ 

. Õ. Ëàòûïîâ

Íàáåðåæíûå ×åëíû  2011 ãîä

Ñîäåðæàíèå

Ââåäåíèå

6

1

9

Àíàëèòè÷åñêèé îáçîð

1.1
1.2
1.3
2

9
10
12

Ôîðìóëèðîâàíèå êàðòèíû âçðûâà ñîãëàñíî ÒÆÌ

14

2.1
2.2

14
15

2.3
3

Îáçîð èññëåäîâàíèé ïî ìàòåìàòè÷åñêîìó ìîäåëèðîâàíèþ
âçðûâîâ . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Îáçîð òåõíîëîãèè ïàðàëëåëüíûõ âû÷èñëåíèé è ñîâðåìåííûõ òåõíèê å¼ ïðèìåíåíèÿ . . . . . . . . . . . . . . . . . .
Âûáîð ÿçûêà ïðîãðàììèðîâàíèÿ . . . . . . . . . . . . . . .
Ïîñòàíîâêà êðàåâîé çàäà÷è, ýêâèâàëåíòíîé èñõîäíîé . . .
Âûâîä ðåøåíèÿ äëÿ êðàåâîé çàäà÷è . . . . . . . . . . . . .
2.2.1 Êîìïëåêñíûé ïîòåíöèàë íà ïëîñêîñòè âñïîìîãàòåëüíîãî ïåðåìåííîãî . . . . . . . . . . . . . . . . . . . .
2.2.2 Âûðàæåíèå êîìïëåêñíîãî ïîòåíöèàëà ÷åðåç óíêöèþ Æóêîâñêîãî . . . . . . . . . . . . . . . . . . . .
2.2.3 àçëîæåíèå óíêöèè Æóêîâñêîãî íà ïðÿìîëèíåéíóþ ÷àñòü è êîððåêòèðóþùóþ óíêöèþ . . . . . . .
2.2.4 Êðèâèçíà êðàÿ çàðÿäà ýëëèïòè÷åñêîé îðìû . . . .
Âû÷èñëåíèå êîîðäèíàò òî÷åê íà ãðàíèöå âîðîíêè âçðûâà .

16
16
17
22
22

×èñëåííîå ðåøåíèå çàäà÷è

24

3.1
3.2

24
25
25
26
27
27
28

3.3
3.4

Ïðåäñòàâëåíèå ïàðàìåòðîâ ìîäåëè â ïðîãðàììå . . . . . .
Ïðåäñòàâëåíèå àíàëèòè÷åñêîãî ðåøåíèÿ çàäà÷è â ïðîãðàììå
3.2.1 Ïðîãðàììèðîâàíèå ÷èñëåííîãî èíòåãðèðîâàíèÿ . .
3.2.2 Âû÷èñëåíèå çíà÷åíèé òåòà-óíêöèé . . . . . . . . .
3.2.3 Âû÷èñëåíèå çíà÷åíèé óíêöèè dw/du . . . . . . . .
3.2.4 Âû÷èñëåíèå çíà÷åíèé óíêöèè Æóêîâñêîãî χ(u) .
3.2.5 Âû÷èñëåíèå çíà÷åíèé êîððåêòèðóþùåé óíêöèè f (u)
3.2.6 Âû÷èñëåíèå êîýèöèåíòîâ cn â ðàçëîæåíèè f (u)
â ðÿä . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.7 Ïðîãðàììèðîâàíèå îòîáðàæåíèÿ çíà÷åíèé äîïîëíèòåëüíîãî ïåðåìåííîãî íà îáëàñòü èñõîäíîãî ïåðåìåííîãî . . . . . . . . . . . . . . . . . . . . . . . . .
Ïðîãðàììèðîâàíèå âû÷èñëåíèÿ êîîðäèíàò òî÷åê íà ãðàíèöå âîðîíêè âçðûâà . . . . . . . . . . . . . . . . . . . . . . .
Ïðîãðàììíûé ïàêåò äëÿ âûâîäà ãðàèêîâ óíêöèé ñðåäñòâàìè Haskell . . . . . . . . . . . . . . . . . . . . . . . . .
2

28
29
29
30

3.5
4

Ñáîðêà öåëüíîãî ïðèëîæåíèÿ ñ ó÷¼òîì ìíîãîïîòî÷íîñòè .

30

Àíàëèç ïîëó÷åííûõ ðåçóëüòàòîâ

33

4.1
4.2

33
34 

åçóëüòàòû âû÷èñëåíèé è èõ èíòåðïðåòàöèÿ . . . . . . . .
Îöåíêà ïðîèçâîäèòåëüíîñòè . . . . . . . . . . . . . . . . . .

Çàêëþ÷åíèå

37

Ñïèñîê ëèòåðàòóðû

39

Ïðèëîæåíèÿ

42

A
B
C

BlastModel.hs . . . . . . . . . . . . . . . . . . . . . . . . . .
Theta.hs . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Main.hs . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

42
50
51 

ååðàò
Ñàðîíîâ Ì. À. ×ÈÑËÅÍÍÎÅ ÌÎÄÅËÈÎÂÀÍÈÅ ÏËÎÑÊÎ Î
ÂÇÛÂÀ ÇÀ ËÓÁ˜ÍÍÎ Î ÇÀßÄÀ ÝËËÈÏÒÈ×ÅÑÊÎÉ ÔÎÌÛ
Ñ ÈÑÏÎËÜÇÎÂÀÍÈÅÌ ÒÅÕÍÎËÎ ÈÈ ÌÍÎ ÎÏÎÒÎ×ÍÎÑÒÈ, äèïëîìíàÿ ðàáîòà: ñòð. 41, ðèñ. 8, òàáë. 1, áèáë. íàçâ. 27.
Êëþ÷åâûå ñëîâà: ÌÀÒÅÌÀÒÈ×ÅÑÊÎÅ ÌÎÄÅËÈÎÂÀÍÈÅ, ÊÀÅÂÀß ÇÀÄÀ×À, ÒÅÎÈß ÑÒÓÉ, ÒœÄÎ-ÆÈÄÊÎÑÒÍÀß ÌÎÄÅËÜ, ÏÀÀËËÅËÜÍÎÅ ÏÎ ÀÌÌÈÎÂÀÍÈÅ, HASKELL. 
àññìàòðèâàåòñÿ ïëîñêèé âçðûâ çàãëóáë¼ííîãî çàðÿäà ýëëèïòè÷åñêîé 
îðìû â èìïóëüñíîé ïîñòàíîâêå. åøåíèå íàõîäèòñÿ ñ èñïîëüçîâàíèåì òâ¼ðäî-æèäêîñòíîé ìîäåëè Ëàâðåíòüåâà ìîäèèöèðîâàííûì ìåòîäîì
×àïëûãèíà. 
àçðàáîòàíà ïðîãðàììà, ÷èñëåííî ðàññ÷èòûâàþùàÿ êîîðäèíàòû òî÷åê ãðàíèöû âîðîíêè âçðûâà çàãëóáë¼ííîãî ýëëèïòè÷åñêîãî çàðÿäà, èñïîëüçóþùàÿ âîçìîæíîñòè ïàðàëëåëüíûõ âû÷èñëåíèé. Ïîêàçàíà ýåêòèâíîñòü ïðîãðàììèðîâàíèÿ â ñòèëå, ïðåäóñìàòðèâàþùåì âîçìîæíîñòü
âûïîëíåíèÿ ïðîãðàììû â ìíîãîÿäåðíîé ñðåäå, â òîì ÷èñëå ìíîãîïðîöåññîðíîé.

4

Óñëîâíûå îáîçíà÷åíèÿ è
ñîêðàùåíèÿ
ÏÎ
ÒÆÌ
GHC
ÎÑ
MB
χ(u)
φ0
v0

τ
α
κ
cn
ntheta
nintegral
ncn
ε 

ïðîãðàììíîå îáåñïå÷åíèå; 
òâ¼ðäî-æèäêîñòíàÿ ìîäåëü; 
Glasgow Haskell Compiler, íàçâàíèå òðàäèöèîííîãî
èçâåñòíåéøåãî êîìïèëÿòîðà Haskell; 
îïåðàöèîííàÿ ñèñòåìà; 
ìåãàáàéò; 
óíêöèÿ Æóêîâñêîãî; 
çíà÷åíèå ïîòåíöèàëà òå÷åíèÿ íà ïîâåðõíîñòè çàðÿäà; 
êðèòè÷åñêîå çíà÷åíèå ñêîðîñòè òå÷åíèÿ íà ñâîáîäíîé ïîâåðõíîñòè; 
ïàðàìåòð, òðåáóåìûé äëÿ ïîëíîãî çàäàíèÿ òåòàóíêöèé; 
óãîë â òî÷êàõ A è D îáëàñòè 2.1 òå÷åíèÿ; 
óíêöèÿ êðèâèçíû íà ãðàíèöå çàðÿäà; 
ïîñòîÿííûå ìíîæèòåëè èç ðàçëîæåíèÿ êîððåêòèðóþùåé óíêöèè (2.23) f (u) â ðÿä Ëîðàíà, n ∈ [0; ∞); 
÷èñëî ñëàãàåìûõ â ðÿäàõ (3.1) è (3.4), ïîçâîëÿþùèõ
âû÷èñëèòü çíà÷åíèå òåòà-óíêöèé ÷èñëåííî; 
÷àñòîòà ðàçáèåíèÿ îòðåçêà èíòåãðèðîâàíèÿ íà ñåòêó; 
êîëè÷åñòâî ïîñòîÿííûõ ìíîæèòåëåé cn â ðàçëîæåíèè f (u), à, ñëåäîâàòåëüíî, è êîëè÷åñòâî ñëàãàåìûõ
â í¼ì; 
æåëàåìàÿ òî÷íîñòü ïðè îïðåäåëåíèè êîýèöèåíòîâ
cn ÷èñëåííûìè ìåòîäàìè.

5

Ââåäåíèå
 ïîñëåäíåå âðåìÿ ïðè ïðîèçâîäñòâå ðàçëè÷íîãî ðîäà ðàáîò âñ¼ áîëåå øèðîêîå ïðèìåíåíèå íàõîäÿò òåõíîëîãèè, îñíîâàííûå íà èñïîëüçîâàíèè ýíåðãèè âçðûâà. Âçðûâ ïðåäñòàâëÿåò ñîáîé ñëîæíóþ öåïü èçèêîõèìè÷åñêèõ ïðîöåññîâ, âêëþ÷àþùóþ â ñåáÿ äåòîíàöèþ âçðûâ÷àòîãî âåùåñòâà, ðàñïðîñòðàíåíèå óäàðíûõ âîëí, àçîâûå ïðåâðàùåíèÿ, ïëàñòè÷åñêîå òå÷åíèå ñðåäû, äåîðìàöèþ è ðàçðóøåíèå. Äëÿ ïîëíîãî âñåñòîðîííåãî èçó÷åíèÿ âçðûâà â ñïëîøíîé ñðåäå ïðèìåíÿþòñÿ òàêèå òåîðèè,
êàê òåîðèÿ äåòîíàöèè, ãàçîâîé äèíàìèêè, òâ¼ðäîãî äåîðìèðóåìîãî òåëà, áàëëèñòèêè è ìíîãèå äðóãèå.
Îäíîé èç îñíîâíûõ çàäà÷, âîçíèêàþùèõ ïðè èñïîëüçîâàíèè âçðûâîâ
íà âûáðîñ, ÿâëÿåòñÿ çàäà÷à îïðåäåëåíèÿ ðàçìåðîâ è îðìû âîðîíîê (ïðè
âçðûâå ñîñðåäîòî÷åííûõ çàðÿäîâ) èëè âûåìîê (ïðè âçðûâå øíóðîâûõ
çàðÿäîâ) âûáðîñà â çàâèñèìîñòè îò ãåîìåòðèè îáëàñòè, ñâîéñòâ ãðóíòà,
ýíåðãåòè÷åñêîé õàðàêòåðèñòèêè çàðÿäà, à òàêæå åãî îðìû è ðàñïîëîæåíèÿ. Âàæíîñòü ýòîé çàäà÷è îáóñëîâëåíà øèðîêèì ïðèìåíåíèåì óäëèí¼ííûõ ëèíåéíî-ðàñïðåäåë¼ííûõ èëè øíóðîâûõ çàðÿäîâ ïðè ñòðîèòåëüñòâå
êàíàëîâ, äàìá è ò. ï.
Ñóùåñòâóþò ðàçëè÷íûå ïîäõîäû ê èññëåäîâàíèþ ýòîé çàäà÷è. Îäèí
èç íèõ ñîñòîèò â îáîáùåíèè îïûòà ïðèìåíåíèÿ âçðûâà è ýêñïåðèìåíòàëüíûõ äàííûõ è â ïîñòðîåíèè íà ýòîé îñíîâå ýìïèðè÷åñêèõ îðìóë
(ñì., íàïð., [15℄). Ïîëó÷àþùèåñÿ ïðè ýòîì îðìóëû äîâîëüíî ïðîñòû è
óäîáíû â èñïîëüçîâàíèè. Îäíàêî ïðèìåíèìîñòü èõ îãðàíè÷åíà, ò. ê. îíè
â îñíîâíîì ïîçâîëÿþò ðàññ÷èòûâàòü âçðûâû íà âûáðîñ â îäíîðîäíîì
ïîëóïðîñòðàíñòâå.
Äðóãîé ïîäõîä çàêëþ÷àåòñÿ â ñîçäàíèè ìàòåìàòè÷åñêèõ ìîäåëåé, îïèñûâàþùèõ îñíîâíûå ïðîöåññû, ïðîèñõîäÿùèå ïðè âçðûâå. ÿä àâòîðîâ
(ñì., íàïð., [1℄, [4℄) ïðè ïîñòðîåíèè òàêèõ ìîäåëåé ñòðåìÿòñÿ ó÷åñòü, ïî
âîçìîæíîñòè, âñå ñòîðîíû ÿâëåíèÿ. Ïðè ýòîì ïîÿâëÿåòñÿ âîçìîæíîñòü
èçó÷åíèÿ âëèÿíèÿ îòäåëüíûõ àêòîðîâ íà äåéñòâèå âçðûâà, íî èññëåäîâàíèå âçðûâà ñâîäèòñÿ ê ðåøåíèþ ñëîæíûõ ìàòåìàòè÷åñêèõ çàäà÷, òðåáóþùèõ ïðèâëå÷åíèÿ ñàìûõ ñîâðåìåííûõ ÝÂÌ. Âñëåäñòâèå ýòîãî ïðèìåíèìîñòü òàêèõ ìîäåëåé òàêæå îãðàíè÷åíà, è èñïîëüçóþò èõ ëèøü äëÿ
ðàñ÷¼òà åäèíè÷íûõ âçðûâîâ, â îñíîâíîì, ÿäåðíûõ.
Èç ñêàçàííîãî ÿñíî, ÷òî ïîáóæäàëî ìíîãèõ èññëåäîâàòåëåé ê ñîçäàíèþ ðàçëè÷íûõ ìîäåëåé âçðûâà â ãðóíòå. Ïðè ýòîì ñòðåìèëèñü, ÷òîáû
ìîäåëü ïîçâîëÿëà äîñòàòî÷íî ïîëíî èçó÷àòü îñíîâíûå ÿâëåíèÿ âçðûâà è
áûëà ñðàâíèòåëüíî ïðîñòà. Ïî-âèäèìîìó, íàèáîëåå òåîðåòè÷åñêè îáîñíîâàííîé ìîäåëüþ, ïîçâîëÿþùåé â ðÿäå ñëó÷àåâ íàõîäèòü îðìó âûåìêè
6

âûáðîñà ïðè âçðûâå øíóðîâîãî çàðÿäà, ÿâëÿåòñÿ òâ¼ðäî-æèäêîñòíàÿ ìîäåëü (ÒÆÌ) âçðûâà íà âûáðîñ, ïðåäëîæåííàÿ Ì. À. Ëàâðåíòüåâûì [11℄
è ïðèìåí¼ííàÿ âïåðâûå ê ðåøåíèþ êîíêðåòíûõ çàäà÷ Â. Ì. Êóçíåöîâûì [9℄, [10℄. Ñîãëàñíî ýòîé ìîäåëè, îñíîâàííîé íà èìïóëüñíî-ãèäðîäèíàìè÷åñêîé ïîñòàíîâêå [2℄, ãðàíèöà âûåìêè âûáðîñà íàõîäèòñÿ êàê
ëèíèÿ òîêà, âäîëü êîòîðîé ñêîðîñòü ïîñòîÿííà è ðàâíà êðèòè÷åñêîé, õàðàêòåðèçóþùåé ñðåäó.
Çà ïîñëåäíèå 20 ëåò, ïðîøåäøèõ ñ ìîìåíòà îïóáëèêîâàíèÿ ìîíîãðàèè [6℄, ñóäÿ ïî âñåìó, íå áûëî âûïóùåíî áîëüøå íè îäíîé ðàáîòû, â
êîòîðîé ïðèìåíÿëàñü áû ÒÆÌ êàê ñðåäñòâî ðåøåíèÿ ïðèêëàäíûõ çàäà÷ èñïîëüçîâàíèÿ âçðûâîâ íà âûáðîñ.
Çàäà÷à, ðàññìîòðåííàÿ â äàííîé ðàáîòå, ÿâëÿåòñÿ îáîáùåíèåì çàäà÷è,
ðåø¼ííîé â äðóãèõ ïîñòàíîâêàõ Êîòëÿðîì Ë. Ì. [8℄, Èëüèíñêèì Í. Á. [6℄
è Ìàðòûíþêîì Ï. À. [12℄. Â ðàáîòå [8℄ ðàññìàòðèâàåòñÿ êðèâîëèíåéíûé
íåçàãëóáë¼ííûé çàðÿä (ðàñïîëîæåííûé íà ïîâåðõíîñòè ãðóíòà), â ðàáîòå
[6℄ çàðÿä ïîëèãîíàëüíîé îðìû, à [12℄ ñâîäèò âçðûâ êðóãîâîãî çàðÿäà ê
âçðûâó òî÷å÷íîãî çàðÿäà, òåðÿÿ îáùíîñòü.
Ïîñòàíîâêà çàäà÷è. Òðåáóåòñÿ íàéòè ãåîìåòðè÷åñêîå ìåñòî òî÷åê, ðàñïîëîæåííûõ íà ãðàíèöå âîðîíêè âçðûâà çàðÿäà ýëëèïòè÷åñêîé 
îðìû, çàãëóáë¼ííîãî â ãðóíò. Äëÿ ïðîñòîòû âçðûâ ðàññìàòðèâàåòñÿ
íà äâóõìåðíîé ïëîñêîñòè, ÷òî ïîçâîëÿåò ýêñòðàïîëèðîâàòü ðåçóëüòàò äâîÿêî: êàê âçðûâ çàðÿäà â îðìå ýëëèïñîèäà âðàùåíèÿ, èëè êàê
âçðûâ øíóðîâîãî çàðÿäà ýëëèïòè÷åñêîãî ñå÷åíèÿ. 

àáîòà áóäåò ñîñòîÿòü èç äâóõ ýòàïîâ. Íà ïåðâîì ýòàïå ìû ïîñòðîèì
÷èñòî ìàòåìàòè÷åñêóþ ìîäåëü âçðûâà, ñîñòîÿùóþ èç îäíîé óíêöèè,
êîòîðàÿ ïîçâîëÿåò íàéòè èñêîìóþ ãðàíèöó âîðîíêè âçðûâà èñõîäÿ èç åãî 
èçè÷åñêèõ ïàðàìåòðîâ. Íà âòîðîì ýòàïå ìàòåìàòè÷åñêàÿ ìîäåëü áóäåò
òðàíñëèðîâàíà â ïðîãðàììíûé êîä, ïîçâîëÿþùèé èññëåäîâàòü ìîäåëü
ñðåäñòâàìè ïåðñîíàëüíîãî êîìïüþòåðà.
 ïîñëåäíèå ãîäû (20062010 è äàëåå) íàáëþäàåòñÿ çíà÷èòåëüíûé
òðåíä íà èñïîëüçîâàíèå ìíîãîïðîöåññîðíûõ (â íàñòîëüíûõ ñèñòåìàõ 
ìíîãîÿäåðíûõ) òåõíîëîãèé â êîìïüþòåðíîé èíäóñòðèè [25℄, îáóñëîâëåííûé òåõíîëîãè÷åñêèìè òðóäíîñòÿìè, ïðåïÿòñòâóþùèìè ðàçâèòèþ òðàäèöèîííûõ îäíîïðîöåññîðíûõ/îäíîÿäåðíûõ ðåøåíèé. Ìíîãîïðîöåññîðíûé ïîäõîä ïðåäïîëàãàåò ðàçðàáîòêó ïðîãðàììíîãî îáåñïå÷åíèÿ, ÿâíî
ïðåäóñìàòðèâàþùåãî åãî âîçìîæíîå âûïîëíåíèå â ñðåäå, ñïîñîáíîé âûïîëíÿòü íåêîòîðûå âû÷èñëåíèÿ ïàðàëëåëüíî. Äëÿ ðàçðàáîòêè òàêîãî ðîäà ¾ïàðàëëåëüíîãî¿ ÏÎ òðåáóåòñÿ èñïîëüçîâàòü âïîëíå îïðåäåë¼ííûå
ìåòîäèêè ïðîãðàììèðîâàíèÿ, îäíàêî, ïðåèìóùåñòâà â âèäå ìíîãîêðàòíîãî óâåëè÷åíèÿ ïðîèçâîäèòåëüíîñòè, ïîëó÷åííûå ïðè èõ èñïîëüçîâàíèè, ïåðåâåøèâàþò ñëîæíîñòè ðàçðàáîòêè.
Òàêèì îáðàçîì, äîïîëíèòåëüíûå òðåáîâàíèÿ ê ðåøåíèþ çàäà÷è ñëåäóþùèå. Çàïðîãðàììèðîâàòü âû÷èñëåíèÿ ïîëó÷åííîé íà ïåðâîì
7

ýòàïå ìàòåìàòè÷åñêîé ìîäåëè òàêèì îáðàçîì, ÷òîáû â íàèáîëåå âîçìîæíî ïîëíîé ìåðå âîñïîëüçîâàòüñÿ âîçìîæíîñòÿìè ìíîãîïðîöåññîðíîé/ìíîãîÿäåðíîé àðõèòåêòóðû ñîâðåìåííîé âû÷èñëèòåëüíîé òåõíèêè.

Öåëüþ

íàñòîÿùåé ðàáîòû ÿâëÿåòñÿ:

1 ðåøèòü çàäà÷ó, ÿâëÿþùóþñÿ îáîáùåíèåì áîëåå ðàííèõ ðàáîò â äàííîé îáëàñòè;
2 ïðåäîñòàâèòü ñðåäñòâî ðàñ÷¼òîâ ðåàëüíûõ ãðàíèö âîðîíîê îò âçðûâîâ, ìàñøòàáèðóåìîå è ïðèãîäíîå äëÿ âûïîëíåíèÿ íà âûñîêîïðîèçâîäèòåëüíîé âû÷èñëèòåëüíîé òåõíèêå, ýêñïëóàòèðóþùåé ïàðàëëåëüíîñòü âû÷èñëåíèé.

8

ëàâà 1. Àíàëèòè÷åñêèé îáçîð
1.1

Îáçîð èññëåäîâàíèé ïî
ìàòåìàòè÷åñêîìó ìîäåëèðîâàíèþ
âçðûâîâ

Èññëåäîâàíèþ ìåõàíèçìà âçðûâà â ãðóíòàõ â ñåðåäèíå XX âåêà ïîñâÿùåíî ìíîãî ðàáîò. Èíòåðåñ ê ýòîé òåìå áûë âûçâàí êàê ïðàêòè÷åñêèìè, òàê è òåîðåòè÷åñêèìè ñîîáðàæåíèÿìè. Ñëîæíîñòü ÿâëåíèÿ, áîëüøîé
äèàïàçîí èçìåíåíèé ïàðàìåòðîâ (íàïðÿæåíèé, ñêîðîñòåé è äð.), ðàçíîîáðàçèå óñëîâèé è íàçíà÷åíèÿ âçðûâà ïðåäñòàâëÿþò áëàãîïðèÿòíóþ è
óâëåêàòåëüíóþ òåìó äëÿ èññëåäîâàòåëÿ, äëÿ åãî èçîáðåòàòåëüíîñòè è
èíòóèöèè. Áîëüøîå çíà÷åíèå ïðè ýòîì èìååò è ïðàêòè÷åñêîå èñïîëüçîâàíèå âçðûâîâ â ãðóíòàõ è ãîðíûõ ïîðîäàõ. Âçðûâû ïðèìåíÿþòñÿ ïðè
ðàçðàáîòêå ïîëåçíûõ èñêîïàåìûõ, ïðè ïðîõîäêå òðàíøåé, ïðè ñîîðóæåíèè ïëîòèí. Íàïðèìåð, áîëüøàÿ ïëîòèíà â Ìåäåî (áëèç Àëìà-Àòû) è
ãèäðîòåõíè÷åñêèé êîìïëåêñ â Íóðåêå (Òàäæèêèñòàí) áûëè ñîîðóæåíû ñ
èñïîëüçîâàíèåì ýíåðãèè âçðûâà.
Ïîñëå ðàáîò Î. Å. Âëàñîâà, ïðèìåíèâøåãî èìïóëüñíî-ãèäðîäèíàìè÷åñêóþ ïîñòàíîâêó (È Ï) ê èçó÷åíèþ âçðûâà, è ïèîíåðñêèõ ðàáîò
Ì. À. Ëàâðåíòüåâà è Â. Ì. Êóçíåöîâà, ïîñòàâèâøèõ è ðåøèâøèõ ðÿä êðàåâûõ çàäà÷ òåîðèè âçðûâà, ïîÿâèëîñü áîëüøîå êîëè÷åñòâî ñòàòåé, ïîñâÿù¼ííûõ èññëåäîâàíèþ çàäà÷ âçðûâà â È Ï (ê 1990 ã. èõ áèáëèîãðàèÿ
íàñ÷èòûâàëà ñâûøå 150 íàèìåíîâàíèé; áîëüøàÿ èõ ÷àñòü áûëà âûïîëíåíà â Íîâîñèáèðñêå, Êèåâå, Êàçàíè è Ìîñêâå). Èç ìîíîãðàèé, â êîòîðûõ
ðàññìàòðèâàþòñÿ çàäà÷è âçðûâà â È Ï, áëèæå âñåãî ê òåìå íàñòîÿùåé
ðàáîòû êíèãà Â. Ì. Êóçíåöîâà [10℄ è êíèãà Èëüèíñêîãî [6℄.
Èñïîëüçóþùàÿñÿ â äàííîé ðàáîòå òâ¼ðäî-æèäêîñòíàÿ ìîäåëü ñèëüíî
ñõåìàòèçèðóåò ÿâëåíèå, íà çàòî îíà ïðèâîäèò åãî ê ñðàâíèòåëüíî ïðîñòîìó ìàòåìàòè÷åñêîìó îïèñàíèþ. Îñíîâíîå óïðîùåíèå â èìïóëüñíîé ìîäåëè ñîñòîèò â òîì, ÷òî ñðåäà ïðåäïîëàãàåòñÿ íåñæèìàåìîé, â ðåçóëüòàòå
÷åãî èñ÷åçàåò èç ïîëÿ çðåíèÿ âîëíîâîé ïðîöåññ è ìàòåìàòè÷åñêè çàäà÷à ñâîäèòñÿ ê êðàåâîé çàäà÷å äëÿ ýëëèïòè÷åñêèõ óðàâíåíèé (â ñëó÷àå
íåñæèìàåìîé ñðåäû  ê çàäà÷å äëÿ óðàâíåíèÿ Ëàïëàñà). Ïðè ïîìîùè
òàêîé ìîäåëè, êîíå÷íî, íåëüçÿ îòâåòèòü íà âñå âîïðîñû; îäíàêî íà íåêîòîðûå (íå òîëüêî êà÷åñòâåííûå, íî è êîëè÷åñòâåííûå) îòâåò ïîëó÷àåòñÿ
ñ äîñòàòî÷íîé ñòåïåíüþ ïðèáëèæåíèÿ.
 äàííîé ðàáîòå ðåøàåòñÿ ñàìàÿ î÷åâèäíàÿ çàäà÷à, êîòîðàÿ ìîæåò
9

áûòü ðåøåíà ïðè ïîìîùè ÒÆÌ  çàäà÷à îïðåäåëåíèÿ ãðàíèöû âîðîíêè âûáðîñà.  èìïóëüñíîé ìîäåëè îñòàëñÿ íåäîñòàòî÷íî îáîñíîâàííûì
âûáîð êðèòåðèÿ, îïðåäåëÿþùåãî ýòó ãðàíèöó. Ïðè÷èíà âîçíèêàþùåé ïðè
ýòîì òðóäíîñòè ïîíÿòíà  çäåñü ñòàâèòñÿ âîïðîñ î êðèòåðèè ïðî÷íîñòè,
êðèòåðèè ðàçðóøåíèÿ, ò. å. âîçíèêàåò íîâûé èçè÷åñêèé âîïðîñ, êîòîðûé íå ìîæåò áûòü ðåø¼í ïðîñòûì ìîäåëèðîâàíèåì ñðåäû íåñæèìàåìîé
æèäêîñòüþ. Îáû÷íûì ðåøåíèåì äàííîé ïðîáëåìû ÿâëÿåòñÿ âûáîð ãðàíèöû âîðîíêè âûáðîñà êàê ëèíèè òîêà, íà êîòîðîé óíêöèÿ òîêà ïðèíèìàåò îïðåäåë¼ííîå ¾êðèòè÷åñêîå¿ çíà÷åíèå, çàâèñÿùåå îò ïàðàìåòðîâ
ñðåäû.
Ìåòîä ðåøåíèÿ ïîñòàâëåííîé çàäà÷è îñíîâàí íà ìåòîäå, óñïåøíî ïðèìåí¼ííîì â ðàáîòå Ë. Ì. Êîòëÿðà [8℄ äëÿ íåçàãëóáë¼ííîãî çàðÿäà. Îòëè÷èå îò ðàáîòû [8℄ â çàãëóáëåíèè çàðÿäà è ïðèäàíèþ åìó ýëëèïòè÷åñêîé 
îðìû, ò. å., àêòè÷åñêè, â ïåðåõîäå ê áîëåå îáîáù¼ííîé çàäà÷å. Ìåòîä
Ë. Ì. Êîòëÿðà îñíîâûâàåòñÿ íà íåêîòîðûõ ìîäèèêàöèÿõ ìåòîäà ×àïëûãèíà [3℄ è èñïîëüçîâàíèè òåòà-óíêöèé [16℄ äëÿ ïîñòðîåíèÿ èñêîìûõ 
óíêöèé. 
àáîòà [6℄, ïî-âèäèìîìó, áûëà ïîñëåäíåé èç îïóáëèêîâàííûõ ïî òåìå èñïîëüçîâàíèÿ ÒÆÌ âî âçðûâíîì äåëå. Íèêàêèõ ðàáîò ñ 1986 ãîäà
áîëüøå íå èçäàâàëîñü, ïîýòîìó, äàííàÿ ðàáîòà ïðèîáðåòàåò îñîáóþ àêòóàëüíîñòü êàê âîçîáíîâëÿþùàÿ ïðåðâàííûå ïî òåì èëè èíûì ïðè÷èíàì
èññëåäîâàíèÿ.
 íàñòîÿùåå âðåìÿ (íà÷àëî 2011 ãîäà) èç îáùåäîñòóïíûõ è îòíîñèòåëüíî èçâåñòíûõ ñðåäñòâ ìîäåëèðîâàíèÿ âçðûâîâ ÿâëÿþòñÿ ñïåöèàëèçèðîâàííûå ïðîãðàììíûå ïàêåòû äëÿ ïåðñîíàëüíîãî êîìïüþòåðà, òàêèå,
êàê LS-DYNA [13℄. àñ÷¼ò â ýòèõ ïðîãðàììàõ âåä¼òñÿ ïðè ïîìîùè ðàçëè÷íûõ ñåòî÷íûõ ìåòîäîâ, ðàññ÷èòûâàþùèõ âçðûâ êàê îïðåäåë¼ííóþ
äåîðìàöèþ ñïëîøíîé ñðåäû. Òàêîé ïîäõîä èñêëþ÷èòåëüíî ðåñóðñîçàòðàòíûé, îñîáåííî ïðè íåîáõîäèìîñòè ñîáëþäàòü âûñîêóþ òî÷íîñòü ðàñ÷¼òîâ, è ðàñ÷¼òû ïî áîëåå ïðîñòîé ìàòåìàòè÷åñêîé ìîäåëè, òàêîé êàê
ÒÆÌ, â íåêîòîðûõ ñëó÷àÿõ áóäåò ýåêòèâíåå, ÷åì èñïîëüçîâàíèå ïîäîáíûõ ïðîãðàììíûõ ïàêåòîâ.
1.2

Îáçîð òåõíîëîãèè ïàðàëëåëüíûõ
âû÷èñëåíèé è ñîâðåìåííûõ òåõíèê å¼
ïðèìåíåíèÿ

Âñå ñîâðåìåííûå ìèêðîïðîöåññîðû èìåþò äâà èëè áîëüøå ÿäåð è
îòíîñèòåëüíî ñêîðî ìîæíî îæèäàòü, ÷òî êîëè÷åñòâî ÿäåð âûðàñòåò äî
äåñÿòêîâ èëè ñîòåí. Áîëüøå íåëüçÿ ðàññ÷èòûâàòü íà òî, ÷òî ïðîèçâîäèòåëüíîñòü êàæäîãî îòäåëüíîãî ÿäðà áóäåò ðàñòè è äàëüøå. Åäèíñòâåííûé
10

ñïîñîá äîñòè÷ü óâåëè÷åíèÿ ïðîèçâîäèòåëüíîñòè îò êàæäîãî ñëåäóþùåãî
ïîêîëåíèÿ ÷èïîâ  ðàçäåëèòü ðàáîòó ïðîãðàììû íà ìíîæåñòâî îáðàáàòûâàþùèõ äàííûå ÿäåð. 
àçäåëèòü ïðèëîæåíèå íà ìíîæåñòâî îáðàáàòûâàþùèõ ÿäåð âîçìîæíî, åñëè êàêèì-ëèáî îáðàçîì àâòîìàòè÷åñêè ðàñïàðàëëåëèòü ïîñëåäîâàòåëüíûé êîä. Äàííûé ïîäõîä ÿâëÿåòñÿ òåêóùåé îáëàñòüþ èññëåäîâàíèé
â îáëàñòè êîìïüþòåðíûõ íàóê. Äðóãîé ïîäõîä çàêëþ÷àåòñÿ â íàïèñàíèè
ïîëó-ÿâíî èëè ÿâíî ïàðàëëåëüíûõ ïðîãðàìì, êîòîðûå çàòåì áóäóò ðàñïðåäåëåíû íà ìíîæåñòâî ÿäåð îïåðàöèîííîé ñèñòåìîé è ýòî èìåííî òîò
òîò ïîäõîä, êîòîðûé áóäåò èñïîëüçîâàòüñÿ â äàííîé ðàáîòå.
Ñëåäóåò ðàçäåëèòü ïîíÿòèÿ ¾ïàðàëëåëüíûå¿, ¾parallel ¿, âû÷èñëåíèÿ
è ¾îäíîâðåìåííûå¿1 , ¾ on urrent ¿ âû÷èñëåíèÿ. Ïàðàëëåëüíàÿ ïðîãðàììà íàïèñàíà ñ êîíêðåòíîé öåëüþ âîñïîëüçîâàòüñÿ ïîòåíöèàëîì èñòèííî ïàðàëëåëüíîãî âû÷èñëèòåëüíîãî ðåñóðñà, òàêîãî, êàê ìíîãîÿäåðíîãî
ïðîöåññîðà. Îò ïàðàëëåëüíîé ïðîãðàììû ìû îæèäàåì èñòèííî îäíîâðåìåííîãî âûïîëíåíèÿ. Îäíîâðåìåííîñòü æå ÿâëÿåòñÿ òåõíèêîé ñòðóêòóðèðîâàíèÿ ïðîãðàììíîãî îáåñïå÷åíèÿ, êîòîðàÿ ïîçâîëÿåò ñìîäåëèðîâàòü
âû÷èñëåíèÿ â âèäå ãèïîòåòè÷åñêè íåçàâèñèìûõ äåéñòâèé, êîòîðûå ìîãóò
ñèíõðîíèçèðîâàòüñÿ è ñâÿçûâàòüñÿ äðóã ñ äðóãîì.
Íàïèñàíèå îäíîâðåìåííûõ è ïàðàëëåëüíûõ ïðîãðàìì  ãîðàçäî áîëåå ñëîæíàÿ çàäà÷à, ÷åì íàïèñàíèå ïîñëåäîâàòåëüíûõ ïðîãðàìì. Îäíàêî, ñóùåñòâóþò ñåðü¼çíûå ïðè÷èíû äëÿ íàïèñàíèÿ îäíîâðåìåííûõ è
ïàðàëëåëüíûõ ïðîãðàìì:
1

Ïðîèçâîäèòåëüíîñòü.

×òîáû ïîëó÷èòü óâåëè÷åíèå ïðîèçâîäèòåëüíîñòè ñ êàæäûì íîâûì ïîêîëåíèåì ìíîãîÿäåðíûõ ïðîöåññîðîâ, íàì ñëåäóåò ïèñàòü ïàðàëëåëüíûå ïðîãðàììû.

2

Ñîêðûòèå çàäåðæåê.

3

Ñòðóêòóðèðîâàíèå ÏÎ.

4

Îäíîâðåìåííîñòü â ðåàëüíîñòè.

Äàæå íà îäíîÿäåðíûõ ïðîöåññîðàõ ìû ìîæåì èñïîëüçîâàòü îäíîâðåìåííûå ïðîãðàììû äëÿ òîãî, ÷òîáû
ñêðûòü îò ïîëüçîâàòåëÿ îæèäàíèå ìåäëåííûõ îïåðàöèé ââîäà/âûâîäà íà äèñêè è ñåòåâûå óñòðîéñòâà.
Íåêîòîðûå âèäû çàäà÷ ìîãó áûòü óäîáíûì îáðàçîì ïðåäñòàâëåíû â âèäå ìíîæåñòâà ñâÿçàííûõ äðóã ñ
äðóãîì íèòåé âûïîëíåíèÿ, ÷òî ïîìîãàåò ñòðóêòóðèðîâàòü êîä áîëåå
ìîäóëüíûì îáðàçîì. Íàïðèìåð, ìîæíî ìîäåëèðîâàòü êîìïîíåíòû
ïîëüçîâàòåëüñêîãî èíòåðåéñà êàê îòäåëüíûå íèòè âûïîëíåíèÿ.
 ðàñïðåäåë¼ííûõ ñèñòåìàõ è
ñèñòåìàõ ðåàëüíîãî âðåìåíè ïðèõîäèòñÿ ìîäåëèðîâàòü è ðåàãèðî-

1 Óñòîÿâøåãîñÿ

on urrent íà ðóññêèé ÿçûê íåò. Ïîýòîìó äëÿ ÿñíîñòè, òàê êàê
on urrent êðàéíå çíà÷èòåëüíà, âåçäå äàëåå â òåêñòå áóäåò èñïîëüçî-

ïåðåâîäà òåðìèíà

ðàçíèöà â òåðìèíàõ

parallel

è

âàíî âûðàæåíèå ¾îäíîâðåìåííàÿ ïðîãðàììà¿ êàê ïåðåâîä ðàçû ¾ on urrent program¿

11

âàòü íà ñîáûòèÿ â ðåàëüíîì ìèðå, íàïðèìåð, îáðàáàòûâàòü ìíîãî÷èñëåííûå çàïðîñû ê ñåðâåðó, ïàðàëëåëüíî.
Ñîâðåìåííûå ìèêðîïðîöåññîðû èñïîëüçóþò òàê íàçûâàåìûé threadlevel parallelism, ¾ïàðàëëåëèçì íà óðîâíå íèòåé âûïîëíåíèÿ¿ [25, ñòð. 195℄.
Ýòî îçíà÷àåò, ÷òî ó÷àñòêè êîäà, êîòîðûå äîëæíû âûïîëíÿòüñÿ ïàðàëëåëüíî (åñëè ýòî âîçìîæíî), óêàçûâàþòñÿ ÿâíî èëè ïîëó-ÿâíî ðàçðàáîò÷èêîì ïðîãðàììíîãî îáåñïå÷åíèÿ. Áóäóò ëè ýòè ó÷àñòêè äåéñòâèòåëüíî âûïîëíÿòüñÿ ïàðàëëåëüíî, çàâèñèò îò êîìïèëÿòîðà ïðîãðàììû è îò
îïåðàöèîííîé ñèñòåìû, êîòîðàÿ áóäåò å¼ âûïîëíÿòü.  ëþáîì ñëó÷àå,
äëÿ îïèñàíèÿ ïàðàëëåëèçìà âûïîëíåíèÿ ïðîãðàììû èñïîëüçóþò ïîíÿòèå ¾íèòü âûïîëíåíèÿ¿ (¾thread¿). Íèòü âûïîëíåíèÿ èíêàïñóëèðóåò âû÷èñëåíèÿ, êîòîðûå äîëæíû âûïîëíÿòüñÿ îäíîâðåìåííî ñ äðóãèìè íèòÿìè.
 íàñòîÿùåå âðåìÿ ñóùåñòâóåò íåñêîëüêî âûñîêîóðîâíåâûõ òåõíèê
ïîñòðîåíèÿ ïàðàëëåëüíûõ ïðîãðàìì, íàïðèìåð, MapRedu e [19℄, Software
Transa tional Memory [26℄ èëè ìîäåëü àêòîðîâ [21℄.
 ïðîãðàììå, êîòîðàÿ áóäåò ðåàëèçîâàíà â ðàìêàõ äàííîãî ïðîåêòà, áóäåò èñïîëüçîâàíà êàê èñòèííàÿ ïàðàëëåëüíîñòü ÷èñòî ìàòåìàòè÷åñêèõ âû÷èñëåíèé, òàê è òåõíèêà îäíîâðåìåííîñòè îïåðàöèé ââîäà/âûâîäà. Âû÷èñëåíèÿ è äèàëîã ñ ïîëüçîâàòåëåì áóäóò ïðîèçâîäèòüñÿ îäíîâðåìåííî, ÷òî ïîçâîëèò, íàïðèìåð, â ïåðñïåêòèâå  çàïóñòèòü ïàðàëëåëüíî
íåñêîëüêî âû÷èñëåíèé èç îäíîãî ýêçåìïëÿðà ïðîãðàììû. Äëÿ óâåëè÷åíèÿ ïðîèçâîäèòåëüíîñòè æå áóäåò èñïîëüçîâàí ïàðàëëåëèçì âûïîëíåíèÿ
íåêîòîðûõ âû÷èñëèòåëüíûõ îïåðàöèé â ïðîãðàììå.
1.3

Âûáîð ÿçûêà ïðîãðàììèðîâàíèÿ

Äëÿ ïðîãðàììèðîâàíèÿ âû÷èñëåíèé, ñ ó÷¼òîì òðåáîâàíèé, ïðåäúÿâëåííûõ ê çàäà÷å, áûë âûáðàí ÿçûê Haskell [24℄.
Haskell ÿâëÿåòñÿ ÷èñòî óíêöèîíàëüíûì ñòðîãî òèïèçèðîâàííûì ÿçûêîì ïðîãðàììèðîâàíèÿ ñ ¾ëåíèâîé¿ ìîäåëüþ âû÷èñëåíèé. Îí îäíîâðåìåííî êàê èíòåðïðåòèðóåìûé, òàê è êîìïèëèðóåìûé (äîñòóïíû êàê èíòåðïðåòàòîð Haskell, òàê è êîìïèëÿòîð). Âîçìîæíî çàíèìàòüñÿ îòëàäêîé
ïðîãðàììû â èíòåðïðåòàòîðå, ñ ïîñëåäóþùåé êîìïèëÿöèåé èñõîäíîãî êîäà â íàòèâíîå ïðèëîæåíèå, íå òðåáóþùåå èíòåðïðåòàòîðà äëÿ âûïîëíåíèÿ.
Èíòåðïðåòèðóåìîñòü ïðîãðàìì íà Haskell îáëåã÷àåò èõ îòëàäêó, íàïèñàíèå è ïåðåíîñèìîñòü. Ôóíêöèîíàëüíàÿ ïàðàäèãìà ïðîãðàììèðîâàíèÿ,
ëåæàùàÿ â îñíîâå ýòîãî ÿçûêà, îáëåã÷àåò ïåðåîðìóëèðîâàíèå ìàòåìàòè÷åñêèõ âûêëàäîê, êîòîðûå áóäóò ÿâëÿòüñÿ ðåøåíèåì ïîñòàâëåííîé çàäà÷è, â ïðîãðàììíûé êîä.
12

Áîëåå òîãî, ñèíòàêñèñ è âûðàçèòåëüíîñòü Haskell ïîçâîëÿþò â íåêîòîðûõ ñëó÷àÿõ ïåðåïèñûâàòü ìàòåìàòè÷åñêèå âûðàæåíèÿ â ïðîãðàììíûé
êîä ¾îäèí-ê-îäíîìó¿, áåç èçäåðæåê íà ïåðåîðìóëèðîâàíèå â äðóãèå àáñòðàêöèè, ÷òî ÿâëÿåòñÿ îáÿçàòåëüíûì ïðè èñïîëüçîâàíèè èìïåðàòèâíûõ
ÿçûêîâ, òàêèõ, êàê C [27℄.
Èíòåðïðåòàòîð è êîìïèëÿòîð Haskell íå ïîääåðæèâàþò êðîññ-êîìïèëÿöèþ, íî ñàìè ñêîìïèëèðîâàíû äëÿ ìíîãèõ ïëàòîðì, è ÿâëÿþòñÿ
ïðèëîæåíèÿìè ñ îòêðûòûì èñõîäíûì êîäîì, ÷òî ïîçâîëÿåò ïåðåíîñèòü
ïðîãðàììû, íàïèñàííûå íà Haskell, îòíîñèòåëüíî ïðîñòûìè ìåòîäàìè.
Äëÿ Haskell èìååòñÿ îáøèðíàÿ áèáëèîòåêà ïàêåòîâ, âêëþ÷àþùàÿ â
ñåáÿ ïàêåò äëÿ ÷åð÷åíèÿ ïðîèçâîëüíûõ ãðàèêîâ óíêöèé
Graphi s.Rendering.Chart [20℄, à òàêæå ïàêåò äëÿ ïîääåðæêè èñòèííî
ïàðàëëåëüíûõ âû÷èñëåíèé Control.Parallel [23℄ è ïàêåò äëÿ ïîääåðæêè
îäíîâðåìåííîñòè âûïîëíåíèÿ Control.Con urrent [18℄. Ñëåäóåò çàìåòèòü,
÷òî çàâèñèìîñòè, íàëè÷åñòâóþùèå äëÿ ïàêåòà Graphi s.Rendering.Chart,
çíà÷èòåëüíî óñëîæíÿò ñáîðêó ïðèëîæåíèÿ äëÿ ÎÑ Windows, òàê êàê â
ýòîé îïåðàöèîííîé ñèñòåìå îòñóòñòâóåò ñòàíäàðòíûé óäîáíûé äëÿ èñïîëüçîâàíèÿ èç êîìàíäíîé ñòðîêè êîìïèëÿòîð ÿçûêà C.
×èñòûé ïàðàëëåëèçì â Haskell ñîõðàíÿåò äåòåðìèíèçì îïåðàöèé, ïîýòîìó åãî âêëþ÷åíèå â ïðîãðàììíûé êîä íå ìåíÿåò ðåçóëüòàòà.
Ñ 2004 ãîäà òðàäèöèîííûé êîìïèëÿòîð Haskell, ¾GHC¿ ïîääåðæèâàåò
êîìïèëÿöèþ ïðîãðàìì, ñïîñîáíûõ âûïîëíÿòüñÿ ïàðàëëåëüíî íà ìíîãîÿäåðíûõ ìàøèíàõ. Äëÿ ýòîãî òðåáóåòñÿ êîìïèëèðîâàòü ñ ëàãîì
-threaded, è çàïóñêàòü ïðèëîæåíèå ñ àðãóìåíòàìè êîìàíäíîé ñòðîêè
+RTS -Nn, ãäå n  ýòî êîëè÷åñòâî ÿäåð, íà êîòîðûå ìîæíî ðàññ÷èòûâàòü
â òåêóùåé ñðåäå âûïîëíåíèÿ. Çàïóùåííîå â òàêîì ðåæèìå ïðèëîæåíèå
áóäåò ïûòàòüñÿ ðàñïàðàëëåëèâàòü âûïîëíåíèå ó÷àñòêîâ êîäà, ÿâíî ïîìå÷åííûõ ðàçðàáîò÷èêîì êàê äîëæíûå âûïîëíÿòüñÿ îäíîâðåìåííî.
Òàêæå ìîæíî äîáèòüñÿ ïîâûøåíèÿ ïðîèçâîäèòåëüíîñòè ïðèëîæåíèÿ
íà ÿçûêå Haskell, ñêîìïèëèðîâàííîãî â ïàðàëëåëüíîì ðåæèìå, ÿâíî óêàçàâ ðàçìåð êó÷è è ñòåêà, äîñòóïíûõ äëÿ ïðèëîæåíèÿ. Óâåëè÷åíèå êó÷è
âåä¼ò ê óìåíüøåíèþ êîëè÷åñòâà çàïóñêîâ ñáîðùèêà ìóñîðà â ñëó÷àå òðåáîâàòåëüíûõ ê ðåñóðñàì âû÷èñëåíèé, à êàæäûé çàïóñê ñáîðùèêà ìóñîðà
óìåíüøàåò ïðîèçâîäèòåëüíîñòü ïðèëîæåíèÿ. 
àçìåð êó÷è óêàçûâàåòñÿ àðãóìåíòîì êîìàíäíîé ñòðîêè äëÿ ïðèëîæåíèÿ, íàïðèìåð -K100M óêàçûâàåò èñïîëüçîâàòü 100 MB äëÿ ñòåêà, à
-H800MB óêàçûâàåò èñïîëüçîâàòü 800 MB äëÿ êó÷è.

13

ëàâà 2. Ôîðìóëèðîâàíèå
êàðòèíû âçðûâà ñîãëàñíî
ÒÆÌ
Ñëåäóÿ Ì. À. Ëàâðåíòüåâó, ðàññìîòðèì çàäà÷ó òåîðèè âçðûâà â èìïóëüñíîé ïîñòàíîâêå.  ýòîì ñëó÷àå òå÷åíèå, âîçíèêàþùåå ïîä äåéñòâèåì èìïóëüñíîãî äàâëåíèÿ, ÿâëÿåòñÿ ïîòåíöèàëüíûì. Åñëè ïðåíåáðå÷ü
ñæèìàåìîñòüþ ñðåäû, å¼ ïðî÷íîñòíûìè è ïëàñòè÷åñêèìè ñâîéñòâàìè,
à òàêæå ñèëàìè òðåíèÿ è ãðàâèòàöèè, òî ìû ïðèä¼ì ê èçó÷åíèþ äâèæåíèÿ èäåàëüíîé íåñæèìàåìîé íåâåñîìîé æèäêîñòè. ðóíò, íà êîòîðûé
äåéñòâóåò çàðÿä, ìîäåëèðóåòñÿ, òàêèì îáðàçîì, ñðåäîé, äâèæóùåéñÿ êàê
èäåàëüíàÿ íåñæèìàåìàÿ æèäêîñòü ïðè ñêîðîñòÿõ áîëüøå íåêîòîðîé êðèòè÷åñêîé ñêîðîñòè v0 è ÿâëÿåòñÿ àáñîëþòíî òâ¼ðäûì òåëîì ïðè ñêîðîñòÿõ, ìåíüøèõ v0 .
2.1

Ïîñòàíîâêà êðàåâîé çàäà÷è,
ýêâèâàëåíòíîé èñõîäíîé

Ïðåäñòàâèì ñîãëàñíî òâ¼ðäî-æèäêîñòíîé ìîäåëè äâóìåðíûé âçðûâ
çàãëóáë¼ííîãî çàðÿäà íà äâóìåðíîì åâêëèäîâîì ïðîñòðàíñòâå â äåêàðòîâûõ êîîðäèíàòàõ êàê ïëîñêîå ïîòåíöèàëüíîå óñòàíîâèâøååñÿ òå÷åíèå
èäåàëüíîé íåâåñîìîé æèäêîñòè íà ïëîñêîñòè êîìïëåêñíîãî ïåðåìåííîãî z = x + iy . Îñü îðäèíàò íàïðàâëåíà ïî ãîðèçîíòàëüíîé ïîâåðõíîñòè,
îñü àáñöèññ  ëèíèÿ ñèììåòðèè è íàïðàâëåíà âåðòèêàëüíî âíèç.  ñèëó ñèììåòðèè áóäåì ðàññìàòðèâàòü òîëüêî ïðàâóþ ïîëîâèíó òå÷åíèÿ.
Òàêèì îáðàçîì, ðàññìàòðèâàåìàÿ îáëàñòü òå÷åíèÿ îãðàíè÷åíà êðèâîëèíåéíûì ó÷àñòêîì AD, ïðÿìîëèíåéíûìè ó÷àñòêàìè AB è CD è ëèíèåé
òîêà CB (ñì. ðèñ. 2.1).
Îáîçíà÷èì ÷åðåç πγ/2 óãîë, îáðàçîâàííûé êàñàòåëüíîé ê çàðÿäó è
ãîðèçîíòàëüíîé ïîâåðõíîñòüþ â òî÷êå D (ðèñ. 2.1). Äîâîëüíî î÷åâèäíî,
÷òî äëÿ òîãî, ÷òîáû êàðòèíà âçðûâà ñîîòâåòñòâîâàëà ðèñ. 2.1, äîëæíî
âûïîëíÿòüñÿ óñëîâèå γ < 1. Ââåä¼ì îáëàñòü Gu âñïîìîãàòåëüíîãî ïåðåìåííîãî u = ξ + iη â âèäå ïðÿìîóãîëüíèêà 0 < ξ < π/4, 0 < η < π|τ |/4 ñ
ñîîòâåòñòâèåì òî÷åê, óêàçàííûì íà ðèñ. 2.2.
Ñëåäóåò íàéòè îòîáðàæåíèå z(u) òàêîå, ÷òî îíî êîíîðìíî îòîáðàæàåò ïðÿìîóãîëüíèê ABCD èç ïðîñòðàíñòâà u íà îáëàñòü ABCD èç
ïðîñòðàíñòâà z .
14

0

C

D

y

πγ/2

z

A

B

~v

x 
èñ. 2.1. Èñõîäíàÿ ñõåìà ìîäåëè

η
πτ
4

A:

B

u

π
4

+

πτ
4

~v

C

D

0

π
4

ξ 

èñ. 2.2. Îáëàñòü äîïîëíèòåëüíîãî ïåðåìåííîãî u
Ïàðàìåòð τ çàäàí òàê, ÷òîáû Im τ > 0 è Re τ = 0.
2.2

Âûâîä ðåøåíèÿ äëÿ êðàåâîé çàäà÷è

Íàì äîñòàòî÷íî ïîëó÷èòü dz/du, ÷òîáû íàéòè ∀z : z ∈ CB . Íóæíàÿ
ãðàíèöà áóäåò íàéäåíà èíòåãðèðîâàíèåì ïî u íà ñîîòâåòñòâóþùåé ñòîðîíå ïðÿìîóãîëüíèêà.
Ïðåäñòàâèì dz/du â âèäå ïðîèçâîäíîé ñëîæíîé óíêöèè:

dz
dz dw
=
·
du dw du
Âûâåäåì ïîñëåäîâàòåëüíî îáà ìíîæèòåëÿ ýòîãî ïðîèçâåäåíèÿ.

15

(2.1)

2.2.1

Êîìïëåêñíûé ïîòåíöèàë íà ïëîñêîñòè
âñïîìîãàòåëüíîãî ïåðåìåííîãî

Êîìïëåêñíûé ïîòåíöèàë w(u) íàä âñïîìîãàòåëüíûì ïåðåìåííûì u
ââîäèòñÿ ñëåäóþùèì îáðàçîì:
(2.2)

w(u) = ϕ(u) + iψ(u) 

àññìîòðèì w(u) êàê òî÷êó â ïîëå w = ϕ + iψ . Íàì èçâåñòíû èç
ïîñòàíîâêè çàäà÷è êðàåâûå óñëîâèÿ äëÿ w(u):
(2.3a)
(2.3b)
(2.3 )

CD : ϕ = 0
AD : ϕ = ϕ0
ABC : ψ = −ψ0

Ïðîèçâîäíàÿ êîìïëåêñíîãî ïîòåíöèàëà dw/du èìååò â îáëàñòè Gu
íóëü ïåðâîãî ïîðÿäêà â òî÷êå B (íàðóøàåòñÿ êîíîðìíîñòü îòîáðàæåíèÿ) è ïîëþñ ïåðâîãî ïîðÿäêà â òî÷êå D (âèõðü èíòåíñèâíîñòè 4ϕ0 ). Êàê
âèäíî èç ðèñ. 2.1, dw/du ÷èñòî ìíèìà íà BCD è âåùåñòâåííà íà BAD.
Ñëåäîâàòåëüíî, å¼ ìîæíî ïðîäîëæèòü ïî ïðèíöèïó ñèììåòðèè íà âñþ
ïëîñêîñòü. Íà îñíîâàíèè òåîðèè ýëëèïòè÷åñêèõ óíêöèé [16, ñòð. 350℄,
íàéä¼ì    

ϑ1 u − πτ4 ϑ1 u + πτ4 ϑ2 u − πτ4 ϑ2 u + πτ4
dw    

(2.4)
= iN
du
ϑ1 u − π4 ϑ1 u + π4 ϑ4 u − π4 ϑ4 u + π4
ãäå N  âåùåñòâåííàÿ ïîëîæèòåëüíàÿ ïîñòîÿííàÿ, ϑk (u), k = 1, 2, 3, 4 
òýòà-óíêöèè äëÿ ïåðèîäîâ π è πτ [16, ñòð. 334℄.
Îïðåäåëÿÿ èç (2.4) âû÷åò óíêöèè w(u) â òî÷êå D, âûðàçèì ïîñòîÿííóþ N ÷åðåç âåëè÷èíó ϕ0 :
!2
ϕ0 M
ϑ2 (0)ϑ3(0)ϑ4(0)
N=
,
M =2
(2.5) 

ϑ1 π + πτ 2
π
4

2.2.2

4

Âûðàæåíèå êîìïëåêñíîãî ïîòåíöèàëà ÷åðåç 
óíêöèþ Æóêîâñêîãî

Äëÿ òîãî, ÷òîáû âûðàçèòü dz/dw èç (2.1), ââåä¼ì óíêöèþ Æóêîâñêîãî [3, ñ. 30℄:

dw
v
= ln − iΘ ≡ r − iΘ
(2.6)
v0dz
v0
ãäå Θ  óãîë íàêëîíà âåêòîðà ñêîðîñòè ê îñè Ox, v  ìîäóëü ñêîðîñòè
â òî÷êå u, v0  ñêîðîñòü íà ñâîáîäíîé ïîâåðõíîñòè CD.
χ(u) = ln

16

Èç ðèñ. 2.1 ïîëó÷èì ãðàíè÷íûå óñëîâèÿ äëÿ χ(u) íà ïðÿìîëèíåéíûõ
ó÷àñòêàõ îáëàñòè òå÷åíèÿ:

AB : Im χ(u) u=ξ+ πτ = 0
(2.7a)
4

CD : Im χ(u) u=ξ = −π
(2.7b)

CB : Re χ(u) u=iη = 0
(2.7 )
Äëÿ òîãî, ÷òîáû ïîëó÷èòü êðàåâîå óñëîâèå íà AD, ñäåëàåì ñëåäóþùåå.
Ïóñòü íà êðèâîëèíåéíîé äóãå AD çàäàí ∠β , îáðàçîâàííûé êàñàòåëüíîé ñ îñüþ àáñöèññ, ïðè ýòîì β = β(s), ãäå s  äëèíà äóãè, îòñ÷èòûâàåìàÿ îò òî÷êè A è îòíåñ¼ííàÿ ê ïîëíîé äëèíå l äóãè AD. Òîãäà
π
áåçðàçìåðíàÿ êðèâèçíà äóãè κ(β) = dβ
ds , è, òàê êàê β = Θ − 2 , òî

dΘ dΘ du dΘ du
=
·
=
·
κ(Θ) =
(2.8)
ds
du ds
du dz
Òåïåðü, ó÷èòûâàÿ (2.4), (2.5) è (2.8) ïîëó÷èì óñëîâèå äëÿ χ(u) íà AD:

ãäå δ =
2.2.3

ϕ0
v0 lπ

dz dw

=
= δMκ(Θ)
·

dw du
π 

= δMκ(Θ) F
+ iη e−r(η)
4

(2.9) 

áåçðàçìåðíûé ïàðàìåòð. 

àçëîæåíèå óíêöèè Æóêîâñêîãî íà
ïðÿìîëèíåéíóþ ÷àñòü è êîððåêòèðóþùóþ 
óíêöèþ

Ïðåäñòàâèì χ(u) â ñëåäóþùåì âèäå:

χ(u) = χ0 (u) − f (u)

(2.10)

χ0 (u) ïðåäñòàâëÿåò ñîáîé óíêöèþ Æóêîâñêîãî äëÿ óïðîù¼ííîé çàäà÷è, èçîáðàæ¼ííîé íà ðèñ. 2.3, à óíêöèÿ f (u) ÿâëÿåòñÿ ñïåöèàëüíîé 
óíêöèåé, êîòîðàÿ ìîäèèöèðóåò óïðîù¼ííóþ êàðòèíó, âíîñÿ â íå¼ èçìåíåíèÿ, íåîáõîäèìûå äëÿ âîçâðàòà ê èñõîäíîé êàðòèíå ÿâëåíèÿ.

17

0

C

D
πγ/2

y

~v

B

z

A

x 
èñ. 2.3. Óïðîù¼ííàÿ ñõåìà çàäà÷è
Äëÿ χ0 äîëæíû âûïîëíÿòüñÿ ñëåäóþùèå ãðàíè÷íûå óñëîâèÿ:

CD : Im χ0 (u) u=ξ = −π
(2.11a)  

γ
AD : Im χ0 (u) u= π +iη = −π 1 −
(2.11b)
4
2 

γ

AB : Im χ0 (u) u=ξ+ πτ = −π 1 −
(2.11 )
4
2

BC : Re χ0 (u) u=iη = 0
(2.11d)

Ñëåäîâàòåëüíî, χ0 (u) èìååò â D ëîãàðèìè÷åñêóþ îñîáåííîñòü ñ âû÷åòîì −γ .
Êðàåâûå óñëîâèÿ äëÿ êîððåêòèðóþùåé óíêöèè f (u) íàéä¼ì ïîçäíåå.
Ôóíêöèÿ Æóêîâñêîãî äëÿ óïðîù¼ííîé çàäà÷è

Òàê êàê

dχ0
∂ Re χ0
∂ Im χ0
∂ Im χ0
∂ Re χ0
=
+i
=
−i
du
∂ξ
∂ξ
∂η
∂η

(2.12)

0
òî dχ
÷èñòî âåùåñòâåííà íà CD è BA è ÷èñòî ìíèìà
du 
π íà 
BC è ADπτ. Çíà
π
÷èò, å¼ ìîæíî ïðîäîëæèòü íà ïðÿìîóãîëüíèê ξ ∈ − 2 ; 2 , η ∈ −3 4 , πτ
4
ñîîòâåòñòâåííî ðèñ. 2.4.
Ôóíêöèþ χ0 áóäåì èñêàòü â âèäå êîìáèíàöèè òåòà-óíêöèé (ñì. [16,
ñ. 334℄). Òàê êàê ïîëó÷åííûé ïðÿìîóãîëüíèê ïî ðàçìåðàì ñîâïàäàåò ñ
ïåðèîäè÷íîñòüþ òåòà-óíêöèé, òî òàêîå îïðåäåëåíèå χ0 àâòîìàòè÷åñêè
îïðåäåëèò å¼ íà âñåé ïëîñêîñòè.

18

η

πτ
4

D3

− π2

b

u
B

A

C

D

0

− π4

π|τ |

b

π
4

π
2

ξ

− πτ
4
D4

D2
b

− πτ
2

b

− 3πτ
4
π 

èñ. 2.4. Ñõåìà îòîáðàæåíèÿ χ0 ïî ïðèíöèïó ñèììåòðèè
Ïðåäñòàâèì χ0 â âèäå
4

dχ0 X
d
=
Ak ln ϑ1 (u − bk )
du
du

(2.13)

k=1

ãäå Ak  ýòî âû÷åòû óíêöèè χ0 â å¼ ïîëþñàõ bk , k = 1, 2, 3, 4.
Äëÿ òî÷åê D è D2 âû÷åò ðàâíÿåòñÿ −γ . Äëÿ òî÷åê D3 è D4 âû÷åò ðàâíÿåòñÿ γ . Èõ ñóììà ðàâíà íóëþ, ÷òî ïîçâîëÿåò íàì èñïîëüçîâàòü (2.13):   

dχ0
d
π
π πτ 

ln ϑ1 u +
+ ln ϑ1 u + −

du
du
4
4
2 

(2.14)  

π
π πτ 
− ln ϑ1 u −
+ ln ϑ1 u − −
4
4
2
Òàê êàê 

πτ 
ϑ1 u −
= N ϑ4 (u)
2
1
N = −ieiu+ 4 iπτ
(ñì. ðèñ. 2.5) òî

Îòêóäà  

ϑ1 u + π4 ϑ4 u + π4
dχ0
d  

= γ ln
du
du ϑ1 u − π4 ϑ4 u − π4  

ϑ1 u + π4 ϑ4 u + π4  

χ0 (u) = C + γ ln
ϑ1 u − π4 ϑ4 u − π4
19

(2.15)

(2.16)

u+ π2

Θ1 (u)
u+ πτ
2

-

Θ2 (u)

-

Θ3 (u)

6
u+ π2

Θ4 (u) 

èñ. 2.5. Ñîîòíîøåíèå ìåæäó òåòà-óíêöèÿìè
Äëÿ îïðåäåëåíèÿ êîíñòàíòû èíòåãðèðîâàíèÿ C âîñïîëüçóåìñÿ êðàåâûìè óñëîâèÿìè (2.11) äëÿ χ0 . Îòêóäà ïîëó÷èì êîíå÷íîå âûðàæåíèå äëÿ
χ0 :  

ϑ1 u + π4 ϑ4 u + π4  

χ0 (u) = −iπ(γ − 1) + γ ln
(2.17)
ϑ1 u − π4 ϑ4 u − π4
Êîððåêòèðóþùàÿ óíêöèÿ

f (u)

f (u)  àíàëèòè÷åñêàÿ óíêöèÿ, çàêëþ÷àþùàÿ â ñåáå îòëè÷èÿ óïðîù¼ííîé ñõåìû âçðûâà îò äàííîé èçíà÷àëüíî.
ðàíè÷íûå óñëîâèÿ f (u) íàéä¼ì, ñðàâíèâàÿ ãðàíè÷íûå óñëîâèÿ (2.7)
äëÿ χ(u) è (2.11) äëÿ χ0 (u):

AB : Im f (u) u=ξ+ πτ = 0
(2.18a)
4

CD : Im f (u) u=ξ = 0
(2.18b)

BC : Re f (u) u=iη = 0
(2.18 )
π 

d

AD :
Im f (u) u= π +iη = δMκ(Θ) F
+ iη e−r(η)
(2.18d)
4

4
Äëÿ ïîñòðîåíèÿ f (u) âîñïîëüçóåìñÿ òåì, ÷òî íåêîòîðûå óíêöèè
ìîæíî ðàçëîæèòü â ðÿä Ëîðàíà.
Îòîáðàçèì îáëàñòü u íà ïîëóêîëüöî ρ 6 |ζ| 6 1 ñ ïîìîùüþ ñëåäóþùåé óíêöèè (ñì., íàïð., [17, ñ. 107℄):

ζ=e

4u−π
|τ |

ρ = e− |τ |
π

,

(2.19) 

àññìîòðèì óíêöèþ

γ
p(ζ) = f (u(ζ)) + ln ζ 1 −
2 

(2.20)

Ýòà óíêöèÿ óäîâëåòâîðÿåò ãðàíè÷íîìó óñëîâèþ
Im ζ ⇒ Im p(ζ) = 0
20

(2.21)

Îòñþäà ñëåäóåò, ÷òî å¼ ìîæíî ïðîäîëæèòü íà âñ¼ êîëüöî è íà êîëüöå
ìîæíî ïðåäñòàâèòü â âèäå ðÿäà Ëîðàíà
+∞
X

p(ζ) =

cn ζ n

(2.22)

n=−∞

À òîãäà

(4u − π) 1 −
f (u) = −
|τ |

γ
2 

+∞
X

cn e

4u−π
|τ |

(2.23)

n=−∞

Âîñïîëüçóåìñÿ óñëîâèåì (2.18 ) äëÿ òîãî, ÷òîáû íàéòè íåêîòîðûå èç
êîýèöèåíòîâ cn : 

+∞ 
γ 

X

πn
πn
π
1

4ηn

2
Re f (iη)
+
=0
= c0 +
cn e |τ | + c−n e |τ | cos

|

|
πτ
η∈[0; 4 ]
n=1
(2.24)
Èç (2.24) ïîëó÷èì:
π
π 
γ
c0 = −
1−
,
c−n = −cn ρ2n , ρ = e− |τ |
(2.25)
|τ |
2
Òåïåðü âîñïîëüçóåìñÿ óñëîâèåì (2.18d):
+∞
X 

γ
π
1 − γ2
n
4n
2n
4
Cn
1 − ρ cos η − 4
= δMκ(Θ)Q(η)e− |τ | (1− 2 ) (2.26)
|τ |
|τ |
|τ |
n=1  

P
4n
ϑ2 π + iη − πτ ϑ2 π + iη + πτ 2 +∞
cn (1−ρ2n ) cos |τ

4
4
4
4
n=1
Q(η) =
e
(2.27)
|ϑ2(iη)ϑ3(iη)|1+γ |ϑ1 (iη)ϑ4(iη)|1−γ

Èíòåãðèðóÿ (2.26) ïî η â ïðåäåëàõ îò 0 äî πτ
íàéä¼ì óñëîâèå, êîòî4
ðîìó äîëæíû óäîâëåòâîðÿòü êîýèöèåíòû cn : 

γ
π
γ
−π 1 −
= δMe−π |τ | (1− 2 ) I0,
(2.28)
2
π|τ |

I0 =

Z2

κ(Θ)Q(η)dη.

(2.29)

0

cn :

Äîìíîæèâ (2.28) íà cos 4n
|τ | η è èíòåãðèðóÿ â òåõ æå ïðåäåëàõ, âûðàçèì 

2 1 − γ2
In
cn = −
·
,
n(1 + ρ2n ) I0

(2.30)

4n
η dη.
|τ |

(2.31)

π|τ |

In =

Z2

κ(Θ)Q(η) cos

0

21

Òàê êàê óðàâíåíèå (2.30) ÿâëÿåòñÿ âûðàæåíèåì cn = A(c1 , c2 . . . cn ),
ãäå A  äåéñòâèòåëüíîçíà÷íàÿ óíêöèÿ, òî êîíñòàíòû cn áóäåì íàõîäèòü â ïðîöåññå ðåøåíèÿ çàäà÷è ìåòîäîì ïðîñòîé èòåðàöèè [7, ñ. 150℄. Çà
íà÷àëüíîå ïðèáëèæåíèå áóäåì áðàòü âåêòîð c0 , c1 . . . cn , n ∈ N, n < ∞.
Ñëåäóåò îòìåòèòü, ÷òî çíà÷åíèÿ êîýèöèåíòîâ cn ìîãóò áûòü íàéäåíû ëþáûì äðóãèì ÷èñëåííûì ìåòîäîì, ïîçâîëÿþùèì ðåøàòü ñèñòåìû
íåëèíåéíûõ óðàâíåíèé, íàïðèìåð, ìåòîäîì êîëëîêàöèè [5, ñòð. 353℄.
2.2.4

Êðèâèçíà êðàÿ çàðÿäà ýëëèïòè÷åñêîé îðìû

 äàííîé ðàáîòå ðàññìàòðèâàåòñÿ ñëó÷àé, ïðè êîòîðîì çàðÿä, ãðàíèöà êîòîðîãî ïðîõîäèò ïî ëèíèè AD, èìååò ýëëèïòè÷åñêóþ îðìó. Òîãäà
êðèâèçíà κ(Θ), ó÷àñòâóþùàÿ â ãðàíè÷íîì óñëîâèè äëÿ óíêöèè Æóêîâñêîãî (2.9), à îòòóäà  â âûðàæåíèè êîýèöèåíòîâ cn (2.30), èìååò
âèä:

1 − ε2 sin2 Θ
κ(Θ) =
p 

3/2

,

a2
p = 2,
b

p
b2 − a2
ε=
b

(2.32)

ãäå a, b  ïîëóîñè ýëëèïñà.
2.3

Âû÷èñëåíèå êîîðäèíàò òî÷åê íà
ãðàíèöå âîðîíêè âçðûâà

Èòàê, çíàÿ (2.1), (2.4), (2.6), (2.17) è (2.23) ñîðìóëèðóåì ïîëíîå âûðàæåíèå äëÿ èñêîìîé óíêöèè:    

ϑ1 u − πτ4 ϑ1 u + πτ4 ϑ2 u − πτ4 ϑ2 u + πτ4
dz
N
eiπ(1−γ)ef (u)
=      

1−γ
1+γ
du
v 0 ϑ1 u − π ϑ4 u − π
ϑ1 u + π4 ϑ4 u + π4
4
4
(2.33)
ãäå N îïðåäåëåíà âûðàæåíèåì (2.5).
Çíàÿ âåëè÷èíû N/v0, τ , γ è óíêöèþ f (u) (àêòè÷åñêè, êîýèöèåíòû cn , âõîäÿùèå â å¼ âûðàæåíèå), ìîæíî íàéòè âñå ãåîìåòðè÷åñêèå è
ãèäðîäèíàìè÷åñêèå ýëåìåíòû òå÷åíèÿ. Äëÿ ðåøåíèÿ ïîñòàâëåííîé çàäà÷è äîñòàòî÷íî íàéòè òîëüêî íåêîòîðûå ãåîìåòðè÷åñêèå õàðàêòåðèñòèêè.
Êîîðäèíàòû òî÷åê íà ãðàíèöå CB íà ïëîñêîñòè ïåðåìåííîãî z áóäåì
îïðåäåëÿòü ïîñëåäîâàòåëüíûì èíòåãðèðîâàíèåì (2.33) ÷èñëåííî.  êà÷åñòâå îñíîâíîé îðìóëû äëÿ ïîñòðîåíèÿ òî÷åê ãðàíèöû CB èñïîëüçóåì
âûðàæåíèå
Zu0
dz
du
z(u0 ) =
(2.34)
du
0

22

Òàêèì îáðàçîì, äëÿ ëþáîé òî÷êè ãðàíèöû CB , êîîðäèíàòû ìîæíî
ïîëó÷èòü èç îðìóë (2.34) è (2.33), çíàÿ, ÷òî:

z(E)

E∈CB

=

dz
(iη)dη,
du

E = iε,

0

πτ i
ε ∈ 0;
4
h

(2.35)

Òî÷êè, êîîðäèíàòû êîòîðûõ ïîëó÷åíû âûðàæåíèåì (2.35), ÿâëÿþòñÿ
òî÷êàìè, ëåæàùèìè íà ãðàíèöå âîðîíêè âçðûâà, ÷òî è òðåáîâàëîñü íàéòè
â çàäà÷å. Ñëåäóåò çàìåòèòü, ÷òî îðìóëà (2.34) ïîçâîëÿåò íàéòè, âîîáùå
ãîâîðÿ, ëþáóþ òî÷êó èç îáëàñòè z , à íå òîëüêî ëåæàùóþ íà ãðàíèöå CB .

23

ëàâà 3. ×èñëåííîå ðåøåíèå
çàäà÷è
Ïîëó÷èâ òî÷íîå àíàëèòè÷åñêîå ðåøåíèå ïîñòàâëåííîé çàäà÷è, ìû âûïîëíèëè ïåðâûé ýòàï ðàáîòû. Òåïåðü ïåðåíåñ¼ì âûâåäåííûå îðìóëû â
ïðîãðàììíûé êîä Haskell äëÿ òîãî, ÷òîáû èìåòü âîçìîæíîñòü óäîñòîâåðèòüñÿ â òîì, ÷òî ìîäåëü ðàáîòîñïîñîáíà.
 ýòîé ãëàâå ìû ïîñëåäîâàòåëüíî ïåðåíåñ¼ì âñå îòäåëüíûå îðìóëû, âûâåäåííûå â ãëàâå 2, çàòåì ââåä¼ì ìîäóëü äëÿ ÷åð÷åíèÿ ãðàèêîâ 
óíêöèé è, íàêîíåö, ñâåä¼ì âñ¼ âîåäèíî â öåëüíîì ïðèëîæåíèè. Ñëåäóåò
ó÷åñòü, ÷òî ðàñ÷¼ò íà ïàðàëëåëüíîñòü âûïîëíåíèÿ äîëæåí áûòü èíòåãðèðîâàí â ïðîãàììíûé êîä.
3.1

Ïðåäñòàâëåíèå ïàðàìåòðîâ ìîäåëè â
ïðîãðàììå

 ìîäåëè èñïîëüçóþòñÿ ñëåäóþùèå ïîñòîÿííûå ïàðàìåòðû, êîòîðûå
äîëæíû áûòü çàäàíû èçâíå:
1 φ0  Çíà÷åíèå ïîòåíöèàëà òå÷åíèÿ íà ïîâåðõíîñòè çàðÿäà;
2 v0  Êðèòè÷åñêîå çíà÷åíèå ñêîðîñòè òå÷åíèÿ íà ñâîáîäíîé ïîâåðõíîñòè;
3 τ  Ïàðàìåòð, òðåáóåìûé äëÿ ïîëíîãî çàäàíèÿ òåòà-óíêöèé;
4 α  Óãîë â òî÷êàõ A è D îáëàñòè 2.1 òå÷åíèÿ;
5 a  Ìàëûé ðàäèóñ êðèâèçíû ýëëèïñà êðèâîëèíåéíîãî çàðÿäà;
6 b  Áîëüøîé ðàäèóñ êðèâèçíû ýëëèïñà êðèâîëèíåéíîãî çàðÿäà;
7 cn , n ∈ [0; ∞)  Ïîñòîÿííûå ìíîæèòåëè èç ðàçëîæåíèÿ êîððåêòèðóþùåé óíêöèè (2.23) f (u) â ðÿä Ëîðàíà.
Êðîìå òîãî, âû÷èñëèòåëüíûé õàðàêòåð ðåøåíèÿ ïîñòàâëåííîé çàäà÷è
ïîäðàçóìåâàåò èñïîëüçîâàíèå ðÿäà äîïîëíèòåëüíûõ ïàðàìåòðîâ:
1 ntheta  ×èñëî ñëàãàåìûõ â ðÿäàõ (3.1) è (3.4), ïîçâîëÿþùèõ âû÷èñëèòü çíà÷åíèå òåòà-óíêöèé ÷èñëåííî;
24

2 nintegral  ×àñòîòà ðàçáèåíèÿ îòðåçêà èíòåãðèðîâàíèÿ íà ñåòêó;
3 ncn  Êîëè÷åñòâî ïîñòîÿííûõ ìíîæèòåëåé cn â ðàçëîæåíèè f (u),
à, ñëåäîâàòåëüíî, è êîëè÷åñòâî ñëàãàåìûõ â í¼ì;
4 ε  Æåëàåìàÿ òî÷íîñòü ïðè îïðåäåëåíèè êîýèöèåíòîâ cn ÷èñëåííûìè ìåòîäàìè.
Äëÿ õðàíåíèÿ ýòèõ ïàðàìåòðîâ â ïðîãðàììå áûë îïðåäåë¼í òèï äàííûõ, ïðåäíàçíà÷åííûé äëÿ õðàíåíèÿ âñåãî ìàññèâà ïàðàìåòðîâ. Ïðåäïîëàãàåòñÿ, ÷òî â ïðîöåññå âûïîëíåíèÿ ïðîãðàììû áóäåò ñîçäàí îäèí
ýêçåìïëÿð ýòîãî òèïà, êîòîðûé áóäåò ïåðåäàâàòüñÿ âî âñå âñïîìîãàòåëüíûå óíêöèè, ó÷àñòâóþùèå â âû÷èñëåíèÿõ.

data ModelParams = ModelParams {
−− \tau, passed to Fun tions.Theta(qpar)
tau
:: Double,
3
phi_0
:: Double,
−− \phi_0
4
v_0
:: Double,
−− v_0
5
alpha
:: Double,
−− \alpha
−− long ellipse radius
6
a
:: Double,
7
b
:: Double,
−− short ellipse radius
8
n_theta :: Integer ,
−− number of addends in \Theta_4 and \Theta_3
9
n_integral :: Integer ,
−− number of elements in numeri integration
10
n_ n
:: Integer ,
−− number of addends in f(u), essentially number of _n
11
pre ision :: Double,
−− pre ision of al ulating fu king _n's
12
_n
:: [ Double℄ −− list of _n, it should be omputed separately
13
} deriving ( Show)
Òèï ModelParams íàñëåäóåò êëàññ Show äëÿ òîãî, ÷òîáû áûë ïðîñòîé
1
2

ñïîñîá âèçóàëèçèðîâàòü âåñü ìàññèâ ïàðàìåòðîâ. Èñïîëüçîâàíèå òèïà
ModelParams ïîçâîëÿåò ïåðåäàâàòü â óíêöèè, ó÷àñòâóþùèå â âû÷èñëåíèÿõ, òîëüêî îäèí àðãóìåíò, êîòîðûé õðàíèò ïàðàìåòðû ìîäåëè, âìåñòî
îäèííàäöàòè.
3.2

Ïðåäñòàâëåíèå àíàëèòè÷åñêîãî
ðåøåíèÿ çàäà÷è â ïðîãðàììå

3.2.1

Ïðîãðàììèðîâàíèå ÷èñëåííîãî
èíòåãðèðîâàíèÿ

Äëÿ ÷èñëåííîãî èíòåãðèðîâàíèÿ èñïîëüçóåòñÿ ìåòîä òðàïåöèé [7, ñ. 86℄.
Âìåñòî òîãî, ÷òîáû îïðåäåëÿòü îáùóþ óíêöèþ èíòåãðèðîâàíèÿ, êîòîðóþ âñëåäñòâèå îñîáåííîñòåé èíòåãðàëîâ îò êîìïëåêñíîãî àðãóìåíòà
áûëî áû êðàéíå çàòðóäíèòåëüíî ñîðìóëèðîâàòü, áûëè îïðåäåëåíû äâå
ðàçëè÷íûå óíêöèè, îòëè÷àþùèåñÿ òèïàìè âõîäíûõ äàííûõ.
Ôóíêöèÿ integrateX èñïîëüçóåòñÿ äëÿ âû÷èñëåíèÿ îïðåäåë¼ííîãî èíòåãðàëà â âûðàæåíèè (2.30). Èíòåãðèðîâàíèå ïðîèçâîäèòñÿ ïî äåéñòâèòåëüíîé ÷àñòè ïåðåìåííîãî u.
25

1
2
3
4
5
6
7
8
9

integrateX :: ( RealFloat a, Enum a) => (Complex a −> Complex a) −>
a −> a −> Integer −> Complex a
integrateX f a b n =
(( sum $ map f xvalues) + t) ∗ (h :+ 0)

where

values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
xvalues = map (:+ 0) values
t = (f (a :+ 0) + f (b :+ 0))/2
h = (b − a) / fromInteger(n)

Ôóíêöèÿ integrateY èñïîëüçóåòñÿ äëÿ èíòåãðèðîâàíèÿ íà êîíå÷íîì ýòàïå âû÷èñëåíèé 3.3, â ïðîöåññå ïîëó÷åíèÿ êîîðäèíàò òî÷åê íà îáëàñòè z .
Èíòåãðèðîâàíèå ïðîèçâîäèòñÿ ïî ìíèìîé ÷àñòè ïåðåìåííîãî u.
1
2
3
4
5
6
7
8
9

integrateY :: ( RealFloat a, Enum a) => (Complex a −> Complex a) −>
a −> a −> Integer −> Complex a
integrateY f a b n =
(( sum $ map f yvalues) + t) ∗ (h :+ 0)

where

values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
yvalues = map ((:+) 0) values
t = (f (0 :+ a) + f (0 :+ b))/2
h = (b − a) / fromInteger(n)

3.2.2

Âû÷èñëåíèå çíà÷åíèé òåòà-óíêöèé

Ñîãëàñíî [16, ñ. 336℄, Θ4 ïðåäñòàâëÿåòñÿ â âèäå:

Θ4 (u) = Θ4 (u, q) = 1 + 2

+∞
X

2

(−1)nq n cos(2nu)

(3.1)

n=1

Çäåñü q âû÷èñëÿåòñÿ ñëåäóþùèì îáðàçîì:

q = eπiτ : |q| < 1
τ  onst : Im(τ ) > 0

(3.2)
(3.3)

 ýòîé óíêöèè, òàêèì îáðàçîì, èñïîëüçóåòñÿ äâà ïàðàìåòðà: ntheta
è τ . Äîïîëíèòåëüíûé ïàðàìåòð q (3.2) âû÷èñëÿåòñÿ ñëåäóþùåé âñïîìîãàòåëüíîé óíêöèåé:
1

qpar tau = exp $ pi ∗ tau ∗ (0 :+ 1)

 êà÷åñòâå ïàðàìåòðà tau óíêöèè qpar äîëæåí ïåðåäàâàòüñÿ ïàðàìåòð
ìîäåëè τ .
Íà Haskell îïðåäåëåíèå (3.1) ïåðåâîäèòñÿ òàê:
1
2
3
4
5
6
7
8

theta4 :: ( RealFloat a) => Integer −> Complex a −> Complex a −> Complex a
theta4 n q u = 1 + 2 ∗ sum thetaarg
where thetaarg = [(signfun nn) ∗ (qfun q nn) ∗ ( osfun u nn) | nn <− [1..n℄℄
signfun :: ( RealFloat a) => Integer −> Complex a
signfun nn
| odd nn = −1
| otherwise = 1
qfun :: ( RealFloat a) => Complex a −> Integer −> Complex a

26

qfun q nn = q ∗∗ fromInteger(nn) ∗∗ 2
osfun :: (RealFloat a) => Complex a −> Integer −> Complex a
osfun u nn = os $ fromInteger(2 ∗ nn) ∗ u

9
10
11

Àíàëîãè÷íî, óíêöèÿ Θ3 çàäà¼òñÿ ñëåäóþùèì ìàòåìàòè÷åñêèì âûðàæåíèåì:
+∞
X
2
Θ3 (u) = Θ3 (u, q) = 1 + 2
q n cos(2nu)
(3.4)
n=1

Åãî ïåðåâîä íà Haskell âûãëÿäèò òàê:

1
2
3
4
5
6
7

theta3 :: ( RealFloat a) => Integer −> Complex a −> Complex a −> Complex a
theta3 n q u = 2 ∗ sum thetaarg
where thetaarg = [(qfun q nn) ∗ ( osfun u nn) | nn <− [1..n℄℄
qfun :: ( RealFloat a) => Complex a −> Integer −> Complex a
qfun q nn = q ∗∗ (fromInteger nn) ∗∗ 2
osfun :: (RealFloat a) => Complex a −> Integer −> Complex a
osfun u nn = os $ fromInteger(2 ∗ nn) ∗ u

 îáîèõ óíêöèÿõ ïåðâûé àðãóìåíò çàäà¼ò êîëè÷åñòâî âû÷èñëÿåìûõ ñëàãàåìûõ èç áåñêîíå÷íîé ñóììû, êîòîðîé ïðåäñòàâëÿþòñÿ òåòàóíêöèè. Äëÿ êðàòêîñòè ââåä¼ì äâå áîëåå êîðîòêèõ óíêöèè, êîòîðûìè
áóäåì ïîëüçîâàòüñÿ â äàëüíåéøåì 1 :
1
2

theta3' param = theta3 (n_theta param) (qpar (0 :+ tau param))
theta4' param = theta4 (n_theta param) (qpar (0 :+ tau param))

3.2.3

Âû÷èñëåíèå çíà÷åíèé óíêöèè

dw/du

Ïðîèçâîäíàÿ êîìïëåêñíîãî ïîòåíöèàëà îò âñïîìîãàòåëüíîãî ïåðåìåííîãî dw/du ÿâëÿåòñÿ êîíñòàíòíîé óíêöèåé, è ïåðåâîäèòñÿ íà Haskell
ñëåäóþùèì îáðàçîì:
1
2
3
4

dwdu :: ModelParams −> Double
dwdu param = ((negate 2) ∗ phi_0') / (pi ∗ tau')
where phi_0' = phi_0 param
tau' = tau param

ż åäèíñòâåííûé âõîäíîé àðãóìåíò  ìàññèâ ïàðàìåòðîâ param.
3.2.4

Âû÷èñëåíèå çíà÷åíèé óíêöèè Æóêîâñêîãî

χ(u)
Ôóíêöèÿ χ(u) (2.6) ïåðåâîäèòñÿ â ñëåäóþùèé êîä íà Haskell:

1
2

hi :: ModelParams −> Complex Double −> Complex Double
hi param u = ( hi_0 param u) + (f_ orr param u)

Ôóíêöèÿ χ0 (u) (2.17) ïåðåâîäèòñÿ â
1 Çäåñü

è äàëåå àðãóìåíò ¾param¿ ÿâëÿåòñÿ ïåðåìåííîé, õðàíÿùåé çíà÷åíèÿ âñåõ ïàðàìåòðîâ

ìîäåëè.

27

1
2
3
4
5
6

hi_0 :: ModelParams −> Complex Double −> Complex Double
hi_0 param u = _ hi_0 + onst_ oe ∗ log ( divident / divisor )
where onst_ oe = ((pi / 2) ∗ (1 + alpha')) :+ 0
divident = (theta3' param 0) ∗ (theta4' param u)
divisor = (theta3' param u) ∗ (theta4' param 0)
alpha' = alpha param

Ïàðàìåòð Θ(u) = Im χ(u) áóäåì ïîëó÷àòü åñòåñòâåííûì îáðàçîì, âû÷èñëÿÿ óíêöèþ χ(u) è îïðåäåëÿÿ ìíèìóþ ÷àñòü ïîëó÷åííîãî êîìïëåêñíîãî ÷èñëà:

1

imagPart( hi param u)
3.2.5

Âû÷èñëåíèå çíà÷åíèé êîððåêòèðóþùåé 
óíêöèè

f (u)

Ñëåäóþùèì îáðàçîì âûãëÿäèò óíêöèÿ Haskell, ðåàëèçóþùàÿ (2.23):
1
2
3
4
5
6
7
8
9

Complex Double −> Complex Double

f_ orr :: ModelParams −>
−− Clear fun tional implementation

f_ orr param u = foldl (+) ( 0 :+ 0) (f_arg u list )
where f_arg u list = map (\ (n, n) −> ( n :+ 0) ∗ (exp' u (i' n) − exp' u (negate (i' n)))) list
i' n
= (fromInteger n) :+ 0
list
= zip [1..( pred $ n_ n param)℄ n'
exp' u n = exp $ 2 ∗ (0 :+ 1) ∗ n
n'
= tail $ _n param
0
= head $ _n param

Äëÿ êîððåêòíîé ðàáîòû ýòà óíêöèÿ äîëæíà ïîëó÷èòü èç ìàññèâà
äàííûõ param ñïèñîê êîýèöèåíòîâ cn .
3.2.6

Âû÷èñëåíèå êîýèöèåíòîâ

f (u)

cn

â ðàçëîæåíèè

â ðÿä

Êàê áûëî ñêàçàíî â 2.2.3, êîýèöèåíòû cn , íåîáõîäèìûå äëÿ îïðåäåëåíèÿ f (u), òðåáóåòñÿ âû÷èñëèòü îòäåëüíî, äî òîãî, êàê çàíèìàòüñÿ
âû÷èñëåíèåì êîîðäèíàò òî÷åê íà ãðàíèöå âîðîíêè âçðûâà.
Äëÿ âû÷èñëåíèÿ cn îïðåäåëèì ñëåäóþùóþ óíêöèþ, êîòîðàÿ ïîñëåäîâàòåëüíî áóäåò óòî÷íÿòü cn , äî òåõ ïîð, ïîêà íå áóäåò äîñòèãíóòà òðåáóåìàÿ òî÷íîñòü.
1
2
3
4
5
6
7
8
9
10
11
12

al _ n param
| has_error param new_ n = param { _n = new_ n}
| otherwise = al _ n (param { _n = new_ n})

where

has_error param new_ n = foldl (&&) True $ map ( al _error) (zip n' new_ n)
al _error (x1, x2)
= (((x2 − x1) ∗∗ 2 ) / abs (2 ∗ x1 − x2) ) < pre ision '
new_ n
= map (transform') [0..n '℄
transform' n
= s_fun param n ∗ (integrate (transform n) 0 ( pi /2) ni ')
transform n x
= urvature param (x :+ eta)
∗ exp ( − realPart( hi param (x :+ eta)))
∗ os (2 ∗ x ∗ fromInteger n)
eta
= (pi ∗ tau ') / 2

28

13
14
15
16
17

tau'
pre ision '
ni '
n'
n'

= tau param
= pre ision param
= n_integral param
= _n param
= n_ n param

al _ n  ðåêóðñèâíàÿ óíêöèÿ ñî ñëåäóþùèì óñëîâèåì îñòàíîâà:

(xt − xt−1)2

|2xt−1 − xt − xt−2|

(3.5)

ãäå ε åñòü çàðàíåå çàäàííàÿ êîíñòàíòà, îïðåäåëÿþùàÿ æåëàåìóþ òî÷íîñòü âû÷èñëåíèé.
Íà êàæäîé èòåðàöèè óòî÷íåíèÿ âåêòîðà êîýèöèåíòîâ cn óíêöèÿ
al _ n îáíîâëÿåò ñîäåðæèìîå ïîëÿ _n â áëîêå äàííûõ param. Ïðè äîñòèæåíèè óñëîâèÿ îñòàíîâêè âåêòîð _n ìîæíî èñïîëüçîâàòü â ÷èñëåííîì
ðåøåíèè ïîñòàâëåííîé â äàííîé ðàáîòå çàäà÷è.
3.2.7

Ïðîãðàììèðîâàíèå îòîáðàæåíèÿ çíà÷åíèé
äîïîëíèòåëüíîãî ïåðåìåííîãî íà îáëàñòü
èñõîäíîãî ïåðåìåííîãî

Ñîáñòâåííî, êîíå÷íàÿ öåëü ðàçäåëà 2, óíêöèÿ dz/du, îïðåäåë¼ííàÿ
âûðàæåíèåì (2.33), ïåðåâîäèòñÿ íà Haskell ñëåäóþùèì îáðàçîì:

1
2
3

dzdu :: ModelParams −> Complex Double −> Complex Double
dzdu param u = ( ((dwdu param) / v') :+ 0 ) ∗ exp ( hi param u )
where v' = v_0 param

Âñå îñòàëüíûå óíêöèè óæå áûëè îïðåäåëåíû ðàíåå.
3.3

Ïðîãðàììèðîâàíèå âû÷èñëåíèÿ
êîîðäèíàò òî÷åê íà ãðàíèöå âîðîíêè
âçðûâà

Êàê ñëåäóåò èç (2.35), òî÷êè íà ãðàíèöå CD â îáëàñòè èñõîäíîãî
ïåðåìåííîãî z ìîæíî íàéòè èíòåãðèðîâàíèåì óíêöèè dz/du (2.33) ïî
ëèíèè CD îáëàñòè âñïîìîãàòåëüíîãî ïåðåìåííîãî u. Ýòî âûïîëíÿåòñÿ
ïðè ïîìîùè ñëåäóþùåé óíêöèè Haskell:
1
2
3
4
5
6
7
8

zlist :: ModelParams −> [Complex Double℄
zlist param = map (z param) [a', a' + h .. b '℄

where

z param e = integrateY (dzdu param) 0 e n'
h = (b' − a') / fromInteger n'
n' = n_integral param
a' = 0
b' = ( pi ∗ (tau param) ) / 2

29  

ξ + i πτ4 , ξ ∈ 0; π4 â òî÷êè x + iy ïîñëåäîâàòåëüíûì èíòåãðèðîâàíèåì. Ïîëó÷èâ êîîðäèíàòû ýòèõ òî÷åê, ìû
ðåøèì çàäà÷ó.
zlist îòîáðàæàåò ìàññèâ òî÷åê

3.4

Ïðîãðàììíûé ïàêåò äëÿ âûâîäà
ãðàèêîâ óíêöèé ñðåäñòâàìè Haskell

Äëÿ âûâîäà ãðàèêîâ áóäåò èñïîëüçîâàòüñÿ ïàêåò ðàñøèðåíèÿ äëÿ
Haskell ïîä îáùèì íàçâàíèåì Chart (ñì. [20℄, [22℄). Chart ïîääåðæèâàåò âûâîä
íåïîñðåäñòâåííî â àéë ñ ðàñòðîâûì èçîáðàæåíèåì à òàêæå ÷åð÷åíèå íà
êàíâå îêíà GTK+.
Ïðîöåäóðà outputData, âûïîëíÿþùàÿ âûâîä ãðàèêà ïî çàäàííûì òî÷êàì, îïðåäåëåíà ñëåäóþùèì îáðàçîì:
1
2
3
4
5
6
7
8
9
10
11
12
13
14

outputData datalist = do
renderableToWindow (toRenderable ( hart datalist )) 640 480
renderableToPNGFile (toRenderable ( hart datalist )) 640 480 "test .png"
hart :: [( Double, Double)℄ −> Layout1 Double Double
hart datalist = layout

where

myPlot = plot_lines_values ^= [datalist ℄
$ plot_lines_style .> line_ olor ^= opaque blue
$ plot_lines_title ^= "test"
$ defaultPlotLines
layout = layout1_title ^= "Graphi s.Rendering.Chart"
$ layout1_plots ^= [Left (toPlot myPlot)℄
$ defaultLayout1

Ôóíêöèÿ hart íóæíà äëÿ óäîáñòâà íàñòðîéêè îîðìëåíèÿ ãðàèêà.
×åðåç àðãóìåíò datalist óíêöèÿ ïîëó÷àåò íàáîð òî÷åê â âèäå ñïèñêà ïàð
(x, y) .
3.5

Ñáîðêà öåëüíîãî ïðèëîæåíèÿ ñ ó÷¼òîì
ìíîãîïîòî÷íîñòè

Âñå óíêöèè, îïðåäåë¼ííûå â ðàçäåëå 3.2, çàâåðí¼ì â ìîäóëü ïîä íàçâàíèåì BlastModel (ñì. ïðèëîæåíèå A), çà èñêëþ÷åíèåì óíêöèé âû÷èñëåíèÿ çíà÷åíèé òåòà-óíêöèé. Òåòà-óíêöèè âûíåñåì â ìîäóëü ïîä
íàçâàíèåì Theta (ñì. ïðèëîæåíèå B).
 ãëàâíîì ìîäóëå íàõîäèòñÿ ïðîãðàììíûé êîä äëÿ ÷åð÷åíèÿ ãðàèêîâ, îïðåäåë¼ííûé â ïîäðàçäåëå 3.4, è òî÷êà âõîäà ïðîãðàììû.
Òî÷êà âõîäà ïðîãðàììû, óíêöèÿ main, ñîñòîèò â öåëîì èç ÷åòûð¼õ
øàãîâ:
1 ïîëó÷åíèå ïàðàìåòðîâ ìîäåëè îò ïîëüçîâàòåëÿ;
30

2 óòî÷íåíèå êîýèöèåíòîâ cn (ýòî íåîáõîäèìûé øàã, êîòîðûé, óâû,
ïðèõîäèòñÿ ñîâåðøàòü èìåííî íà ýòîì ýòàïå âûïîëíåíèÿ ïðîãðàììû);
3 âû÷èñëåíèå êîîðäèíàò òî÷åê íà ãðàíèöå âîðîíêè âçðûâà;
4 ÷åð÷åíèå êðèâîé ïî ïîëó÷åííûì êîîðäèíàòàì.
Âñå ýòè øàãè äîëæíû áûòü âûïîëíåíû ïîñëåäîâàòåëüíî, ïîýòîìó íèêàêîé ïàðàëëåëüíîñòè íà ýòîì óðîâíå àáñòðàêöèè íå ïðåäïîëàãàåòñÿ. Âîò
êàê âûãëÿäèò òî÷êà âõîäà äëÿ âñåé ïðîãðàììû â öåëîì:
1

main = do

putStrLn "Greetings!~ This is blast model, based on solid−liquid model of Lavrentyev and Kotlyar."
putStrLn "First, we will dene model parameters."
4
par <− getModelParameters
5
putStrLn "Se ond, we ompute the parameters _n needed for omputations"
6 −− let par_ orre ted = al _ n par
7
putStrLn "We will now ompute points on the edge of blast."
8
let pointlist = omputePoints par
9
putStrLn "And at last, we print the data to the le for a Gnuplot"
10
outputData pointlist
11
putStrLn "All done, good bye."
2

3

Äëÿ ïîëó÷åíèÿ îò ïîëüçîâàòåëÿ ïàðàìåòðîâ áûëà âûäåëåíà âñïîìîãàòåëüíàÿ óíêöèÿ getModelParameters ñëåäóþùåãî âèäà:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

getModelParameter parname = do
putStrLn $ "Value of " ++ parname

getLine

getModelParameters = do
phi_0'
<− getModelParameter "phi_0"
v_0'
<− getModelParameter "v_0"
tau'
<− getModelParameter "|tau|"
alpha'
<− getModelParameter "alpha"
a'
<− getModelParameter "a"
b'
<− getModelParameter "b"
n_theta'
<− getModelParameter "n_theta"
n_integral' <− getModelParameter "n_integral"
n_ n'
<− getModelParameter "n_ n"
pre ision ' <− getModelParameter "pre ision"
return ModelParams{
phi_0
= read phi_0',
v_0
= read v_0',
tau
= read tau',
alpha
= read alpha',
a
= read a',
b
= read b',
n_theta = read n_theta',
n_integral = read n_integral',
n_ n
= read n_ n',
pre ision = read pre ision ',
_n
= take n_ n' $ repeat 2
}

Äëÿ óòî÷íåíèÿ çíà÷åíèé cn èñïîëüçóåòñÿ îïðåäåë¼ííàÿ â BlastModel 
óíêöèÿ al _ n, êîòîðàÿ ïîäðîáíî îïèñàíà â ðàçäåëå 3.2.6.
31

Äëÿ âû÷èñëåíèÿ êîîðäèíàò òî÷åê íà ãðàíèöå âîðîíêè îïðåäåëåíà äîïîëíèòåëüíàÿ óíêöèÿ omputePoints ñëåäóþùåãî âèäà:

1
2
3
4

omputePoints par = zip xlist ylist
where n' = fromInteger(n_integral par)
ylist = map (\x −> (x − 1) ∗∗ 2 − (n' / 2)) xlist
xlist = [0.. n '℄

Äëÿ âûâîäà äàííûõ, êîòîðûå áûëè ñãåíåðèðîâàíû óíêöèåé omputePoints,
èñïîëüçóåòñÿ óíêöèÿ outputData, îïèñàííàÿ â ðàçäåëå 3.4.
Çàïóñê ïðèëîæåíèÿ ñëåäóåò îñóùåñòâëÿòü èç êîìàíäíîé ñòðîêè. Â
êà÷åñòâå àðãóìåíòîâ êîìàíäíîé ñòðîêè ñëåäóåò ïåðåäàâàòü ïàðàìåòðû
+RTS −N2 (ãäå 2  ýòî êîëè÷åñòâî ÿäåð). Âñå ïàðàìåòðû ìîäåëè ïðîãðàììà çàïðîñèò ñàìîñòîÿòåëüíî, ïîñëå ÷åãî âûïîëíèò ïðåäóñìîòðåííûå âû÷èñëåíèÿ è âûäàñò ãðàèê â îòäåëüíîì îêíå è â àéë PNG â ðàáî÷åì
êàòàëîãå.
Ïîëíûé òåêñò ïðîãðàììû íàõîäèòñÿ â ïðèëîæåíèè. Ñîäåðæèìîå èñõîäíîãî êîäà ãëàâíîãî ìîäóëÿ ïðîãðàììû ðàñïîëîæåí â ïðèëîæåíèè C.

32

ëàâà 4. Àíàëèç ïîëó÷åííûõ
ðåçóëüòàòîâ
4.1 

åçóëüòàòû âû÷èñëåíèé è èõ
èíòåðïðåòàöèÿ

Äëÿ ðàçðàáîòàííîé ïðîãðàììû áûë ñîðìèðîâàí ðÿä òåñòîâ, äëÿ
ìàññîâîãî âûâîäà ãðàèêîâ ñ âàðèàöèåé òîãî èëè èíîãî ïàðàìåòðà ìîäåëè. Áûëî ïîëó÷åíî áîëåå 150 ðàçëè÷íûõ ãðàèêîâ, ïîñëå ÷åãî äàëüíåéøèå ýêñïåðèìåíòû áûëè ïðèçíàíû íåñóùåñòâåííûìè äëÿ îöåíêè ðàáîòû.
 òàáëèöå 4.1 ïðèâåäåíû ñâåäåíèÿ î ïàðàìåòðàõ, èñïîëüçîâàííûõ â
íåêîòîðûõ ïðîâåðî÷íûõ çàïóñêàõ. Ïàðàìåòðû òî÷íîñòè îñòàâàëèñü íåèçìåííûìè: èíòåãðèðîâàíèå ïðîèçâîäèëîñü ïî ñåòêå ÷àñòîòîé â 50 îòðåçêîâ, òåòà-óíêöèè ïðåäñòàâëÿëèñü ðÿäàìè èç 25 ýëåìåíòîâ, è êîëè÷åñòâî
âû÷èñëÿåìûõ cn áûëî ðàâíî 30.
ðàèê íà ðèñ. ϕ0 v0 τ
4.1
100 0.2 0.7
4.2
100 0.2 0.6
4.3
100 0.2 0.7

α
0.7
0.7
0.49

a
1
1
1

b
5
5
5

Òàáëèöà 4.1. Ïàðàìåòðû òð¼õ ðàçëè÷íûõ òåñòîâ ÷åð÷åíèÿ ãðàíèöû âîðîíêè âçðûâà. Òî÷íîñòü âû÷èñëåíèé íå ìåíÿëàñü
Áûëî çàìå÷åíî, ÷òî ïàðàìåòðû ϕ0 è v0 âëèÿþò òîëüêî íà ìàñøòàá
÷åðòåæà. Ïðè óâåëè÷åíèè ϕ0 ÷åðò¼æ óâåëè÷èâàåòñÿ (ãðàíèöà îòäàëÿåòñÿ
îò íà÷àëà êîîðäèíàò), à ïðè óâåëè÷åíèè v0  óìåíüøàåòñÿ (ãðàíèöà ïðèáëèæàåòñÿ ê íà÷àëó êîîðäèíàò). Ýòè ðåçóëüòàòû åñòåñòâåííûì îáðàçîì
ñëåäóþò èç ïîñòðîåíèÿ óíêöèè (2.33), ãäå ýòè ïàðàìåòðû âûñòóïàþò â
êà÷åñòâå êîýèöèåíòîâ.
Ïàðàìåòðû a è b, ïðåäñòàâëÿþùèå ñîáîé äëèíû ðàäèóñîâ ýëëèïñà,
êîòîðûé ÿâëÿåòñÿ îðìîé çàðÿäà, îêàçûâàþò òàêæå ìàñøòàáèðóþùåå
âëèÿíèå íà ÷åðò¼æ. Ïðè ýòîì ïðè çàäàíèè êàêîãî-ëèáî b òàê, ÷òî b < a
ïðîãðàììà íà÷èíàåò âûäàâàòü âåêòîðû èç îøèáî÷íûõ çíà÷åíèé ¾NaN¿
ïðè âû÷èñëåíèè êîýèöèåíòîâ cn äëÿ âûðàæåíèÿ f (u).
Ïàðàìåòðû |τ | è γ îêàçûâàþò íàìíîãî áîëåå ñóùåñòâåííîå âëèÿíèå íà
÷åðò¼æ. Îáà ýòèõ ïàðàìåòðà èñêàæàþò è ïîâîðà÷èâàþò ãðàíèöó, èçîáðàæ¼ííóþ íà ãðàèêå, ïðè÷¼ì âåñüìà ñëîæíûì îáðàçîì. Äëÿ îïðåäåëåíèÿ
33 

èñ. 4.1. ×åðò¼æ ãðàíèöû âîðîíêè âçðûâà ïðè ïåðâîì òåñòîâîì íàáîðå
ïàðàìåòðîâ

îñîáåííîñòåé âëèÿíèÿ γ è |τ | íà ðàñïîëîæåíèå è îðìó èçîáðàæåíèÿ ãðàíèöû âîðîíêè âçðûâà ñëåäóåò ïðîâåñòè äîïîëíèòåëüíîå èññëåäîâàíèå.
 öåëîì èíòåðïðåòàöèÿ ïîëó÷åííûõ ðåçóëüòàòîâ çàòðóäíåíà. Íà îíå
àíàëèòè÷åñêè âåðíûõ ìàòåìàòè÷åñêèõ îðìóë, ëåæàùèõ â îñíîâå ïðîèçâîäèìûõ âû÷èñëåíèé, íå ïîääàþùèåñÿ ðàñøèðîâêå ïðîèçâîäèìûå ïðîãðàììîé ãðàèêè ïðåäñòàâëÿþò ñîáîé ïðîáëåìó äëÿ äàëüíåéøåãî ïðèìåíåíèÿ ðåçóëüòàòîâ äàííîé ðàáîòû.
Ñëåäóåò îòìåòèòü, ÷òî èç-çà îñîáåííîñòåé ÷èñëåííîé ðåàëèçàöèè âû÷èñëåíèÿ çíà÷åíèé òåòà-óíêöèé, â ñëó÷àå çàäàíèÿ áîëåå ÷åì 25 ñëàãàåìûõ â ðÿäó, ïðåäñòàâëÿþùåì òåòà-óíêöèè (èíûìè ñëîâàìè, â ñëó÷àå,
êîãäà ntheta > 25), òåòà-óíêöèè íà÷èíàþò ðàñõîäèòüñÿ è èõ âû÷èñëåíèå
êðàéíå çàìåäëÿåòñÿ. Ýòî ïðîèñõîäèò èç-çà íàêîïëåíèÿ îøèáêè. Óæå ïðè
ntheta > 10 ïàðàìåòð q , âõîäÿùèé â ðàçëîæåíèå òåòà-óíêöèé, íà÷èíàåò
âîçâîäèòüñÿ â ñòåïåíü n2 , ãäå n > 10, à ïðè óñëîâèè, ÷òî |q| < 1, ïîëó÷àåòñÿ, ÷òî âñå ñëàãàåìûå â ðàçëîæåíèè òåòà-óíêöèè, ïîñëå äåñÿòîãî
ñòàíîâÿòñÿ èñ÷åçàþùå ìàëû.
4.2

Îöåíêà ïðîèçâîäèòåëüíîñòè

Âû÷èñëåíèÿ ïðîèçâîäèëèñü íà AMD Athlon 64 X2 Dual Core 5000+
1.96 GB îïåðàòèâíîé ïàìÿòè. Ñðàçó æå ñëåäóåò çàìåòèòü, ÷òî â ñëó÷àå êîìïèëÿöèè ïðîãðàììû ïðîèçâîäèòåëüíîñòü âîçðàñòàåò íà 200%. Â
34 

èñ. 4.2. ×åðò¼æ ãðàíèöû âîðîíêè âçðûâà ïðè âòîðîì òåñòîâîì íàáîðå
ïàðàìåòðîâ 

èñ. 4.3. ×åðò¼æ ãðàíèöû âîðîíêè âçðûâà ïðè òðåòüåì òåñòîâîì íàáîðå
ïàðàìåòðîâ

35

ñðåäíåì âðåìÿ âûïîëíåíèÿ ïðîãðàììû ñîñòàâëÿåò 40 ñåêóíä ïëþñ-ìèíóñ
ïÿòü ïðè ëþáîì íàáîðå âõîäíûõ ïàðàìåòðîâ.
Îøèáêà, ñâÿçàííàÿ ñ êîëè÷åñòâîì ýëåìåíòîâ, ïðåäñòàâëÿþùèõ òåòàóíêöèè, ïðîÿâëÿåòñÿ è íà ïðîèçâîäèòåëüíîñòè.  ñëó÷àå ïðåâûøåíèÿ
êîëè÷åñòâà ýëåìåíòîâ äàëüøå 25 ïðîèçâîäèòåëüíîñòü ïðîãðàììû ïàäàåò.
Íà îäíó èòåðàöèþ âû÷èñëåíèÿ cn íà òåñòîâîì êîìïüþòåðå òðåáóåòñÿ
îò 5.9 äî 6.9 ñåêóíä. Íà âû÷èñëåíèå êîîðäèíàò 50 òî÷åê, íàïðèìåð, äëÿ
ïîñòðîéêè ðèñóíêà îäíîé èç ãðàíèö îáëàñòè z(u), òðåáóåòñÿ 7 ñåêóíä.
Ýòè ñâåäåíèÿ ïî âðåìåíè âûïîëíåíèÿ àêòóàëüíû äëÿ ñêîìïèëèðîâàííîãî
ïðèëîæåíèÿ, âûïîëíÿåìîãî â ñðåäå GNU \Linux.
Âíåäðåíèå òåõíèê ïîëóàâòîìàòè÷åñêîãî ðàñïàðàëëåëèâàíèÿ, ïðåäîñòàâëÿåìûõ êîìïèëÿòîðîì GHC, äàëî ïðîòèâîðå÷èâûå ðåçóëüòàòû. Ïðè
âíåäðåíèè êàêîãî-ëèáî êîäà, ïðåäíàçíà÷åííîãî äëÿ óêàçàíèÿ íà ïàðàëëåëüíûå âû÷èñëåíèÿ, â ïðîãðàììó, ïðîèçâîäèòåëüíîñòü êîíå÷íîãî ïðèëîæåíèÿ ïàäàåò íà 20%. Äàííîå íàáëþäåíèå ðàñïðîñòðàíÿåòñÿ íà ëþáûå
âû÷èñëåíèÿ, ïðîâîäèìûå ïðîãðàììîé.
Ïðè íàëè÷èè â ïðîãðàììå êîäà äëÿ îñóùåñòâëåíèÿ ïàðàëëåëüíûõ
âû÷èñëåíèé è èñïîëüçîâàíèè àðãóìåíòîâ êîìàíäíîé ñòðîêè +RTS -N2
âî âðåìÿ çàïóñêà ïðîãðàììû âðåìÿ âûïîëíåíèÿ óâåëè÷èâàåòñÿ. Ïðè ñåìàíòè÷åñêè îäíîïîòî÷íîì êîäå è èñïîëüçîâàíèè îäíîãî òîëüêî óêàçàíèÿ
+RTS -N2 ïðîèçâîäèòåëüíîñòü òîæå ïàäàåò, õîòÿ è ìåíåå çíà÷èòåëüíî.
Òàêîå ïîâåäåíèå ïðèëîæåíèÿ ñâÿçàíî, î÷åâèäíî, ñ òåì, ÷òî â îïåðàöèîííîé ñèñòåìå, â êîòîðîé âûïîëíÿåòñÿ ïðèëîæåíèå, ðàáîòàåò ñâîé ñîáñòâåííûé ìåõàíèçì ðàñïàðàëëåëèâàíèÿ çàäà÷. Ýòî ïðåäïîëîæåíèå ïîäòâåðæäàåòñÿ íàáëþäåíèåì çà íàãðóçêîé ïðîöåññîðà ñòîðîííèìè ïðèëîæåíèÿìè.
Ïðèìåíåíèå ìåòîäèêè óâåëè÷åíèÿ îáú¼ìà êó÷è è ñòåêà, âûäåëÿåìûõ
íà ïðîãðàììó, ñ öåëüþ óìåíüøåíèÿ êîëè÷åñòâà âûçîâîâ ñáîðùèêà ìóñîðà, òàêæå ïîíèæàåò ïðîèçâîäèòåëüíîñòü. Ñëåäóåò, îäíàêî, îòìåòèòü ïðè
ýòîì, ÷òî êîëè÷åñòâî çàïóñêîâ ñáîðùèêà ìóñîðà äåéñòâèòåëüíî óìåíüøàåòñÿ. Áûë ïðîèçâåä¼í ýêñïåðèìåíò ñ çàïóñêîì ïðèëîæåíèÿ, âûäåëèâ
åìó 100 MB äëÿ ñòåêà è 500 MB äëÿ êó÷è. Âðåìÿ, ïðîâåä¼ííîå çà ñáîðêîé
ìóñîðà, óìåíüøèëîñü ñ 2 ñåê, ïîëó÷àåìûõ ïðè çàïóñêå ñ ïàðàìåòðàìè ïî
óìîë÷àíèþ, äî 0.2 ñåê. Ïðè ýòîì ñóììàðíîå âðåìÿ âûïîëíåíèÿ ïðîãðàììû óâåëè÷èëîñü.
Îïðåäåë¼ííî, ìîæíî ñäåëàòü âûâîä î òîì, ÷òî, êðîìå, ñîáñòâåííî,
ïðèìåíåíèÿ òåõíèê ðàñïàðàëëåëèâàíèÿ, à òåì áîëåå, òàêèõ ñïåöèè÷íûõ, êàê ïðåäîñòàâëÿåìûõ ñðåäîé âûïîëíåíèÿ Haskell, òðåáóåòñÿ åù¼ äîïîëíèòåëüíî ïðîâîäèòü èññëåäîâàíèÿ äëÿ âûÿâëåíèÿ ó÷àñòêîâ êîäà, ðàñïàðàëëåëèâàíèå êîòîðûõ äåéñòâèòåëüíî ïðèâåä¼ò ê ïîâûøåíèþ ïðîèçâîäèòåëüíîñòè.  îñòàëüíûõ ñëó÷àÿõ êîìïèëÿöèÿ ñ îïòèìèçàöèåé, ïðåäîñòàâëÿåìàÿ GHC, ïîçâîëÿåò äîáèòüñÿ íàèëó÷øåé ïðîèçâîäèòåëüíîñòè
áåç ïðèìåíåíèÿ êàêèõ-ëèáî äîïîëíèòåëüíûõ òåõíèê.
36

Çàêëþ÷åíèå
Çàäà÷à áûëà ðåøåíà ïîëíîñòüþ.
1  êà÷åñòâå ïåðâîãî ýòàïà ðàáîòû áûëà ïîñòðîåíà è ðåøåíà êðàåâàÿ çàäà÷à, ïîçâîëÿþùàÿ îïèñàòü òå÷åíèå, ýêâèâàëåíòíîå ïðîöåññó
âçðûâà ñîãëàñíî ÒÆÌ.
2 Ñîðìóëèðîâàííàÿ íà ïåðâîì ýòàïå ìàòåìàòè÷åñêàÿ ìîäåëü âçðûâà áûëà ïåðåîðìóëèðîâàíà íà ÿçûê Haskell ñ ðàñ÷¼òîì íà òåõíèêó
ìíîãîïîòî÷íîñòè.
Ñëåäóåò îòìåòèòü êðàéíþþ ë¼ãêîñòü íàïèñàíèÿ ïðîãðàìì íà ÿçûêå
Haskell, ïî ñðàâíåíèþ ñ Ñ  òðàäèöèîííûì ÿçûêîì äëÿ íàïèñàíèÿ ïðîãðàìì, çàíèìàþùèõñÿ ñëîæíûìè âû÷èñëåíèÿìè.  íåêîòîðûõ ñëó÷àÿõ
îïðåäåëåíèå ïîäïðîãðàììû íà Haskell ñ òî÷íîñòüþ äî îáîçíà÷åíèé íàïîìèíàåò îïðåäåëåíèå ñîîòâåòñòâóþùåé ìàòåìàòè÷åñêîé óíêöèè. 
àçðàáîòàíî êîíñîëüíîå ïðèëîæåíèå äëÿ ÎÑ GNU\Linux, ïîçâîëÿþùåå ïðîèçâîëüíî çàäàâàòü ïàðàìåòðû ìîäåëè è ïîëó÷àòü ÷åðòåæè ñâîáîäíîé ïîâåðõíîñòè, ñîîòâåòñòâóþùåé çàäàííûì ïàðàìåòðàì.  êà÷åñòâå
äîïîëíåíèÿ äëÿ îáëåã÷åíèÿ àíàëèçà ðåàëèçîâàíà âîçìîæíîñòü ìàññîâîãî âûâîäà ÷åðòåæåé, ñ âàðüèðîâàíèåì çàðàíåå çàäàííîãî ïàðàìåòðà. Ïðè
çàïóñêå âîçìîæíî çàäàòü êîëè÷åñòâî äîñòóïíûõ íà àïïàðàòíîé áàçå ÿäåð
äëÿ ðàñïàðàëëåëèâàíèÿ âû÷èñëåíèé. Ïðèëîæåíèå ïåðåíîñèìî íà äðóãèå
îïåðàöèîííûå ñèñòåìû, ïðè óñëîâèè, ÷òî îíî äîëæíî áûòü ïðåäâàðèòåëüíî ñêîìïèëèðîâàíî ïåðåä èñïîëüçîâàíèåì.
Ñîðìóëèðîâàííàÿ ìîäåëü ìîæåò áûòü ñ ó÷¼òîì å¼ íåäîñòàòêîâ, îòìå÷åííûõ â ðàçäåëå 4.1, èñïîëüçîâàíà äëÿ ðàñ÷¼òîâ ðåàëüíûõ âîðîíîê
îò âçðûâîâ çàãëóáë¼ííûõ çàðÿäîâ. Ïîëó÷åííûå îðìóëû äîñòàòî÷íî îáùèå, ÷òîáû èñïîëüçîâàòü èõ äëÿ ìîäåëèðîâàíèÿ âçðûâîâ çàðÿäîâ ëþáîé 
îðìû, íå îãðàíè÷èâàÿñü ýëëèïñîèäàìè.  ïåðñïåêòèâå âèäèòñÿ âîçìîæíîñòü âûâîäà ðåøåíèÿ åù¼ áîëåå îáùåé çàäà÷è, â ðàçëè÷íûõ ïîñòàíîâêàõ. 
åàëèçîâàííàÿ ïðîãðàììà ìîæåò áûòü ñ ó÷¼òîì îñîáåííîñòåé ðàáîòû,
âûÿâëåííûõ â ðàçäåëå 4.2, äîïîëíåíà è ðàçâèòà äî ïîëíîöåííîãî ïðèëîæåíèÿ, ïðèãîäíîãî äëÿ èñïîëüçîâàíèÿ íà ìåñòàõ êîíêðåòíûìè ñïåöèàëèñòàìè ïî âçðûâîòåõíèêå.
Ïîëó÷åííàÿ ïðîãðàììà ìîæåò áûòü èñïîëüçîâàíà íåñêîëüêèìè ñïîñîáàìè:
1 äëÿ ðåàëüíûõ ðàñ÷¼òîâ âîðîíîê îò âçðûâîâ çàãëóáë¼ííûõ çàðÿäîâ
ýëëèïòè÷åñêîé îðìû;
37

2 äëÿ äàëüíåéøèõ èññëåäîâàíèé â îáëàñòè ìîäåëèðîâàíèÿ âçðûâîâ
ïðè ïîìîùè ÒÆÌ;
3 â êà÷åñòâå ïðèìåðà äëÿ ñòóäåíòîâ ìëàäøèõ êóðñîâ ïî äèñöèïëèíå
¾ïàðàëëåëüíûå âû÷èñëåíèÿ¿.
Î äàííîé ðàáîòå áûë ñäåëàí äîêëàä [14℄ íà ìåæðåãèîíàëüíîé íàó÷íîïðàêòè÷åñêîé êîíåðåíöèè ñòóäåíòîâ, àñïèðàíòîâ è ìîëîäûõ ó÷¼íûõ
¾III Êàìñêèå ÷òåíèÿ¿, çàíÿâøèé 2 ìåñòî â ñåêöèè ¾Åñòåñòâåííûå íàóêè¿.
Ïðåäñòàâëÿåòñÿ öåëåñîîáðàçíûì ïðîäîëæèòü ðàáîòó ïî äàííîé òåìå.
Ïîëó÷åííûå â ðàìêàõ ðåøåíèÿ äàííîé çàäà÷è ðåçóëüòàòû ïîäòâåðæäàþò íåîáõîäèìîñòü äàëüíåéøèõ èññëåäîâàíèé. Òàêæå çàìåòèì, ÷òî õàðàêòåðíûå îñîáåííîñòè ðåøåíèÿ çàäà÷è áåçîãîâîðî÷íî òðåáóþò ïðèìåíåíèÿ
âû÷èñëèòåëüíîé òåõíèêè äëÿ ïîëó÷åíèÿ íåîáõîäèìîãî ðåçóëüòàòà, ïîýòîìó äàííàÿ ðàáîòà â öåëîì íàõîäèòñÿ íà ñòûêå äâóõ íàóê: ìàòåìàòè÷åñêîé èçèêè è èíæåíåðèè ïðîãðàììíîãî îáåñïå÷åíèÿ, ïðåäñòàâëÿÿ
ñîáîé ñèíòåòè÷åñêóþ çàäà÷ó, ñ îáðàçîâàòåëüíîé, ïðèêëàäíîé è íàó÷íîé
òî÷åê çðåíèÿ âåñüìà ïîëåçíóþ.

38

Ñïèñîê ëèòåðàòóðû
1. 

àñ÷¼òû âçðûâîâ íà ÝÂÌ. Ïîäçåìíûå âçðûâû / . Áðîóä. 
Ì.: Ìèð, 1975.  163 ñ.
Áðîóä, .

2.

Âëàñîâ, Î. Å.

Îñíîâû òåîðèè äåéñòâèÿ âçðûâà / Î. Å. Âëàñîâ.  Ì.:
Èçä-âî ÂÈÀ, 1957.

3.

óðåâè÷, Ì. È.

Íàóêà, 1979.

Òåîðèÿ ñòðóé èäåàëüíîé æèäêîñòè / Ì. È. óðåâè÷. 

4. Äåéñòâèå ÿäåðíîãî âçðûâà. Ñá. ïåðåâîäîâ / Ïîä ðåä. Ñ. Ñ. ðèãîðÿí,
. Ñ. Øàïèðî.  Ì.: Ìèð, 1971.  312 ñ.
5.

×èñëåííûå ìåòîäû àíàëèçà. Ïðèáëèæåíèå óíêöèé, äèåðåíöèàëüíûå è èíòåãðàëüíûå óðàâíåíèÿ / Á. Ï. Äåìèäîâè÷, È. À. Ìàðîí.  2 èçä.  Ì.: Ôèçìàòãèç, 1963.

6.

Êðàåâûå çàäà÷è òåîðèè âçðûâà / Í. Á. Èëüèíñêèé,
À. Â. Ïîòàø¼â.  Êàçàíü: Èçä-âî Êàçàíñêîãî óíèâåðñèòåòà, 1986.

7.

×èñëåííûå ìåòîäû / Í. Í. Êàëèòêèí.  Ì.: ëàâíàÿ ðåäàêöèÿ èçèêî-ìàòåìàòè÷åñêîé ëèòåðàòóðû èçä-âà ¾Íàóêà¿,
1978.

Äåìèäîâè÷, Á. Ï.

Èëüèíñêèé, Í. Á.

Êàëèòêèí, Í. Í.

8.

Êîòëÿð,

9.

Êóçíåöîâ, Â. Ì.

10.

Î âçðûâå íà ïîâåðõíîñòè ãðóíòà ëèíåéíîðàñïðåäåë¼ííîãî çàðÿäà êðèâîëèíåéíîé îðìû / Ë. Ì. Êîòëÿð //
Æóðíàë ïðèêëàäíîé ìåõàíèêè è òåõíè÷åñêîé èçèêè.  1975. 
 1.  Ñ. 187191.
Ë.

Ì.

Î îðìå âîðîíêè âûáðîñà ïðè âçðûâå íà ïîâåðõíîñòè ãðóíòà / Â. Ì. Êóçíåöîâ // ÏÌÒÔ.  1962.   3.  Ñ. 152156.
Ìàòåìàòè÷åñêèå ìîäåëè âçðûâíîãî äåëà /
Â. Ì. Êóçíåöîâ.  Íîâîñèáèðñê: Íàóêà, 1977.  264 ñ.
Êóçíåöîâ,

Â.

Ì.

11.

Ëàâðåíòüåâ, Ì. À.

Âàðèàöèîííûå ìåòîäû êðàåâûõ çàäà÷ äëÿ ñèñòåì
óðàâíåíèé ýëëèïòè÷åñêîãî òèïà / Ì. À. Ëàâðåíòüåâ.  Ì.: Èçäàòåëüñòâî ÀÍ ÑÑÑ, 1962.

12.

Ìàðòûíþê, Ï. À.

Î îðìå âîðîíêè âûáðîñà ïðè âçðûâå â ãðóíòå
øíóðîâîãî çàðÿäà / Ï. À. Ìàðòûíþê // Íàðîäíî-õîçÿéñòâåííîå èñïîëüçîâàíèå âçðûâà.  Íîâîñèáèðñê: ÑÎ ÀÍ ÑÑÑ, 1965.  Ñ. 39.
39

13.

Ìàòåìàòè÷åñêîå ìîäåëèðîâàíèå ïðîöåññîâ óäàðà è âçðûâà â ïðîãðàììå Ls-dyna: ó÷åáíîå ïîñîáèå / À. Þ. Ìóéçåìíåê, À. À. Áîãà÷.  Ïåíçà: Èíîðìàöèîííî-èçäàòåëüñêèé öåíòð
Ï Ó, 2005.  106 ñ.

14.

Çàäà÷à î âçðûâå êðèâîëèíåéíîãî çàãëóáë¼ííîãî çàðÿäà / Ì. À. Ñàðîíîâ // III Êàìñêèå ÷òåíèÿ: ìåæðåãèîíàëüíàÿ
íàó÷íî-ïðàêòè÷åñêàÿ êîíåðåíöèÿ.  3-õ ÷àñòÿõ.  Ò. 3.  Íàáåðåæíûå ×åëíû: 2011.

Ìóéçåìíåê, À. Þ.

Ñàðîíîâ, Ì. À.

15. Òåõíè÷åñêèå ïðàâèëà âåäåíèÿ âçðûâíûõ ðàáîò íà äíåâíîé ïîâåðõíîñòè.  Ì.: Íåäðà, 1972.  240 ñ.
16.

17.

Êóðñ ñîâðåìåííîãî àíàëèçà: Â 2 ò. / Ý. Ò. Óèòòåêåð, Ä. Í. Âàòñîí.  Ì.: Ôèçìàòãèç, 1963.  Ò. 2: Òðàíñöåíäåíòíûå 
óíêöèè.
Óèòòåêåð, Ý. Ò.

Ôóíêöèè êîìïëåêñíîãî ïåðåìåííîãî è íåêîòîðûå èõ
ïðèëîæåíèÿ / Á. Â. Øàáàò, Á. À. Ôóêñ.  Íàóêà, 1964.
Øàáàò, Á. Â.

18. Control. on urrent. 
Ha kageDB
The
Haskell
Database.  2010 (ïðîâåðÿëàñü 25 àïðåëÿ 2011). 

Pa kages
[Â Ñåòè℄.

http://www.haskell.org/gh /do s/latest/html/libraries/base-4.3.1.0/ControlCon urrent.html

19.

Dean, J.

20.

Do ker, T.

.

Mapredu e: Simplied data pro essing on large lusters /
J. Dean, S. Ghemawat // OSDI'04: Sixth Symposium on Operating System Design and Implementation.  San Fran is o: 2004.
Haskell harts.  Haskell Charts wiki.  2010 (ïðîâåðÿëàñü
25 àïðåëÿ 2011).  [Â Ñåòè℄. http://http://do kerz.net/twd/HaskellCharts.

21. Erlang programming language.  Erlang web node.  2011 (ïðîâåðÿëàñü
25 àïðåëÿ 2011).  [Â Ñåòè℄. http://www.erlang.org/.
22. Ha kagedb: hart-0.14. 
Ha kageDB The Haskell Pa kages
Database.  2010 (ïðîâåðÿëàñü 25 àïðåëÿ 2011).  [Â Ñåòè℄.
http://ha kage.haskell.org/pa kage/Chart.
23. Ha kagedb: parallel-3.1.0.1.  Ha kageDB The Haskell Pa kages
Database.  2010 (ïðîâåðÿëàñü 25 àïðåëÿ 2011).  [Â Ñåòè℄.
http://ha kage.haskell.org/pa kage/parallel.
24. The
2011

haskell
programming
language. 
(ïðîâåðÿëàñü
27
àïðåëÿ
2011). 
http://haskell.org/haskellwiki/Haskell.
40

HaskellWiki. 

Ñåòè℄.

25.

Computer ar hite ture: a quantitative approa h /
J. L. Hennessy, D. A. Patterson.  4th edition.  USA: Elsevier, In ,
2007.  704 pp.

26.

Beautiful Con urren y / S. P. Jones // Beautiful Code /
Ed. by G. Wilson; Mi rosoft Resear h, Cambridge.  O`Reilly, 2007.

27.

The C programming language / B. Kernighan.  Englewood Clis, N.J: Prenti e Hall, 1988.

Hennessy,

J.

L.

Jones, S. P.

Kernighan, B.

41

Ïðèëîæåíèÿ
A
1
2
3
4
5

BlastModel.hs

module BlastModel where

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− Ìîäåëü âçðûâà çàãëóáë¼ííîãî â ãðóíò çàðÿäà êðèâîëèíåéíîé îðìû.
−− Ïîçâîëÿåò âû÷èñëèòü ãðàíèöó âîðîíêè âçðûâà íà îñíîâàíèè ðÿäà ïàðàìåòðîâ.
−− Âçðûâ ïðåäñòàâëÿåòñÿ êàê ïîòåíöèàëüíîå òå÷åíèå ñòðóè èäåàëüíîé æèäêîñòè, à âîðîíêà âçðûâà
−−− êàê ëèíèÿ òîêà íà òå÷åíèè, âäîëü êîòîðîé ñêîðîñòü òå÷åíèÿ ðàâíà íåêîòîðîìó

"êðèòè÷åñêîìó" çíà÷åíèþ.

6
7
8
9
10
11
12
13
14
15
16
17
18

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− Ìû èñïîëüçóåì ïàðàëëåëüíîñòü!

import Control. Parallel . Strategies
import Control. Parallel

−− Íàøà ìîäåëü ïîñòðîåíà íà êîìïëåêñíîçíà÷íûõ óíêöèÿõ êîìïëåêñíîãî àðãóìåíòà

import Data.Complex

−− Èìïîðòèðóåì ñàìîïèñíûå òåòà−óíêöèè

import Theta

−− Ïàðàìåòðû ìîäåëè áóäåì ïåðåäàâàòü îáúåêòîì ñëåäóþùåãî òèïà:

30

data ModelParams = ModelParams {
tau
:: Double,
−− ïàðàìåòð, äîîïðåäåëÿåò òåòà−óíêöèè
phi_0
:: Double,
−− íà÷àëüíîå çíà÷åíèå ïîòåíöèàëà òå÷åíèÿ
v_0
:: Double,
−− êðèòè÷åñêîå çíà÷åíèå ñêîðîñòè, ñêîðîñòü òå÷åíèÿ ðàâíà v_0 íà
ãðàíèöå âîðîíêè âçðûâà
alpha
:: Double,
−− óãîë, ñ êîòîðûì ãðàíèöà çàðÿäà íàêëîíåíà ê îñè àáñöèññ
a
:: Double,
−− çàðÿä ïðåäïîëàãàåòñÿ ýëëèïòè÷åñêèì, ïîýòîìó ýòî áîëüøèé
ðàäèóñ çàðÿäà
b
:: Double,
−− çàðÿä ïðåäïîëàãàåòñÿ ýëëèïòè÷åñêèì, ïîýòîìó ýòî ìåíüøèé
ðàäèóñ çàðÿäà
n_theta :: Integer ,
−− êîëè÷åñòâî ñëàãàåìûõ â ðÿäó, ïðåäñòàâëÿþùåì òåòà−óíêöèþ (ò.
å., ýòî, ïî ñóòè, òî÷íîñòü âû÷èñëåíèé òåòà−óíêöèé)
n_integral :: Integer ,
−− ÷àñòîòà ðàçáèåíèÿ îòðåçêà èíòåãðèðîâàíèÿ
n_ n
:: Integer ,
−− êîëè÷åñòâî êîýèöèåíòîâ N â ðàçáèåíèè f(u) â ðÿä, ò. å.,
çàîäíî è òî÷íîñòü âû÷èñëåíèÿ f(u)
pre ision :: Double,
−− òî÷íîñòü âû÷èñëåíèÿ N ìåòîäîì ïðîñòûõ èòåðàöèé. Äà è âîîáùå
"òî÷íîñòü" òàì, ãäå îíà ìîæåò áûòü íóæíà
_n
:: [ Double℄ −− ñïèñîê êîýèöèåíòîâ N â ðàçáèåíèè f(u) â ðÿä. Ïðè çàäàíèè

31

−− Íå ñóùåñòâóåò _n !! 0, ïàðàìåòð 0 çàäà¼òñÿ â îðìóëå, è çäåñü íå õðàíèòñÿ è íå îáíîâëÿåòñÿ.

19
20
21
22
23
24
25
26
27
28
29

32
33
34
35
36
37
38
39
40
41

ïàðàìåòðîâ ðàâíû íà÷àëüíîìó ïðèáëèæåíèþ, ïîòîì óòî÷íÿþòñÿ.

}

deriving (Show)

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 0. àçëè÷íûå õåëïåðû äëÿ óïðîùåíèÿ ðàáîòû BEGIN
−− Ïåðåîáîçíà÷åíèÿ òåòà−óíêöèé â áîëåå óäîáîâàðèìûé âèä

theta1'
theta2'
theta3'
theta4'

param = theta1 (n_theta param) (qpar (0 :+ tau param))
param = theta2 (n_theta param) (qpar (0 :+ tau param))
param = theta3 (n_theta param) (qpar (0 :+ tau param))
param = theta4 (n_theta param) (qpar (0 :+ tau param))

42

42
43
44
45
46
47
48
49
50
51

−− Ïàðàìåòðû "ïî óìîë÷àíèþ", äëÿ óïðîùåíèÿ îòëàäêè

null_parameters = ModelParams {
tau
= 0.7,
phi_0
= 100,
v_0
= 0.2,
alpha
= 0.25,
a
= 2,
b
= 5,
n_theta = 25, −− you'll never need more, ' ause there ' s an q ∗∗ n_theta ∗∗ 2 in denition of
both theta −fun tions with q < 1

n_integral
n_ n
pre ision
_n
}

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

= 50,
= 30,
= 0.001,
= take 30 $ repeat 0

−− Ôóíêöèÿ äëÿ óäîáñòâà ïå÷àòè êîýèöèåíòîâ N
printCnList :: ModelParams −> ()

IO

printCnList param = do
let nlist = _n param
nlist = [1..( n_ n param)℄
nnstr = (\(n, n) −> "n" ++ (show n) ++ ": " ++ (show n))
mapM print $ map nnstr (zip nlist nlist )
return ()

−− Áîëåå−ìåíåå óäîáíîå èçìåíåíèå ïàðàìåòðîâ

renew_params param (phi_0', v_0', tau', alpha', a ', b') =
param {phi_0 = phi_0', v_0 = v_0', tau = tau', a = a', b = b'}
−− 0. àçëè÷íûå õåëïåðû äëÿ óïðîùåíèÿ ðàáîòû END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

73
74
75
76
77
78
79
80
81
82
83

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 1. Âû÷èñëåíèå êîîðäèíàò òî÷åê íà ãðàíèöå âîðîíêè âçðûâà BEGIN
−− Ôóíêöèÿ äëÿ âû÷èñëåíèÿ ñðàçó âñåõ êîîðäèíàò
−− ïîëó÷àåò ïàðàìåòðû ìîäåëè
−− âûäà¼ò ñïèñîê êîîðäèíàò òî÷åê, ïðèãîäíûõ äëÿ ïåðåäà÷è èõ íà ãðàèê
zlist :: ModelParams −> [(
,
)℄

Double Double

zlist param = map onstru tPoint [a', a' + h .. b '℄

where

onstru tPoint e = asPoint $ z param e
asPoint u = (realPart u, imagPart u)
h = (b' − a') / fromInteger n'
a' = pre ision param
b' = ( pi ∗ (tau param) ) / 2
n' = n_integral param

84
85
86
87
88
89
90
91
92
93
94
95
96
97

−−
−−
−−
−−

Ôóíêöèÿ äëÿ âû÷èñëåíèÿ êîîðäèíàò îäíîé òî÷êè íà ãðàíèöå âîðîíêè âçðûâà
ïîëó÷àåò ïàðàìåòðû ìîäåëè è îäíó êîîðäèíàòó òî÷êè íà ãðàíèöå âîðîíêè â ïîëå 'u'
âûäà¼ò êîîðäèíàòû îäíîé òî÷êè â ïîëå 'z'
 äàííîé ìîäåëè èíòåãðèðîâàíèå ïðîèçâîäèòñÿ ïî ëèíèè (pi/4) + i∗e'

z :: ModelParams −> Double −> Complex Double
z param e = nalIntegrate (dzdu param) lowl e n'
where n' = n_integral param
lowl = pre ision param

98
99
100

−− Ôóíêöèè äëÿ ïîëó÷åíèÿ òî÷åê íà âñåõ ãðàíèöàõ îáëàñòè ïî îòäåëüíîñòè

43

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159

−− Òî÷êè íà ãðàíèöå CD

zlistCD param = map onstru tPoint [a', a' + h .. b '℄

where

onstru tPoint e = asPoint $ zCD param e
asPoint u = (realPart u, imagPart u)
h = (b' − a') / fromInteger n'
a' = pre ision param
b' = pi / 4
n' = n_integral param

zCD param e = integrateCD (dzdu param) lowl e n'
where n' = n_integral param
lowl = pre ision param
−− Òî÷êè íà ãðàíèöå BA

zlistBA param = map onstru tPoint [a', a' + h .. b '℄

where

onstru tPoint e = asPoint $ zBA param e
asPoint u = (realPart u, imagPart u)
h = (b' − a') / fromInteger n'
a' = pre ision param
b' = pi / 4
n' = n_integral param

zBA param e = integrateBA tau' (dzdu param) lowl e n'
where n' = n_integral param
lowl = pre ision param
tau' = tau param
−− Òî÷êè íà ãðàíèöå CB

zlistCB param = map onstru tPoint [a', a' + h .. b '℄

where

onstru tPoint e = asPoint $ zCB param e
asPoint u = (realPart u, imagPart u)
h = (b' − a') / fromInteger n'
a' = pre ision param
b' = ( pi ∗ (tau param) ) / 4
n' = n_integral param

zCB param e = integrateCB (dzdu param) lowl e n'
where n' = n_integral param
lowl = pre ision param
−− Òî÷êè íà ãðàíèöå DA

zlistDA param = map onstru tPoint [a', a' + h .. b '℄

where

onstru tPoint e = asPoint $ zDA param e
asPoint u = (realPart u, imagPart u)
h = (b' − a') / fromInteger n'
a' = pre ision param
b' = ( pi ∗ (tau param) ) / 4
n' = n_integral param

zDA param e = integrateDA (dzdu param) lowl e n'
where n' = n_integral param
lowl = pre ision param
−− 1. Âû÷èñëåíèå êîîðäèíàò òî÷åê íà ãðàíèöå âîðîíêè âçðûâà END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

160

44

161
162
163
164
165
166
167
168
169

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 2. Êîîðäèíàòû òî÷êè íà ãðàíèöå âîðîíêè âçðûâà ïîëó÷àåì èíòåãðèðîâàíèåì dz/du BEGIN

dzdu :: ModelParams −> Complex Double −> Complex Double
dzdu param u = ((dwdu param u) / v_0') ∗ exp ( negate $ hi param u )
where v_0' = (v_0 param :+ 0)
−− 2. Êîîðäèíàòû òî÷êè íà ãðàíèöå âîðîíêè âçðûâà ïîëó÷àåì èíòåãðèðîâàíèåì dz/du END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 3. Ïðîèçâîäíàÿ êîìïëåêñíîãî ïîòåíöèàëà BEGIN

dwdu :: ModelParams −> Complex Double −> Complex Double
dwdu param u = (npar ∗ mpar ∗ divident) / divisor

where

npar = 0 :+ ((phi_0' ∗ 2) / pi )
mpar = (mdivident / mdivisor) ^ 2
mdivident = theta2' param 0 ∗ theta3' param 0 ∗ theta4' param 0
mdivisor = abs $ (theta1' param pA) ^ 2
pA = (pi/4) :+ (pi ∗ tau' / 4)
divident = theta1' param pB' ∗ theta1' param pB ∗ theta2' param pB' ∗ theta2' param pB
divisor = theta1' param pD' ∗ theta1' param pD ∗ theta4' param pD' ∗ theta4' param pD
pB = u + (0 :+ (pi ∗ tau' / 4))
pB' = u − (0 :+ (pi ∗ tau' / 4))
pD = u + ((pi / 4) :+ 0)
pD' = u − ((pi / 4) :+ 0)
tau' = tau param
phi_0' = phi_0 param

−− 3. Ïðîèçâîäíàÿ êîìïëåêñíîãî ïîòåíöèàëà END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

193
194
195
196
197
198
199
200
201

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 4. Ôóíêöèÿ Æóêîâñêîãî BEGIN

hi :: ModelParams −> Complex Double −> Complex Double
hi param u = ( hi_0 param u) − (f_ orr param u)
−− 4. Ôóíêöèÿ Æóêîâñêîãî END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 5. Ôóíêöèÿ Æóêîâñêîãî äëÿ óïðîù¼ííîé çàäà÷è BEGIN
hi_0 :: ModelParams −>
−>
hi_0 param u = par + (gamma :+ 0) ∗
(divident / divisor)

where

Complex Double
log

Complex Double

par = 0 :+ (pi ∗ (gamma − 1))
gamma = alpha param
divident = (theta1' param pD ) ∗ (theta4' param pD )
divisor = (theta1' param pD') ∗ (theta4' param pD')
pD = u + ((pi / 4) :+ 0)
pD' = u − ((pi / 4) :+ 0)

−− 5. Ôóíêöèÿ Æóêîâñêîãî äëÿ óïðîù¼ííîé çàäà÷è END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

217
218
219
220

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 6. Êîððåêòèðóþùàÿ óíêöèÿ f(u) BEGIN
f_ orr :: ModelParams −>
−>

Complex Double

Complex Double

45

221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

f_ orr param u = onst_part + (foldl (+) 0 (f_arg u list ))

where

onst_part
gamma
0
f_arg u list
list
exp' n
rho n
n'
tau'

= ((4 ∗ (1 − (gamma/2)) ∗ negate(1/tau') ) :+ 0) ∗ u
= alpha param
= 0 :+ 0 −− :)
= map (\ (n, n) −> (( n ∗ (1 − rho n)) :+ 0) ∗ exp' n) list
= zip [1..( n_ n param)℄ n'
= exp $ (4 ∗ u − pi ∗ ( fromInteger n)) / (tau' :+ 0)
= exp $ (negate (2 ∗ pi ∗ fromInteger n)) / tau'
= _n param
= tau param

−− 6. Êîððåêòèðóþùàÿ óíêöèÿ f(u) END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− Çäåñü ìû çàêîí÷èëè ñ êàðêàñîì äëÿ âû÷èñëåíèÿ ñîáñòâåííî êîîðäèíàò òî÷åê. Íî äëÿ òîãî,

÷òîáû êîððåêòèðóþùàÿ óíêöèÿ ðàáîòàëà, íåîáõîäèìî, ÷òîáû áûëè âû÷èñëåíû êîýèöèåíòû
N.

237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 7. Âû÷èñëåíèå êîýèöèåíòîâ N BEGIN
−− Ôóíêöèÿ äëÿ îáíîâëåíèÿ êîýèöèåíòîâ, óæå çàïèñàííûõ â ModelParams.
−− Îíà ðåêóðñèâíàÿ ñ óñëîâèåì îñòàíîâêè. Îñíîâàíà íà ìåòîäå ïðîñòûõ èòåðàöèé.
renew_ n_all :: ModelParams −>
(ModelParams)

IO

renew_ n_all param = do
print "renew_ n_all started"
new_param <− al _new_ nlist param
err <− high_error param new_param
if err == True
then renew_ n_all new_param
else return $ new_param

−− Äîïîëíèòåëüíàÿ óíêöèÿ äëÿ âû÷èñëåíèÿ íîâûõ êîýèöèåíòîâ.
−− Ïîëó÷àåò òåêóùèå ModelParams
−− Âîçâðàùàåò îáíîâë¼ííûå ModelParams
al _new_ nlist :: ModelParams −>
(ModelParams)

al _new_ nlist param = do
print " al _new_ nlist started"
print " urrent nlist :"
printCnList param

IO

−− Âû÷èñëÿåì íîâûå ïàðàìåòðû

let

n' = n_ n param
new_ n = map ( al _ n param) [1..n'℄
new_param = param { _n = new_ n}
print "new nlist :"
printCnList new_param
return new_param

268

−− Äîïîëíèòåëüíàÿ óíêöèÿ äëÿ îïðåäåëåíèÿ òîãî, âåëèêà ëè îøèáêà (è íàäî ëè ïðîäîëæàòü

269

−− Ïîëó÷àåò ñòàðûå ModelParams è íîâûå ModelParams.
−− Âîçâðàùàåò True åñëè îøèáêà âåëèêà è False â ïðîòèâíîì ñëó÷àå
high_error :: ModelParams −> ModelParams −> (
)

270
271
272
273
274
275
276
277

âû÷èñëåíèÿ)

IO Bool

high_error old_param new_param = do
let old_ n = _n old_param
new_ n = _n new_param
errlist = map al _error (zip old_ n new_ n)
err = (> pre ision ') $ foldl (+) 0 errlist
−− Âû÷èñëÿåì îøèáêó

46

278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332

al _error (x1, x2) = ((x2 − x1) ∗∗ 2 ) / abs (2 ∗ x1 − x2)
pre ision ' = pre ision old_param
print $ "Error list : " ++ ((show . map (<pre ision')) errlist )
print $ "Is error big totally : " ++ (show err)
return err
−−
−−
−−
−−

Ôóíêöèÿ äëÿ âû÷èñëåíèÿ íîâîãî êîýèöèåíòà íà îñíîâå âåêòîðà ñóùåñòâóþùèõ.
ïðèíèìàåò îáúåêò ModelParams (îòòóäà áåð¼ò âåêòîð N)
ïðèíèìàåò íîìåð êîýèöèåíòà M
âîçâðàùàåò ÷èñëî −−− óòî÷í¼ííîå çíà÷åíèå ñ(M)

al _ n :: ModelParams −> Integer −> Double
al _ n param n = (negate divident / divisor ) ∗ ( ifun param n / ifun param 0)

where

divident
divisor
rho
tau'
gamma

= 2 ∗ (1 − (gamma / 2))
= fromInteger n ∗ (1 + rho)
= exp $ negate 2 ∗ (pi/tau') ∗
= tau param
= alpha param

fromInteger n

ifun :: ModelParams −> Integer −> Double
ifun param n = integrate f lowl ( pi ∗ tau' / 4) n'

where
lowl

= pre ision param −− Ýòî õàê.  íóëå óíêöèÿ qfun' îáðàùàåòñÿ â áåñêîíå÷íîñòü

(äåëåíèå íà íîëü).

f e
= urvature param (t e) ∗ qfun' param e ∗ osfun e
osfun e = os $ 4 ∗ fromInteger n ∗ e / tau'
n'
= n_integral param
tau'
= tau param
t e
= imagPart ( hi param (0 :+ e))
qfun' :: ModelParams −> Double −> Double
qfun' param e = ((divident ^ 2) ∗ (efun param e)) / ( divisor1 ∗ divisor2 )

where

divident = (realPart . abs) $ theta2' param eA ∗ theta2' param eA'
divisor1 = ((∗∗ gamma1) . realPart . abs) $ (theta2' param ie) ∗ (theta3' param ie)
divisor2 = ((∗∗ gamma2) . realPart . abs) $ (theta1' param ie) ∗ (theta4' param ie)
eA = ((pi / 4) :+ (e + (pi ∗ tau' / 4)))
eA' = ((pi / 4) :+ (e − (pi ∗ tau' / 4)))
ie = (0 :+ e)
tau' = tau param
gamma1 = (1 + alpha param)
gamma2 = (1 − alpha param)

efun :: ModelParams −> Double −> Double
efun param e = (exp . sum) $ map (transform e) nlist

where

transform e (n, n) = n ∗ (1 − exparg n) ∗ osarg n ∗ e
exparg n = exp $ negate 2 ∗ pi ∗ fromInteger n / tau'
osarg n = os $ 4 ∗ fromInteger n / tau'
nlist = zip [1.. n '℄ n'
n' = tail $ _n param
n' = n_ n param
tau' = tau param

−− 7. Âû÷èñëåíèå êîýèöèåíòîâ N END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

333
334
335
336

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 8. Ôóíêöèÿ êðèâèçíû BEGIN

47

337
338
339
340
341
342
343
344
345
346
347
348
349
350
351

−−
−−
−−
−−

Îïðåäåëåíà êàê êðèâèçíà â òî÷êàõ, ðàñïîëîæåííûõ âäîëü êðèâîé.
Ò. î., ïàðàìåòðèçîâàíà äëèíîé êðèâîé, è èìååò îäèí àðãóìåíò.
ïîëó÷àåò ïàðàìåòð óêàçûâàþùèé íà òî÷êó íà êðèâîëèíåéíîé äóãå,
âûäà¼ò çíà÷åíèå êðèâèçíû â ýòîé òî÷êå

urvature :: ModelParams −> Double −> Double
urvature param x = ((1 − epssin) ∗∗ (3/2)) / p
where epssin = (epsilon ∗ ( sin x)) ^ 2
epsilon = ( sqrt ( b'∗b' − a'∗a' ) ) / b'
p = (a'∗a') / (b'∗b')
a' = a param
b' = b param

−− 8. Ôóíêöèÿ êðèâèçíû END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

352
353
354
355
356

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 9. Îïåðàòîðû èíòåãðèðîâàíèÿ BEGIN

357

−− Îïåðàòîð èíòåãðèðîâàíèÿ ïî îðäèíàòå. Òî åñòü, èíòåãðèðóåì óíêöèþ êîìïëåêñíîãî

358

−− Èñïîëüçóåòñÿ ìåòîä òðàïåöèé. Âðîäå êàê.
−− íà âõîä ïîëó÷àåì óíêöèþ êîìïëåêñíîãî àðãóìåíòà, íà÷àëüíóþ îðäèíàòó, êîíå÷íóþ îðäèíàòó è

359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389

ïåðåìåííîãî f(x + iy) ïî ëèíèè (0 + ia) .. (0 + ib).
êîëè÷åñòâî îòðåçêîâ ðàçáèåíèÿ ñåòêè.

integrateY :: ( RealFloat a, Enum a) => (Complex a −> Complex a) −> a −> a −> Integer −>
Complex a
integrateY f a b n =
(( sum $ map f yvalues) + t) ∗ (h :+ 0)

where

values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
yvalues = map ((:+) x) values −− DO NOT REMOVE BRACKETS AROUND ':+'
t = (f (x :+ a) + f (x :+ b))/2
h = (b − a) / fromInteger(n)
x=0

−− Òîò æå ñàìûé integrateY, òîëüêî èíòåãðèðîâàíèå ïðîèçâîäèòñÿ ïî ((pi/4) + ia) .. ((pi/4) + ib) 
nalIntegrate :: (
a,
a)
(
a −>
a) −> a −> a −>
−>
a

RealFloat Enum => Complex
Complex
Integer
Complex 
nalIntegrate f a b n =
(( sum $ map f yvalues) + t) ∗ (h :+ 0)
where
values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
yvalues = map ((:+) x) values −− DO NOT REMOVE BRACKETS AROUND ':+'
t = (f (x :+ a) + f (x :+ b))/2
h = (b − a) / fromInteger(n)
x = pi / 4
integrateCD,integrateDA,integrateCB :: ( RealFloat a, Enum a) => (Complex a −> Complex a) −>
a −> a −> Integer −> Complex a
integrateCB f a b n =
(( sum $ map f yvalues) + t) ∗ (h :+ 0)
where
values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
yvalues = map ((:+) x) values −− DO NOT REMOVE BRACKETS AROUND ':+'
t = (f (x :+ a) + f (x :+ b))/2
h = (b − a) / fromInteger(n)
x=0

390

48

391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418

integrateBA :: ( RealFloat a, Enum a) => a −> (Complex a −> Complex a) −> a −> a −>
Integer −> Complex a
integrateBA tau' f a b n =
(( sum $ map f xvalues) + t) ∗ (h :+ 0)

where

values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
xvalues = map (:+ y) values
t = (f (a :+ y) + f (b :+ y))/2
h = (b − a) / fromInteger(n)
y = pi ∗ tau' / 4

integrateCD f a b n =
(( sum $ map f xvalues) + t) ∗ (h :+ 0)

where

values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
xvalues = map (:+ y) values
t = (f (a :+ y) + f (b :+ y))/2
h = (b − a) / fromInteger(n)
y=0

integrateDA f a b n =
(( sum $ map f yvalues) + t) ∗ (h :+ 0)

where

values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
yvalues = map ((:+) x) values −− DO NOT REMOVE BRACKETS AROUND ':+'
t = (f (x :+ a) + f (x :+ b))/2
h = (b − a) / fromInteger(n)
x = pi / 4

419

−− Îïåðàòîð èíòåãðèðîâàíèÿ ïî àáñöèññå. Òî åñòü, èíòåãðèðóåì óíêöèþ êîìïëåêñíîãî

420

−− Èñïîëüçóåòñÿ ìåòîä òðàïåöèé. Âðîäå êàê.
−− íà âõîä ïîëó÷àåì óíêöèþ êîìïëåêñíîãî àðãóìåíòà, íà÷àëüíóþ àáñöèññó, êîíå÷íóþ àáñöèññó è

421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444

ïåðåìåííîãî f(x + iy) ïî ëèíèè (a + i0) .. (b + i0).
êîëè÷åñòâî îòðåçêîâ ðàçáèåíèÿ ñåòêè.

integrateX :: ( RealFloat a, Enum a) => (Complex a −> Complex a) −> a −> a −> Integer −>
Complex a
integrateX f a b n =
(( sum $ map f xvalues) + t) ∗ (h :+ 0)

where

values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
xvalues = map (:+ 0) values
t = (f (a :+ 0) + f (b :+ 0))/2
h = (b − a) / fromInteger(n)

integrateYreal :: (Double −> Complex Double) −> Double −> Double −> Integer −> Complex

Double

integrateYreal f a b n =
(( sum $ map f values) + t) ∗ (h :+ 0)

where

values = [a + h ∗ fromInteger(nn) | nn <− [0..n℄℄
t = (f a + f b) / (2 :+ 0)
h = (b − a) / fromInteger(n)
x=0

−− Îïåðàòîð èíòåãðèðîâàíèÿ äåéñòâèòåëüíîçíà÷íûõ óíêöèé ìåòîäîì òðàïåöèé.
−− Ïîëó÷àåò íà âõîä óíêöèþ, íèæíèé ïðåäåë èíòåãðèðîâàíèÿ, âåðõíèé ïðåäåë èíòåãðèðîâàíèÿ è

êîëè÷åñòâî îòðåçêîâ ðàçáèåíèÿ ñåòêè.

integrate f a b n =
(( sum $ map f values) + t) ∗ h

where

49

values = [a + h ∗ fromInteger(nn) | nn <− [0..(n−1)℄℄
t = (f a + f b)/2
h = (b − a) / fromInteger(n)

445
446
447
448
449
450

−− 9. Îïåðàòîðû èíòåãðèðîâàíèÿ END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

B
1
2
3
4

Theta.hs

module Theta where

−− åàëèçàöèÿ òåòà−óíêöèé íà îñíîâå òðèãîíîìåòðè÷åñêèõ ðÿäîâ.
−− Òåòà−óíêöèè çàâèñÿò îò ïàðàìåòðà tau, ìíèìàÿ ÷àñòü êîòîðîãî äîëæíà áûòü ïîëîæèòåëüíà.
−− Òàó èñïîëüçóåòñÿ òîëüêî â ïàðàìåòðå 'q' â ñàìèõ óíêöèÿõ, òàê ÷òî ìîæíî ñ÷èòàòü, ÷òî
ìàòåìàòè÷åñêè òåòà−óíêöèè çàâèñÿò îò êüþ, íî òåõíè÷åñêè ðàáîòà ýòîãî ìîäóëÿ çàâèñèò îò

íàëè÷èÿ òàó.

5

−− Ëþáóþ óíêöèþ íàäî âûçûâàòü ÷åðåç thetaN <n> (qrap <tau>) <u>

6

import Control. Parallel
import Control. Parallel . Strategies

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

−− Ìû ðàáîòàåì ñ êîìïëåêñíûìè ÷èñëàìè

import Data.Complex

−− Ïàðàìåòð q èç ìàòåìàòè÷åñêîãî ïðåäñòàâëåíèÿ òåòà−óíêöèé.

qpar tau = exp $ pi ∗ tau ∗ (0 :+ 1)

−− Ôóíêöèÿ, èçîáðàæàþùàÿ èç ñåáÿ (−1)^n
signfun :: (
a)
−>

RealFloat => Integer

signfun nn
| odd nn = −1
| otherwise = 1

Complex a

−− Ôóíêöèÿ \Theta_1

theta1 :: ( RealFloat a) => Integer −> Complex a −> Complex a −> Complex a
theta1 n q u = 2 ∗ sum thetaarg
where thetaarg = [(signfun nn) ∗ (qfun q nn) ∗ ( sinfun u nn) | nn <− [1..n℄℄
qfun :: ( RealFloat a) => Complex a −> Integer −> Complex a
qfun q nn = q ∗∗ (0.5 + fromInteger nn) ∗∗ 2
sinfun :: ( RealFloat a) => Complex a −> Integer −> Complex a
sinfun u nn = sin $ fromInteger(2 ∗ nn + 1) ∗ u

−− Ôóíêöèÿ \Theta_2

theta2 :: ( RealFloat a) => Integer −> Complex a −> Complex a −> Complex a
theta2 n q u = 2 ∗ sum thetaarg
where thetaarg = [(qfun q nn) ∗ ( osfun u nn) | nn <− [1..n℄℄
qfun :: ( RealFloat a) => Complex a −> Integer −> Complex a
qfun q nn = q ∗∗ (0.5 + fromInteger nn) ∗∗ 2
osfun :: (RealFloat a) => Complex a −> Integer −> Complex a
osfun u nn = os $ fromInteger(2 ∗ nn + 1) ∗ u

−− Ôóíêöèÿ \Theta_3

theta3 :: ( RealFloat a) => Integer −> Complex a −> Complex a −> Complex a
theta3 n q u = 1 + 2 ∗ sum thetaarg
where thetaarg = [(qfun q nn) ∗ ( osfun u nn) | nn <− [1..n℄℄
qfun :: ( RealFloat a) => Complex a −> Integer −> Complex a
qfun q nn = q ∗∗ (fromInteger nn) ∗∗ 2
osfun :: (RealFloat a) => Complex a −> Integer −> Complex a
osfun u nn = os $ fromInteger (2 ∗ nn) ∗ u

50

49
50
51
52
53
54
55
56

−− Ôóíêöèÿ \Theta_4

theta4 :: ( RealFloat a) => Integer −> Complex a −> Complex a −> Complex a
theta4 n q u = 1 + 2 ∗ sum thetaarg
where thetaarg = [(signfun nn) ∗ (qfun q nn) ∗ ( osfun u nn) | nn <− [1..n℄℄
qfun :: ( RealFloat a) => Complex a −> Integer −> Complex a
qfun q nn = q ∗∗ fromInteger(nn) ∗∗ 2
osfun :: (RealFloat a) => Complex a −> Integer −> Complex a
osfun u nn = os $ fromInteger(2 ∗ nn) ∗ u

C
1
2

Main.hs

module Main where

3

−− Ñêîðåå âñåãî, çäåñü íå ïîíàäîáèòñÿ ýòîò ìîäóëü, ïîòîìó ÷òî ðàáîòà ñ êîìïëåêñíûìè ÷èñëàìè

4

−−import Data.Complex

5
6
7
8
9
10
11
12
13
14
15

áóäåò èíêàïñóëèðîâàíà â ìîäóëå BlastModel

−− Èìïîðòèðóåì ñîáñòâåííî ñàìó ìîäåëü

import BlastModel

−− Ìîäóëè, íåîáõîäèìûå äëÿ ïîääåðæêè ÷åð÷åíèÿ ãðàèêîâ óíêöèé

import Graphi s.Rendering.Chart
import Graphi s.Rendering.Chart.Gtk
import Data.Colour
import Data.Colour.Names
import Data.A essor

16

−− Ìîäóëü äëÿ îöåíêè âðåìåíè âûïîëíåíèÿ òîé èëè èíîé óíêöèè. Ñàìîïèñíûé, íà îñíîâå áîëåå

17

import Time

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

íèçêîóðîâíåâûõ ìîäóëåé

−− Òî÷êà âõîäà ïðîãðàììû. Ïðîãðàììà äåëàåò ïîñëåäîâàòåëüíî ðÿä øàãîâ è çàâåðøàåòñÿ.

main = do

−− 1. Ïå÷àòàåì ïðèãëàøåíèå è îïèñàíèå òîãî, êòî ìû òàêèå âîîáùå.

printGreeting

−− 2. Çàãðóæàåì ïàðàìåòðû òåì èëè èíûì ñïîñîáîì
param <− getParameters
−− 3. Ïå÷àòàåì ïàðàìåòðû, ñ êîòîðûìè â èòîãå ðàáîòàåì.

printParameters param

−− 4. Îáíîâëÿåì â ïàðàìåòðàõ ñïèñîê êîýèöèåíòîâ N `` _n param``
−− 4.5. Âûâîäèì äàííûå îöåíêè âðåìåíè âûïîëíåíèÿ
new_param <− renewCoes param
−− 5. Âû÷èñëÿåì ñïèñîê òî÷åê íà ãðàíèöå âîðîíêè âçðûâà
−− 5.5. Âûâîäèì äàííûå îöåíêè âðåìåíè âûïîëíåíèÿ
pointlist <− al Points new_param

let

linetitle = extra t_param_names new_param

−− 6. Ïåðåäà¼ì ñïèñîê òî÷åê óíêöèè ÷åð÷åíèÿ ãðàèêà, êîòîðàÿ ÷åðòèò ãðàèê

plotFullGraph linetitle

pointlist

−− 7. Ïèøåì, ÷òî âñ¼ ïðîøëî óñïåøíî, òàê ÷òî çàâåðøàåìñÿ

printGoodbye

−− Òî÷êà âõîäà ïðîãðàììû END

39
40
41
42
43
44
45
46

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 1. Ïå÷àòàåì ïðèãëàøåíèå è îïèñàíèå òîãî, êòî ìû òàêèå âîîáùå. BEGIN

printGreeting :: IO ()
printGreeting = do
putStrLn "Greetings!~ This is blast model, based on solid−liquid model of Lavrentyev and Kotlyar."

−− 1. Ïå÷àòàåì ïðèãëàøåíèå è îïèñàíèå òîãî, êòî ìû òàêèå âîîáùå. END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

51

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 2. Çàãðóæàåì ïàðàìåòðû òåì èëè èíûì ñïîñîáîì. BEGIN

getParameters :: IO (ModelParams)
getParameters = do
print "[1℄ −−− load parameters manually"
print "[anykey℄ −−− load defaults"
print "Parameters n_integral, n_ n, n_theta stay onstant"
what <− getLine
if what == "1"
then do print "Ok, will load parameters from you"
getModelParameters
else do print "Ok, will load default parameters"
return null_parameters
getModelParameter :: String −> IO(Double)
getModelParameter parname = do
putStr $ "Value of " ++ parname
param <− getLine
return $ read param
getModelParameters :: IO (ModelParams)
getModelParameters = do
print
"Value of phi_0:"
phi_0'
<− getLine
print
"Value of v_0:"
v_0'
<− getLine
print
"Value of |tau |: "
tau'
<− getLine
print
"Value of alpha:"
alpha'
<− getLine
print
"Value of a:"
a'
<− getLine
print
"Value of b:"
b'
<− getLine
print
" Pre ision :"
pre ision ' <− getLine
−−
−−
−−
−−

Ïàðàìåòðû òî÷íîñòè êîíñòàíòíûå, ïîòîìó ÷òî.
n_theta' <− getModelParameter "n_theta"
n_integral' <− getModelParameter "n_integral"
n_ n'
<− getModelParameter "n_ n"

print
" Filler for _n:" 
ll_ n
<− getLine
return ModelParams{
phi_0
= read phi_0',
v_0
= read v_0',
tau
= read tau',
alpha
= read alpha',
a
= read a',
b
= read b',
pre ision = read pre ision ',

−− Áåð¼ì ïàðàìåòðû òî÷íîñòè èç ïàðàìåòðîâ ïî óìîë÷àíèþ

n_theta = n_theta null_parameters,
n_integral = n_integral null_parameters,
n_ n
= n_ n
null_parameters,

−− Íà÷àëüíûå çíà÷åíèÿ êîýèöèåíòîâ ïðèðàâíèâàåì ê çíà÷åíèþ−çàïîëíèòåëþ

_n
}

= repli ate (( fromInteger . n_ n) null_parameters) (read ll_ n )

106

52

107
108

−− 2. Çàãðóæàåì ïàðàìåòðû òåì èëè èíûì ñïîñîáîì. END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

109
110
111
112
113
114
115
116
117
118

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 3. Ïå÷àòàåì ïàðàìåòðû, ñ êîòîðûìè â èòîãå ðàáîòàåì. BEGIN
printParameters :: ModelParams −>
()

IO

printParameters param = do

−− TODO: Íàïèøè ìåíÿ!

print "Current model parameters: "
print param

−− 3. Ïå÷àòàåì ïàðàìåòðû, ñ êîòîðûìè â èòîãå ðàáîòàåì. END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

119
120
121
122
123
124
125
126
127
128
129
130

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 4. Îáíîâëÿåì â ïàðàìåòðàõ ñïèñîê êîýèöèåíòîâ N `` _n param``. BEGIN
renewCoes :: ModelParams −>
(ModelParams)

IO

renewCoes param = do
putStrLn "Se ond, we ompute the parameters _n needed for omputations"

−− 4.5. Âûâîäèì äàííûå îöåíêè âðåìåíè âûïîëíåíèÿ
new_param <− time $ renew_ n_all param

return new_param

−− 4. Îáíîâëÿåì â ïàðàìåòðàõ ñïèñîê êîýèöèåíòîâ N `` _n param``. END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 5. Âû÷èñëÿåì ñïèñîê òî÷åê íà ãðàíèöå âîðîíêè âçðûâà. BEGIN

type PointList = [(Double, Double)℄
type BAPointList = PointList
type CDPointList = PointList
type CBPointList = PointList
type DAPointList = PointList
type ZPlanePoints = (CBPointList, CDPointList, DAPointList, BAPointList)
al Points :: ModelParams −> IO (ZPlanePoints)
al Points param = do
print "We will now ompute points on the edge of blast."
let da_pointlist = ( init . tail ) $ zlistDA param
ba_pointlist = ( init . tail ) $ zlistBA param
b_pointlist = ( init . tail ) $ zlistCB param
d_pointlist = ( init . tail ) $ zlistCD param
−−5.5. TODO: Âûâîäèì äàííûå îöåíêè âðåìåíè âûïîëíåíèÿ
print "Points at DA: "
time $ outputData da_pointlist
print "Points at BA: "
time $ outputData ba_pointlist
print "Points at CD: "
time $ outputData d_pointlist
print "Points at CB: "
time $ outputData b_pointlist
return ( b_pointlist , d_pointlist , da_pointlist , ba_pointlist )
outputData datalist = do
mapM (\(x, y) −> putStrLn $ (show x) ++ "; " ++ (show y)) datalist
return ()
−− 5. Âû÷èñëÿåì ñïèñîê òî÷åê íà ãðàíèöå âîðîíêè âçðûâà. END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

164
165
166

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 6. Ïåðåäà¼ì ñïèñîê òî÷åê óíêöèè ÷åð÷åíèÿ ãðàèêà, êîòîðàÿ ÷åðòèò ãðàèê. BEGIN

53

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

extra t_param_names param =
let phi0 = show $ phi_0 param
v0
= show $ v_0 param
alpha0 = show $ alpha param
a0
= show $ a param
b0
= show $ b param
abstau = show $ tau param
pre ision0 = show $ pre ision param
in "Phi0 = " ++ phi0 ++ ", V0 = " ++ v0 ++ ", Alpha0 = " ++ alpha0 ++ ", A = " ++ a0
++ ", B = " ++ b0 ++ ", tau = " ++ abstau ++ ", pre ision = " ++ pre ision0
plotGraph :: String −> PointList −> IO()
plotGraph linetitle datalist = do
renderableToWindow (toRenderable ( hart linetitle
renderableToPNGFile (toRenderable ( hart linetitle
return ()

datalist )) 640 480
datalist )) 640 480 ( linetitle ++ ".png")

plotFullGraph :: String −> ZPlanePoints −> IO()
plotFullGraph linetitle datalists = do
renderableToWindow (toRenderable (many hart linetitle datalists )) 640 480
renderableToPNGFile (toRenderable (many hart linetitle datalists )) 640 480 ( linetitle ++
".png")
return ()
hart :: String −> PointList −> Layout1 Double Double
hart linetitle datalist = layout

where

myPlot = plot_lines_values ^= [datalist ℄
$ plot_lines_style .> line_ olor ^= opaque blue
$ plot_lines_title ^= linetitle
$ defaultPlotLines
layout = layout1_title ^= "Form of blast edge"
$ layout1_plots ^= [Left (toPlot myPlot)℄
$ defaultLayout1

many hart :: String −> ZPlanePoints −> Layout1 Double Double
many hart linetitle (pointsCB, pointsCD, pointsBA, pointsDA) = layout

where

plotBA = plot_lines_values ^= [pointsBA℄
$ plot_lines_style .> line_ olor ^= opaque green
$ plot_lines_title ^= "BA"
$ defaultPlotLines
plotDA = plot_lines_values ^= [pointsDA℄
$ plot_lines_style .> line_ olor ^= opaque red
$ plot_lines_title ^= "DA"
$ defaultPlotLines
plotCB = plot_lines_values ^= [pointsCB℄
$ plot_lines_style .> line_ olor ^= opaque blue
$ plot_lines_title ^= "CB: " ++ linetitle
$ defaultPlotLines
plotCD = plot_lines_values ^= [pointsCD℄
$ plot_lines_style .> line_ olor ^= opaque yan
$ plot_lines_title ^= "CD"
$ defaultPlotLines
layout = layout1_title ^= "Form of blast edge"
$ layout1_plots ^= [
Left (toPlot plotBA),
Left (toPlot plotDA),
−− Left (toPlot plotCD),

54

Left (toPlot plotCB)

225


$ defaultLayout1

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248

−−
−−
−−
−−
−−
−−
−−
−−
−−
−−
−−
−−
−−
−−
−−
−−
−−

Ïðèìåð îîðìëåíèÿ ÷åðòåæà

−− hart = layout
−− where
−− am :: Double −> Double
−− am x = (sin (x∗3.14159/45) + 1) / 2 ∗ ( sin (x∗3.14159/5))
−− sinusoid1 = plot_lines_values ^= [[ (x ,( am x)) | x <− [0,(0.5) ..400℄℄℄
−−
$ plot_lines_style .> line_ olor ^= opaque blue
−−
$ plot_lines_title ^= "am"
−−
$ defaultPlotLines
−− sinusoid2 = plot_points_style ^= lledCir les 2 (opaque red)
−−
$ plot_points_values ^= [ (x,(am x)) | x <− [0,7..400℄℄
−−
$ plot_points_title ^= "am points"
−−
$ defaultPlotPoints
−− layout = layout1_title ^= "Amplitude Modulation"
−−
$ layout1_plots ^= [Left (toPlot sinusoid1 ) ,
−−
Left (toPlot sinusoid2 ) ℄
−−
$ defaultLayout1

−− 6. Ïåðåäà¼ì ñïèñîê òî÷åê óíêöèè ÷åð÷åíèÿ ãðàèêà, êîòîðàÿ ÷åðòèò ãðàèê. END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

249
250
251
252
253
254
255
256
257

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− 7. Ïèøåì, ÷òî âñ¼ ïðîøëî óñïåøíî, òàê ÷òî çàâåðøàåìñÿ. BEGIN

IO ()
printGoodbye = do
putStrLn "All done, good bye."
printGoodbye ::

−− 7. Ïèøåì, ÷òî âñ¼ ïðîøëî óñïåøíî, òàê ÷òî çàâåðøàåìñÿ. END
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284

−− Àâòîìàòèçèðîâàííûå òåñòû äëÿ íåêîòîðîãî ïîêðûòèÿ ïîëÿ ïàðàìåòðîâ ìîäåëè
silentlyPlotGraph :: ModelParams −> ()

IO

silentlyPlotGraph param = do
new_param <− renewCoes param
pointlist <− al Points new_param
let linetitle = extra t_param_names new_param
renderableToPNGFile (toRenderable (many hart linetitle pointlist )) 640 480 ( linetitle ++ ".png")
return ()

testPhi0 :: ModelParams −> IO()
testPhi0 param = do
let plotWithPhi0 p = silentlyPlotGraph param{phi_0 = (p ∗ 0.1)}
mapM plotWithPhi0 [0..20℄
return ()
testV0 :: ModelParams −> IO()
testV0 param = do
let plotWithV0 p = silentlyPlotGraph param{v_0 = (p ∗ 15)}
mapM plotWithV0 [0..10℄
return ()
testTau :: ModelParams −> IO()
testTau param = do
let plotWithTau p = silentlyPlotGraph param{tau = (p ∗ 0.1)}
mapM plotWithTau [1..10℄

55

285
286
287
288
289
290
291

return ()
testAlpha :: ModelParams −> IO()
testAlpha param = do
let plotWithAlpha p = silentlyPlotGraph param{alpha = (p ∗ 0.1)}
mapM plotWithAlpha [0..10℄
return ()

56