123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804 |
- Sun Aug 18 18:00:52 2002 run on Windows
- %***********************************************************************
- %***** *****
- %***** Package F I D E - Test Examples Ver. 1.1.2 May 29,1995 *****
- %***** *****
- %***********************************************************************
- %***********************************************************************
- %***** *****
- %***** T e s t Examples --- Module E X P R E S *****
- %***** *****
- %***********************************************************************
- let cos th**2=1 - sin th**2,
- cos fi**2=1 - sin fi**2;
- factor df;
- on rat;
- for all x,y let diff(x,y)=df(x,y);
- depend u,r,th,fi;
- depend v,r,th,fi;
- depend f,r,th,fi;
- depend w,r,th,fi;
- % Spherical coordinate system
- scalefactors 3,r*sin th*cos fi,r*sin th*sin fi,r*cos th,r,th,fi;
- tensor a1,a2,a3,a4,a5;
- vectors u,v;
- dyads w;
- a1:=grad f;
- a1:= ( df(f,r) ,
- df(f,th)
- ---------- ,
- r
- df(f,fi)
- ----------- )
- sin(th)*r
- a2:=div u;
- df(u(3),fi) df(u(2),th) cos(th)*u(2) + 2*sin(th)*u(1)
- a2:=------------- + ------------- + df(u(1),r) + -------------------------------
- sin(th)*r r sin(th)*r
- a3:=curl v;
- df(v(3),th) - df(v(2),fi) cos(th)*v(3)
- a3:= ( ------------- + ---------------- + -------------- ,
- r sin(th)*r sin(th)*r
- df(v(1),fi) - v(3)
- - df(v(3),r) + ------------- + --------- ,
- sin(th)*r r
- - df(v(1),th) v(2)
- df(v(2),r) + ---------------- + ------ )
- r r
- a4:=lapl v;
- - 2*df(v(3),fi) - 2*df(v(2),th) df(v(1),fi,2)
- a4:= ( ------------------ + ------------------ + --------------- + df(v(1),r,2)
- 2 2 2 2
- sin(th)*r r sin(th) *r
- 2*df(v(1),r) df(v(1),th,2) df(v(1),th)*cos(th)
- + -------------- + --------------- + ---------------------
- r 2 2
- r sin(th)*r
- 2*(cos(th)*v(2) + sin(th)*v(1))
- - --------------------------------- ,
- 2
- sin(th)*r
- - 2*df(v(3),fi)*cos(th) df(v(2),fi,2)
- -------------------------- + --------------- + df(v(2),r,2)
- 2 2 2 2
- sin(th) *r sin(th) *r
- 2*df(v(2),r) df(v(2),th,2) df(v(2),th)*cos(th)
- + -------------- + --------------- + ---------------------
- r 2 2
- r sin(th)*r
- 2*df(v(1),th) - v(2)
- + --------------- + ------------- ,
- 2 2 2
- r sin(th) *r
- df(v(3),fi,2) 2*df(v(3),r) df(v(3),th,2)
- --------------- + df(v(3),r,2) + -------------- + ---------------
- 2 2 r 2
- sin(th) *r r
- df(v(3),th)*cos(th) 2*df(v(2),fi)*cos(th) 2*df(v(1),fi)
- + --------------------- + ----------------------- + ---------------
- 2 2 2 2
- sin(th)*r sin(th) *r sin(th)*r
- - v(3)
- + ------------- )
- 2 2
- sin(th) *r
- a3:=2*a3+a4;
- - 2*df(v(3),fi) 2*df(v(3),th) - 2*df(v(2),fi)
- a3:= ( ------------------ + --------------- + ------------------
- 2 r sin(th)*r
- sin(th)*r
- - 2*df(v(2),th) df(v(1),fi,2) 2*df(v(1),r)
- + ------------------ + --------------- + df(v(1),r,2) + --------------
- 2 2 2 r
- r sin(th) *r
- df(v(1),th,2) df(v(1),th)*cos(th)
- + --------------- + ---------------------
- 2 2
- r sin(th)*r
- 2*(cos(th)*v(3)*r - cos(th)*v(2) - sin(th)*v(1))
- + -------------------------------------------------- ,
- 2
- sin(th)*r
- - 2*df(v(3),fi)*cos(th) df(v(2),fi,2)
- -------------------------- - 2*df(v(3),r) + ---------------
- 2 2 2 2
- sin(th) *r sin(th) *r
- 2*df(v(2),r) df(v(2),th,2)
- + df(v(2),r,2) + -------------- + ---------------
- r 2
- r
- df(v(2),th)*cos(th) 2*df(v(1),fi) 2*df(v(1),th)
- + --------------------- + --------------- + ---------------
- 2 sin(th)*r 2
- sin(th)*r r
- 2
- - 2*sin(th) *v(3)*r - v(2)
- + ----------------------------- ,
- 2 2
- sin(th) *r
- df(v(3),fi,2) 2*df(v(3),r) df(v(3),th,2)
- --------------- + df(v(3),r,2) + -------------- + ---------------
- 2 2 r 2
- sin(th) *r r
- df(v(3),th)*cos(th) 2*df(v(2),fi)*cos(th)
- + --------------------- + ----------------------- + 2*df(v(2),r)
- 2 2 2
- sin(th)*r sin(th) *r
- 2
- 2*df(v(1),fi) - 2*df(v(1),th) 2*sin(th) *v(2)*r - v(3)
- + --------------- + ------------------ + -------------------------- )
- 2 r 2 2
- sin(th)*r sin(th) *r
- a5:=lapl f;
- df(f,fi,2) 2*df(f,r) df(f,th,2) df(f,th)*cos(th)
- a5:=------------- + df(f,r,2) + ----------- + ------------ + ------------------
- 2 2 r 2 2
- sin(th) *r r sin(th)*r
- a1:=a1+div w;
- df(w(3,1),fi) df(w(2,1),th)
- a1:= ( --------------- + --------------- + df(w(1,1),r) + df(f,r)
- sin(th)*r r
- cos(th)*w(2,1) - sin(th)*w(3,3) - sin(th)*w(2,2) + 2*sin(th)*w(1,1)
- + ---------------------------------------------------------------------
- sin(th)*r
- ,
- df(w(3,2),fi) df(w(2,2),th) df(f,th)
- --------------- + --------------- + df(w(1,2),r) + ---------- +
- sin(th)*r r r
- - cos(th)*w(3,3) + cos(th)*w(2,2) + sin(th)*w(2,1) + 2*sin(th)*w(1,2)
- ------------------------------------------------------------------------
- sin(th)*r
- ,
- df(w(3,3),fi) df(w(2,3),th) df(f,fi)
- --------------- + --------------- + df(w(1,3),r) + -----------
- sin(th)*r r sin(th)*r
- cos(th)*w(3,2) + cos(th)*w(2,3) + sin(th)*w(3,1) + 2*sin(th)*w(1,3)
- + ---------------------------------------------------------------------
- sin(th)*r
- )
- a1:=u.dyad((a,0,1),(1,b,3),(0,c,d));
- a1:= ( u(2) + u(1)*a ,
- u(3)*c + u(2)*b ,
- u(3)*d + 3*u(2) + u(1) )
- a2:=vect(a,b,c);
- a2:= ( a ,
- b ,
- c )
- a1.a2;
- 2 2
- u(3)*b*c + u(3)*c*d + u(2)*a + u(2)*b + 3*u(2)*c + u(1)*a + u(1)*c
- % Scalar product
- u.v;
- u(3)*v(3) + u(2)*v(2) + u(1)*v(1)
- % Vector product
- u?v;
- ( - u(3)*v(2) + u(2)*v(3) ,
- u(3)*v(1) - u(1)*v(3) ,
- - u(2)*v(1) + u(1)*v(2) )
- % Dyadic
- u&v;
- ( ( u(1)*v(1) ,
- u(1)*v(2) ,
- u(1)*v(3) ) ,
- ( u(2)*v(1) ,
- u(2)*v(2) ,
- u(2)*v(3) ) ,
- ( u(3)*v(1) ,
- u(3)*v(2) ,
- u(3)*v(3) ) )
- % Directional derivative
- dirdf(u,v);
- df(v(1),fi)*u(3) df(v(1),th)*u(2)
- ( ------------------ + df(v(1),r)*u(1) + ------------------
- sin(th)*r r
- u(3)*v(3) + u(2)*v(2)
- - ----------------------- ,
- r
- df(v(2),fi)*u(3) df(v(2),th)*u(2)
- ------------------ + df(v(2),r)*u(1) + ------------------
- sin(th)*r r
- - cos(th)*u(3)*v(3) + sin(th)*u(2)*v(1)
- + ------------------------------------------ ,
- sin(th)*r
- df(v(3),fi)*u(3) df(v(3),th)*u(2)
- ------------------ + df(v(3),r)*u(1) + ------------------
- sin(th)*r r
- u(3)*(cos(th)*v(2) + sin(th)*v(1))
- + ------------------------------------ )
- sin(th)*r
- clear a1,a2,a3,a4,a5,u,v,w;
- for all x,y clear diff(x,y);
- clear cos th**2,
- cos fi**2;
- remfac df;
- off rat;
- scalefactors 3,x,y,z,x,y,z;
- %***********************************************************************
- %***** *****
- %***** T e s t Examples --- Module I I M E T *****
- %***** *****
- %***********************************************************************
- % Example I.1 - 1-D Lagrangian Hydrodynamics
- off exp;
- factor diff;
- on rat,eqfu;
- % Declare which indexes will be given to coordinates
- coordinates x,t into j,m;
- % Declares uniform grid in x coordinate
- grid uniform,x;
- % Declares dependencies of functions on coordinates
- dependence eta(t,x),v(t,x),eps(t,x),p(t,x);
- % Declares p as known function
- given p;
- same eta,v,p;
- iim a, eta,diff(eta,t)-eta*diff(v,x)=0,
- v,diff(v,t)+eta/ro*diff(p,x)=0,
- eps,diff(eps,t)+eta*p/ro*diff(v,x)=0;
- *****************************
- ***** Program ***** IIMET Ver 1.1.2
- *****************************
- Partial Differential Equations
- ==============================
- diff(eta,t) - diff(v,x)*eta = 0
- diff(p,x)*eta
- --------------- + diff(v,t) = 0
- ro
- diff(v,x)*eta*p
- diff(eps,t) + ----------------- = 0
- ro
- Backtracking needed in grid optimalization
- 0 interpolations are needed in x coordinate
- Equation for eta variable is integrated in half grid point
- Equation for v variable is integrated in half grid point
- Equation for eps variable is integrated in half grid point
- 0 interpolations are needed in t coordinate
- Equation for eta variable is integrated in half grid point
- Equation for v variable is integrated in half grid point
- Equation for eps variable is integrated in half grid point
- Equations after Discretization Using IIM :
- ==========================================
- (4*(eta(j,m + 1) - eta(j,m) - eta(j + 1,m) + eta(j + 1,m + 1))*hx - (
- (eta(j + 1,m + 1) + eta(j,m + 1))*(v(j + 1,m + 1) - v(j,m + 1))
- + (eta(j + 1,m) + eta(j,m))*(v(j + 1,m) - v(j,m)))*(ht(m + 1) + ht(m)))/(4
- *(ht(m + 1) + ht(m))*hx) = 0
- (4*(v(j,m + 1) - v(j,m) - v(j + 1,m) + v(j + 1,m + 1))*hx*ro + (
- (eta(j + 1,m + 1) + eta(j,m + 1))*(p(j + 1,m + 1) - p(j,m + 1))
- + (eta(j + 1,m) + eta(j,m))*(p(j + 1,m) - p(j,m)))*(ht(m + 1) + ht(m)))/(4
- *(ht(m + 1) + ht(m))*hx*ro) = 0
- (4*(eps(j,m + 1) - eps(j,m) - eps(j + 1,m) + eps(j + 1,m + 1))*hx*ro + (
- (eta(j + 1,m + 1)*p(j + 1,m + 1) + eta(j,m + 1)*p(j,m + 1))
- *(v(j + 1,m + 1) - v(j,m + 1))
- + (eta(j + 1,m)*p(j + 1,m) + eta(j,m)*p(j,m))*(v(j + 1,m) - v(j,m)))
- *(ht(m + 1) + ht(m)))/(4*(ht(m + 1) + ht(m))*hx*ro) = 0
- clear a;
- clearsame;
- cleargiven;
- %***********************************************************************
- % Example I.2 - How other functions (here sin, cos) can be used in
- % discretized terms
- diffunc sin,cos;
- difmatch all,diff(u*sin x,x),u=one,2,(u(i+1)*sin x(i+1)-u(i-1)
- *sin x(i-1))/(dim1+dip1),
- u=half,0,(u(i+1/2)*sin x(i+1/2)-u(i-1/2)*sin x(i-1/2))
- /di;
- difmatch all,cos x*diff(u,x,2),u=one,0,cos x i*(u(i+1)-2*u(i)+u(i-1))
- /di^2,
- u=half,3,(u(i+3/2)-u(i+1/2))/dip2/2 -
- (u(i-1/2)-u(i-3/2))/dim2/2;
- off exp;
- coordinates x,t into j,m;
- grid uniform,x,t;
- dependence u(x,t),v(x,t);
- iim a,u,diff(u,t)+diff(u,x)+cos x*diff(v,x,2)=0,
- v,diff(v,t)+diff(sin x*u,x)=0;
- *****************************
- ***** Program ***** IIMET Ver 1.1.2
- *****************************
- Partial Differential Equations
- ==============================
- diff(u,t) + diff(u,x) + diff(v,x,2)*cos(x) = 0
- diff(sin(x)*u,x) + diff(v,t) = 0
- 0 interpolations are needed in x coordinate
- Equation for u variable is integrated in half grid point
- Equation for v variable is integrated in half grid point
- 0 interpolations are needed in t coordinate
- Equation for u variable is integrated in half grid point
- Equation for v variable is integrated in half grid point
- Equations after Discretization Using IIM :
- ==========================================
- 2*j + 1 2*j + 1 2*j + 3
- - ((2*(v(---------,m + 1) + v(---------,m)) - v(---------,m)
- 2 2 2
- 2*j + 3 2*j - 1 2*j - 1
- - v(---------,m + 1) - v(---------,m) - v(---------,m + 1))
- 2 2 2
- 2*j + 1
- *cos(x(---------))*ht + (
- 2
- (u(j,m + 1) + u(j,m) - u(j + 1,m) - u(j + 1,m + 1))*ht
- 2
- - (u(j,m + 1) - u(j,m) - u(j + 1,m) + u(j + 1,m + 1))*hx)*hx)/(2*ht*hx )
- = 0
- ( - ((u(j,m + 1) + u(j,m))*sin(x(j))*ht
- 2*j + 1 2*j + 1
- - 2*(v(---------,m + 1) - v(---------,m))*hx)
- 2 2
- + (u(j + 1,m + 1) + u(j + 1,m))*sin(x(j + 1))*ht)/(2*ht*hx) = 0
- clear a;
- %***********************************************************************
- % Example I.3 - Schrodinger equation
- factor diff;
- coordinates t,x into m,j;
- grid uniform,x,t;
- dependence ur(x,t),ui(x,t);
- same ui,ur;
- iim a,ur,-diff(ui,t)+1/2*diff(ur,x,2)+(ur**2+ui**2)*ur=0,
- ui,diff(ur,t)+1/2*diff(ui,x,2)+(ur**2+ui**2)*ui=0;
- *****************************
- ***** Program ***** IIMET Ver 1.1.2
- *****************************
- Partial Differential Equations
- ==============================
- diff(ur,x,2) 2 2
- - diff(ui,t) + -------------- = - ur*(ui + ur )
- 2
- diff(ui,x,2) 2 2
- -------------- + diff(ur,t) = - ui*(ui + ur )
- 2
- 0 interpolations are needed in t coordinate
- Equation for ur variable is integrated in half grid point
- Equation for ui variable is integrated in half grid point
- 0 interpolations are needed in x coordinate
- Equation for ur variable is integrated in one grid point
- Equation for ui variable is integrated in one grid point
- Equations after Discretization Using IIM :
- ==========================================
- ((ur(m,j + 1) - 2*ur(m,j) + ur(m,j - 1) - 2*ur(m + 1,j) + ur(m + 1,j + 1)
- 2 2
- + ur(m + 1,j - 1))*ht - 4*(ui(m + 1,j) - ui(m,j))*hx )/(4*ht*hx ) =
- 3 3 2 2
- ur(m + 1,j) + ur(m,j) + ui(m,j) *ur(m,j) + ui(m + 1,j) *ur(m + 1,j)
- - -----------------------------------------------------------------------
- 2
- ((ui(m,j + 1) - 2*ui(m,j) + ui(m,j - 1) - 2*ui(m + 1,j) + ui(m + 1,j + 1)
- 2 2
- + ui(m + 1,j - 1))*ht + 4*(ur(m + 1,j) - ur(m,j))*hx )/(4*ht*hx ) =
- 2 2 2 2
- (ui(m + 1,j) + ur(m + 1,j) )*ui(m + 1,j) + (ui(m,j) + ur(m,j) )*ui(m,j)
- - ---------------------------------------------------------------------------
- 2
- clear a;
- clearsame;
- %***********************************************************************
- % Example I.4 - Vector calculus in p.d.e. input
- % cooperation with expres module
- % 2-D hydrodynamics
- scalefactors 2,x,y,x,y;
- vectors u;
- off exp,twogrid;
- on eqfu;
- factor diff,ht,hx,hy;
- coordinates x,y,t into j,i,m;
- grid uniform,x,y,t;
- dependence n(t,x,y),u(t,x,y),p(t,x,y);
- iim a,n,diff(n,t)+u.grad n+n*div u=0,
- u,m*n*(diff(u,t)+u.grad u)+grad p=vect(0,0),
- p,3/2*(diff(p,t)+u.grad p)+5/2*p*div u=0;
- *****************************
- ***** Program ***** IIMET Ver 1.1.2
- *****************************
- Partial Differential Equations
- ==============================
- diff(n,t) + diff(n,x)*u1 + diff(n,y)*u2 + diff(u1,x)*n + diff(u2,y)*n = 0
- diff(p,x) + diff(u1,t)*m*n + diff(u1,x)*m*n*u1 + diff(u1,y)*m*n*u2 = 0
- diff(p,y) + diff(u2,t)*m*n + diff(u2,x)*m*n*u1 + diff(u2,y)*m*n*u2 = 0
- 3*diff(p,t) 3*diff(p,x)*u1 3*diff(p,y)*u2 5*diff(u1,x)*p
- ------------- + ---------------- + ---------------- + ----------------
- 2 2 2 2
- 5*diff(u2,y)*p
- + ---------------- = 0
- 2
- 0 interpolations are needed in x coordinate
- Equation for n variable is integrated in half grid point
- Equation for u1 variable is integrated in half grid point
- Equation for u2 variable is integrated in half grid point
- Equation for p variable is integrated in half grid point
- 0 interpolations are needed in y coordinate
- Equation for n variable is integrated in half grid point
- Equation for u1 variable is integrated in half grid point
- Equation for u2 variable is integrated in half grid point
- Equation for p variable is integrated in half grid point
- 0 interpolations are needed in t coordinate
- Equation for n variable is integrated in half grid point
- Equation for u1 variable is integrated in half grid point
- Equation for u2 variable is integrated in half grid point
- Equation for p variable is integrated in half grid point
- Equations after Discretization Using IIM :
- ==========================================
- -1 -1
- (hy *hx *(n(j + 1,i + 1,m + 1)*u1(j + 1,i + 1,m + 1)*hy
- + n(j + 1,i + 1,m + 1)*u2(j + 1,i + 1,m + 1)*hx
- + n(j + 1,i + 1,m)*u1(j + 1,i + 1,m)*hy
- + n(j + 1,i + 1,m)*u2(j + 1,i + 1,m)*hx
- + n(j + 1,i,m + 1)*u1(j + 1,i,m + 1)*hy
- - n(j + 1,i,m + 1)*u2(j + 1,i,m + 1)*hx
- + n(j + 1,i,m)*u1(j + 1,i,m)*hy - n(j + 1,i,m)*u2(j + 1,i,m)*hx
- - n(j,i + 1,m + 1)*u1(j,i + 1,m + 1)*hy
- + n(j,i + 1,m + 1)*u2(j,i + 1,m + 1)*hx
- - n(j,i + 1,m)*u1(j,i + 1,m)*hy + n(j,i + 1,m)*u2(j,i + 1,m)*hx
- - n(j,i,m + 1)*u1(j,i,m + 1)*hy - n(j,i,m + 1)*u2(j,i,m + 1)*hx
- -1
- - n(j,i,m)*u1(j,i,m)*hy - n(j,i,m)*u2(j,i,m)*hx))/4 + (ht *(
- n(j,i,m + 1) - n(j,i,m) - n(j,i + 1,m) + n(j,i + 1,m + 1) - n(j + 1,i,m)
- + n(j + 1,i,m + 1) - n(j + 1,i + 1,m) + n(j + 1,i + 1,m + 1)))/4 = 0
- -1
- (hx *((n(j + 1,i,m + 1)*u1(j + 1,i,m + 1) + n(j,i,m + 1)*u1(j,i,m + 1))
- *(u1(j + 1,i,m + 1) - u1(j,i,m + 1)) +
- (n(j + 1,i,m)*u1(j + 1,i,m) + n(j,i,m)*u1(j,i,m))
- *(u1(j + 1,i,m) - u1(j,i,m)) +
- (n(j + 1,i + 1,m)*u1(j + 1,i + 1,m) + n(j,i + 1,m)*u1(j,i + 1,m))
- *(u1(j + 1,i + 1,m) - u1(j,i + 1,m)) + (
- n(j + 1,i + 1,m + 1)*u1(j + 1,i + 1,m + 1)
- + n(j,i + 1,m + 1)*u1(j,i + 1,m + 1))
- -1 -1 -1
- *(u1(j + 1,i + 1,m + 1) - u1(j,i + 1,m + 1)))*m)/8 + (hy *hx *ht *(((
- (n(j,i + 1,m + 1) + n(j,i + 1,m))
- *(u1(j,i + 1,m + 1) - u1(j,i + 1,m))
- + (n(j,i,m + 1) + n(j,i,m))*(u1(j,i,m + 1) - u1(j,i,m)) +
- (n(j + 1,i,m + 1) + n(j + 1,i,m))
- *(u1(j + 1,i,m + 1) - u1(j + 1,i,m)) +
- (n(j + 1,i + 1,m + 1) + n(j + 1,i + 1,m))
- *(u1(j + 1,i + 1,m + 1) - u1(j + 1,i + 1,m)))*hx*m + 2*(
- p(j + 1,i,m + 1) + p(j + 1,i,m) + p(j + 1,i + 1,m)
- + p(j + 1,i + 1,m + 1)
- - (p(j,i,m + 1) + p(j,i,m) + p(j,i + 1,m) + p(j,i + 1,m + 1)))*ht)
- *hy + ((n(j,i + 1,m + 1)*u2(j,i + 1,m + 1) + n(j,i,m + 1)*u2(j,i,m + 1))
- *(u1(j,i + 1,m + 1) - u1(j,i,m + 1)) +
- (n(j,i + 1,m)*u2(j,i + 1,m) + n(j,i,m)*u2(j,i,m))
- *(u1(j,i + 1,m) - u1(j,i,m)) +
- (n(j + 1,i + 1,m)*u2(j + 1,i + 1,m) + n(j + 1,i,m)*u2(j + 1,i,m))
- *(u1(j + 1,i + 1,m) - u1(j + 1,i,m)) + (
- n(j + 1,i + 1,m + 1)*u2(j + 1,i + 1,m + 1)
- + n(j + 1,i,m + 1)*u2(j + 1,i,m + 1))
- *(u1(j + 1,i + 1,m + 1) - u1(j + 1,i,m + 1)))*ht*hx*m))/8 = 0
- -1 -1
- (hy *hx *(((n(j + 1,i,m + 1)*u1(j + 1,i,m + 1) + n(j,i,m + 1)*u1(j,i,m + 1))
- *(u2(j + 1,i,m + 1) - u2(j,i,m + 1)) +
- (n(j + 1,i,m)*u1(j + 1,i,m) + n(j,i,m)*u1(j,i,m))
- *(u2(j + 1,i,m) - u2(j,i,m)) +
- (n(j + 1,i + 1,m)*u1(j + 1,i + 1,m) + n(j,i + 1,m)*u1(j,i + 1,m))
- *(u2(j + 1,i + 1,m) - u2(j,i + 1,m)) + (
- n(j + 1,i + 1,m + 1)*u1(j + 1,i + 1,m + 1)
- + n(j,i + 1,m + 1)*u1(j,i + 1,m + 1))
- *(u2(j + 1,i + 1,m + 1) - u2(j,i + 1,m + 1)))*hy + (
- (n(j,i + 1,m + 1)*u2(j,i + 1,m + 1) + n(j,i,m + 1)*u2(j,i,m + 1))
- *(u2(j,i + 1,m + 1) - u2(j,i,m + 1)) +
- (n(j,i + 1,m)*u2(j,i + 1,m) + n(j,i,m)*u2(j,i,m))
- *(u2(j,i + 1,m) - u2(j,i,m)) +
- (n(j + 1,i + 1,m)*u2(j + 1,i + 1,m) + n(j + 1,i,m)*u2(j + 1,i,m))
- *(u2(j + 1,i + 1,m) - u2(j + 1,i,m)) + (
- n(j + 1,i + 1,m + 1)*u2(j + 1,i + 1,m + 1)
- + n(j + 1,i,m + 1)*u2(j + 1,i,m + 1))
- -1
- *(u2(j + 1,i + 1,m + 1) - u2(j + 1,i,m + 1)))*hx)*m)/8 + ( - hy
- -1
- *ht *(2*(p(j,i,m + 1) + p(j,i,m) - p(j,i + 1,m) - p(j,i + 1,m + 1)
- + p(j + 1,i,m) + p(j + 1,i,m + 1) - p(j + 1,i + 1,m)
- - p(j + 1,i + 1,m + 1))*ht - ((n(j,i + 1,m + 1) + n(j,i + 1,m))
- *(u2(j,i + 1,m + 1) - u2(j,i + 1,m))
- + (n(j,i,m + 1) + n(j,i,m))*(u2(j,i,m + 1) - u2(j,i,m)) +
- (n(j + 1,i,m + 1) + n(j + 1,i,m))
- *(u2(j + 1,i,m + 1) - u2(j + 1,i,m)) +
- (n(j + 1,i + 1,m + 1) + n(j + 1,i + 1,m))
- *(u2(j + 1,i + 1,m + 1) - u2(j + 1,i + 1,m)))*hy*m))/8 = 0
- -1 -1
- (hy *hx *(3*((p(j + 1,i,m + 1) - p(j,i,m + 1))
- *(u1(j + 1,i,m + 1) + u1(j,i,m + 1))
- + (p(j + 1,i,m) - p(j,i,m))*(u1(j + 1,i,m) + u1(j,i,m)) +
- (p(j + 1,i + 1,m) - p(j,i + 1,m))
- *(u1(j + 1,i + 1,m) + u1(j,i + 1,m)) +
- (p(j + 1,i + 1,m + 1) - p(j,i + 1,m + 1))
- *(u1(j + 1,i + 1,m + 1) + u1(j,i + 1,m + 1)))*hy + 2*(
- 4*p(j + 1,i + 1,m + 1)*u2(j + 1,i + 1,m + 1)
- - p(j + 1,i + 1,m + 1)*u2(j + 1,i,m + 1)
- + 4*p(j + 1,i + 1,m)*u2(j + 1,i + 1,m)
- - p(j + 1,i + 1,m)*u2(j + 1,i,m)
- + p(j + 1,i,m + 1)*u2(j + 1,i + 1,m + 1)
- - 4*p(j + 1,i,m + 1)*u2(j + 1,i,m + 1)
- + p(j + 1,i,m)*u2(j + 1,i + 1,m) - 4*p(j + 1,i,m)*u2(j + 1,i,m)
- + 4*p(j,i + 1,m + 1)*u2(j,i + 1,m + 1)
- - p(j,i + 1,m + 1)*u2(j,i,m + 1) + 4*p(j,i + 1,m)*u2(j,i + 1,m)
- - p(j,i + 1,m)*u2(j,i,m) + p(j,i,m + 1)*u2(j,i + 1,m + 1)
- - 4*p(j,i,m + 1)*u2(j,i,m + 1) + p(j,i,m)*u2(j,i + 1,m)
- - 4*p(j,i,m)*u2(j,i,m))*hx + 5*(
- (p(j + 1,i,m + 1) + p(j,i,m + 1))
- *(u1(j + 1,i,m + 1) - u1(j,i,m + 1))
- + (p(j + 1,i,m) + p(j,i,m))*(u1(j + 1,i,m) - u1(j,i,m)) +
- (p(j + 1,i + 1,m) + p(j,i + 1,m))
- *(u1(j + 1,i + 1,m) - u1(j,i + 1,m)) +
- (p(j + 1,i + 1,m + 1) + p(j,i + 1,m + 1))
- -1
- *(u1(j + 1,i + 1,m + 1) - u1(j,i + 1,m + 1)))*hy))/16 + (3*ht *(
- p(j,i,m + 1) - p(j,i,m) - p(j,i + 1,m) + p(j,i + 1,m + 1) - p(j + 1,i,m)
- + p(j + 1,i,m + 1) - p(j + 1,i + 1,m) + p(j + 1,i + 1,m + 1)))/8 = 0
- clear a,u;
- %***********************************************************************
- % Example I.5 - 1-D hydrodynamics up to 3-rd moments (heat flow)
- coordinates x,t into j,m;
- grid uniform,x,t;
- dependence n(x,t),u(x,t),tt(x,t),p(x,t),q(x,t);
- iim a, n,diff(n,t)+u*diff(n,x)+diff(u,x)=0,
- u,n*m*(diff(u,t)+u*diff(u,x))+k*diff(n*tt,x)+diff(p,x)=0,
- tt,3/2*k*n*(diff(tt,t)+u*diff(tt,x))+n*k*tt*diff(u,x)+1/2*p
- *diff(u,x)+diff(q,x)=0,
- p,diff(p,t)+u*diff(p,x)+p*diff(u,x)+n*k*tt*diff(u,x)+2/5*diff(q,x)
- =0,
- q,diff(q,t)+u*diff(q,x)+q*diff(u,x)+5/2*n*k**2*tt/m*diff(tt,x)+n*k
- *tt*diff(p,x)-p*diff(p,x)=0;
- *****************************
- ***** Program ***** IIMET Ver 1.1.2
- *****************************
- Partial Differential Equations
- ==============================
- diff(n,t) + diff(n,x)*u + diff(u,x) = 0
- diff(n*tt,x)*k + diff(p,x) + diff(u,t)*m*n + diff(u,x)*m*n*u = 0
- 3*diff(tt,t)*k*n 3*diff(tt,x)*k*n*u
- diff(q,x) + ------------------ + --------------------
- 2 2
- diff(u,x)*(2*k*n*tt + p)
- + -------------------------- = 0
- 2
- 2*diff(q,x)
- diff(p,t) + diff(p,x)*u + ------------- + diff(u,x)*(k*n*tt + p) = 0
- 5
- 2
- 5*diff(tt,x)*k *n*tt
- diff(p,x)*(k*n*tt - p) + diff(q,t) + diff(q,x)*u + ----------------------
- 2*m
- + diff(u,x)*q = 0
- 0 interpolations are needed in x coordinate
- Equation for n variable is integrated in half grid point
- Equation for u variable is integrated in half grid point
- Equation for tt variable is integrated in half grid point
- Equation for p variable is integrated in half grid point
- Equation for q variable is integrated in half grid point
- 0 interpolations are needed in t coordinate
- Equation for n variable is integrated in half grid point
- Equation for u variable is integrated in half grid point
- Equation for tt variable is integrated in half grid point
- Equation for p variable is integrated in half grid point
- Equation for q variable is integrated in half grid point
- Equations after Discretization Using IIM :
- ==========================================
- -1
- (hx *((n(j + 1,m + 1) - n(j,m + 1))*(u(j + 1,m + 1) + u(j,m + 1))
- + (n(j + 1,m) - n(j,m))*(u(j + 1,m) + u(j,m))
- + 2*(u(j + 1,m + 1) + u(j + 1,m) - (u(j,m + 1) + u(j,m)))))/4
- -1
- ht *(n(j,m + 1) - n(j,m) - n(j + 1,m) + n(j + 1,m + 1))
- + ---------------------------------------------------------- = 0
- 2
- -1
- ( - hx *(n(j,m + 1)*tt(j,m + 1) + n(j,m)*tt(j,m) - n(j + 1,m)*tt(j + 1,m)
- -1 -1
- - n(j + 1,m + 1)*tt(j + 1,m + 1))*k)/2 + (hx *ht *((
- (n(j + 1,m + 1) + n(j + 1,m))*(u(j + 1,m + 1) - u(j + 1,m))
- + (n(j,m + 1) + n(j,m))*(u(j,m + 1) - u(j,m)))*hx*m
- + 2*(p(j + 1,m + 1) + p(j + 1,m) - (p(j,m + 1) + p(j,m)))*ht + (
- (n(j + 1,m + 1)*u(j + 1,m + 1) + n(j,m + 1)*u(j,m + 1))
- *(u(j + 1,m + 1) - u(j,m + 1))
- + (n(j + 1,m)*u(j + 1,m) + n(j,m)*u(j,m))*(u(j + 1,m) - u(j,m)))*ht*m)
- )/4 = 0
- -1
- (hx *((n(j + 1,m + 1)*tt(j + 1,m + 1) + n(j,m + 1)*tt(j,m + 1))
- *(u(j + 1,m + 1) - u(j,m + 1))
- + (n(j + 1,m)*tt(j + 1,m) + n(j,m)*tt(j,m))*(u(j + 1,m) - u(j,m)))*k)/4
- -1 -1
- + (hx *ht *(((p(j + 1,m + 1) + p(j,m + 1))*(u(j + 1,m + 1) - u(j,m + 1))
- + (p(j + 1,m) + p(j,m))*(u(j + 1,m) - u(j,m))
- + 4*(q(j + 1,m + 1) + q(j + 1,m) - (q(j,m + 1) + q(j,m))))*ht +
- 3*((n(j + 1,m + 1) + n(j + 1,m))*(tt(j + 1,m + 1) - tt(j + 1,m))
- + (n(j,m + 1) + n(j,m))*(tt(j,m + 1) - tt(j,m)))*hx*k + 3*(
- (n(j + 1,m + 1)*u(j + 1,m + 1) + n(j,m + 1)*u(j,m + 1))
- *(tt(j + 1,m + 1) - tt(j,m + 1)) +
- (n(j + 1,m)*u(j + 1,m) + n(j,m)*u(j,m))*(tt(j + 1,m) - tt(j,m))
- )*ht*k))/8 = 0
- -1
- (hx *(5*((n(j + 1,m + 1)*tt(j + 1,m + 1) + n(j,m + 1)*tt(j,m + 1))
- *(u(j + 1,m + 1) - u(j,m + 1))
- + (n(j + 1,m)*tt(j + 1,m) + n(j,m)*tt(j,m))*(u(j + 1,m) - u(j,m)))*k
- + 2*(5*p(j + 1,m + 1)*u(j + 1,m + 1) + 5*p(j + 1,m)*u(j + 1,m)
- - 5*p(j,m + 1)*u(j,m + 1) - 5*p(j,m)*u(j,m) + 2*q(j + 1,m + 1)
- + 2*q(j + 1,m) - 2*q(j,m + 1) - 2*q(j,m))))/20
- -1
- ht *(p(j,m + 1) - p(j,m) - p(j + 1,m) + p(j + 1,m + 1))
- + ---------------------------------------------------------- = 0
- 2
- -1
- ( - hx *(2*((p(j + 1,m + 1) + p(j,m + 1))*(p(j + 1,m + 1) - p(j,m + 1))
- + (p(j + 1,m) + p(j,m))*(p(j + 1,m) - p(j,m)) - 2*(
- q(j + 1,m + 1)*u(j + 1,m + 1) + q(j + 1,m)*u(j + 1,m)
- - q(j,m + 1)*u(j,m + 1) - q(j,m)*u(j,m)))*m - 5*(
- (n(j + 1,m + 1)*tt(j + 1,m + 1) + n(j,m + 1)*tt(j,m + 1))
- *(tt(j + 1,m + 1) - tt(j,m + 1)) +
- (n(j + 1,m)*tt(j + 1,m) + n(j,m)*tt(j,m))*(tt(j + 1,m) - tt(j,m)))
- 2
- *k - 2*((n(j + 1,m + 1)*tt(j + 1,m + 1) + n(j,m + 1)*tt(j,m + 1))
- *(p(j + 1,m + 1) - p(j,m + 1))
- + (n(j + 1,m)*tt(j + 1,m) + n(j,m)*tt(j,m))*(p(j + 1,m) - p(j,m)))
- *k*m))/(8*m)
- -1
- ht *(q(j,m + 1) - q(j,m) - q(j + 1,m) + q(j + 1,m + 1))
- + ---------------------------------------------------------- = 0
- 2
- clear a;
- remfac diff,ht,hx,hy;
- on exp;
- off rat;
- %***********************************************************************
- %***** *****
- %***** T e s t Examples --- Module A P P R O X *****
- %***** *****
- %***********************************************************************
- % Example A.1
- coordinates x,t into j,n;
- maxorder t=2,x=3;
- functions u,v;
- approx( (u(n+1/2)-u(n-1/2))/ht=(v(n+1/2,j+1/2)-v(n+1/2,j-1/2)
- +v(n-1/2,j+1/2)-v(n-1/2,j-1/2))/(2*hx) );
- Difference scheme approximates differential equation df(u,t)=df(v,x)
- with orders of approximation:
- 2
- hx
- 2
- ht
- % Example A.2
- maxorder t=3,x=3;
- approx( (u(n+1)-u(n))/ht=(u(n+1,j+1/2)-u(n+1,j-1/2)
- +u(n,j+1/2)-u(n,j-1/2))/(2*hx) );
- Difference scheme approximates differential equation df(u,t)=df(u,x)
- with orders of approximation:
- 2
- hx
- ht
- % Example A.3
- maxorder t=2,x=3;
- center t=1/2;
- approx( (u(n+1)-u(n))/ht=(v(n+1,j+1/2)-v(n+1,j-1/2)
- +v(n,j+1/2)-v(n,j-1/2))/(2*hx) );
- Difference scheme approximates differential equation df(u,t)=df(v,x)
- with orders of approximation:
- 2
- hx
- 2
- ht
- % Example A.4
- approx( u(n+1)/ht=(v(n+1,j+1/2)-v(n+1,j-1/2)
- +v(n,j+1/2)-v(n,j-1/2))/(2*hx) );
- Reformulate difference scheme, grid steps remain in denominators
- Difference scheme approximates differential equation 0=df(v,x)
- with orders of approximation:
- 2
- hx
- -1
- ht
- % Example A.5
- maxorder t=3,x=3;
- approx( (u(n+1)-u(n))/ht=(u(n+1,j+1/2)-u(n+1,j-1/2))/hx);
- Difference scheme approximates differential equation df(u,t)=df(u,x)
- with orders of approximation:
- 2
- hx
- ht
- % Example A.6
- approx( (u(n+1)-u(n))/ht=(u(n+1/2,j+1/2)-u(n+1/2,j-1/2))/hx);
- Difference scheme approximates differential equation df(u,t)=df(u,x)
- with orders of approximation:
- 2
- hx
- 2
- ht
- % Example A.7;
- maxorder x=4;
- approx((u(n+1)-u(n))/ht=(u(n+1/2,j+1)-2*u(n+1/2,j)+u(n+1/2,j-1))/hx**2);
- Difference scheme approximates differential equation df(u,t)=df(u,x,2)
- with orders of approximation:
- 2
- hx
- 2
- ht
- %***********************************************************************
- %***** *****
- %***** T e s t Examples --- Module C H A R P O L *****
- %***** *****
- %***********************************************************************
- % Example C.1
- coordinates t,x into i,j;
- grid uniform,t,x;
- let cos ax**2=1-sin ax**2;
- unfunc u,v;
- matrix aa(1,2),bb(2,2);
- aa(1,1):=(u(i+1)-u(i))/ht+(v(j+1)-v(j))/hx$
- aa(1,2):=(v(i+1)-v(i))/ht+(u(j+1/2)-u(j-1/2))/hx$
- bb:=ampmat aa;
- kx*hx
- ax := -------
- 2
- [hx 0 ]
- h1 := [ ]
- [0 hx]
- [ hx 2*sin(ax)*ht*( - i*cos(ax) + sin(ax))]
- h0 := [ ]
- [ - 2*i*sin(ax)*ht hx ]
- [ 2*sin(ax)*ht*( - i*cos(ax) + sin(ax)) ]
- [ 1 ---------------------------------------]
- [ hx ]
- bb := [ ]
- [ - 2*i*sin(ax)*ht ]
- [------------------- 1 ]
- [ hx ]
- bb:=denotemat bb;
- [ 1 ai12*i + ar12]
- bb := [ ]
- [ai21*i 1 ]
- factor lam;
- pol:=charpol bb;
- 2
- pol := lam - 2*lam + ai12*ai21 - i*ai21*ar12 + 1
- prdenot;
- 2
- 2*sin(ax) *ht
- ar12 := ---------------
- hx
- - 2*cos(ax)*sin(ax)*ht
- ai12 := -------------------------
- hx
- - 2*sin(ax)*ht
- ai21 := -----------------
- hx
- cleardenot;
- clear aa,bb,pol;
- %***********************************************************************
- % Example C.2 : Reprint Vorozcov, Ganza, Mazurik: Simvolno-cislennyj
- % interfejs. v zadacach ..., Novosibirsk 1986, p.47.
- unfunc u;
- matrix aa(1,1),bb(1,1);
- aa(1,1):=(u(i+1)-u(i))/ht+a*(u(j)-u(j-1))/hx$
- bb:=ampmat aa;
- ax := kx*hx
- h1 := [hx]
- h0 := [cos(ax)*a*ht - i*sin(ax)*a*ht - a*ht + hx]
- [ cos(ax)*a*ht - i*sin(ax)*a*ht - a*ht + hx ]
- bb := [-------------------------------------------]
- [ hx ]
- bb:=denotemat bb;
- bb := [ai11*i + ar11]
- pol:=charpol bb;
- pol := lam - i*ai11 - ar11
- prdenot;
- cos(ax)*a*ht - a*ht + hx
- ar11 := --------------------------
- hx
- - sin(ax)*a*ht
- ai11 := -----------------
- hx
- cleardenot;
- clear aa,bb,pol;
- %***********************************************************************
- % Example C.3 : Reprint Vorozcov, Ganza, Mazurik: Simvolno-cislennyj
- % interfejs. v zadacach ..., Novosibirsk 1986, p.52.
- coordinates t,x into m,j;
- unfunc u,r;
- matrix aa(1,2),bb(2,2);
- aa(1,1):=(r(m+1)-r(m))/ht+u0*(r(m+1,j+1)-r(m+1,j-1))/2/hx
- +r0*(u(m+1,j+1)-u(m+1,j-1))/2/hx$
- aa(1,2):=(u(m+1)-u(m))/ht+u0*(u(m+1,j+1)-u(m+1,j-1))/2/hx
- +c0**2/r0*(r(m,j+1)-u(m,j-1))/2/hx$
- bb:=ampmat aa;
- ax := kx*hx
- [ i*sin(ax)*ht*r0 i*sin(ax)*ht*u0 + hx]
- h1 := [ ]
- [2*r0*(i*sin(ax)*ht*u0 + hx) 0 ]
- h0 := mat((0,hx),
- 2 2
- (cos(ax)*c0 *ht - i*sin(ax)*c0 *ht + 2*hx*r0,
- 2
- c0 *ht*( - cos(ax) - i*sin(ax))))
- 2 2
- - i*cos(ax)*c0 *ht - sin(ax)*c0 *ht - 2*i*hx*r0
- bb := mat((--------------------------------------------------,
- 2*r0*(sin(ax)*ht*u0 - i*hx)
- 2
- c0 *ht*(i*cos(ax) - sin(ax))
- ------------------------------),
- 2*r0*(sin(ax)*ht*u0 - i*hx)
- 2 2
- sin(ax)*ht*(i*cos(ax)*c0 *ht + sin(ax)*c0 *ht + 2*i*hx*r0)
- (------------------------------------------------------------,(
- 2 2 2 2
- 2*(sin(ax) *ht *u0 - 2*i*sin(ax)*ht*hx*u0 - hx )
- 2 2 2 2 2
- - i*cos(ax)*sin(ax)*c0 *ht + sin(ax) *c0 *ht
- 2
- - 2*i*sin(ax)*ht*hx*u0 - 2*hx )/(2
- 2 2 2 2
- *(sin(ax) *ht *u0 - 2*i*sin(ax)*ht*hx*u0 - hx ))))
- bb:=denotemat bb;
- [ai11*i + ar11 ai12*i + ar12]
- bb := [ ]
- [ai21*i + ar21 ai22*i + ar22]
- pol:=charpol bb;
- 2
- pol := lam + lam*( - i*ai11 - i*ai22 - ar11 - ar22) - ai11*ai22 + i*ai11*ar22
- + ai12*ai21 - i*ai12*ar21 - i*ai21*ar12 + i*ai22*ar11 + ar11*ar22
- - ar12*ar21
- prdenot;
- 2
- - c0
- ar11 := ---------
- 2*r0*u0
- 2 2
- - cos(ax)*c0 *ht*u0 - c0 *hx - 2*hx*r0*u0
- ai11 := --------------------------------------------
- 2*r0*u0*(sin(ax)*ht*u0 - hx*i)
- 2
- - c0
- ar12 := ---------
- 2*r0*u0
- 2
- c0 *(cos(ax)*ht*u0 - hx)
- ai12 := --------------------------------
- 2*r0*u0*(sin(ax)*ht*u0 - hx*i)
- 2 2 2
- sin(ax) *c0 *ht
- ar21 := ----------------------------
- 2 2 2 2
- 2*(sin(ax) *ht *u0 - hx )
- 2 2 3 2 2 2
- ai21 := (sin(ax)*ht*(cos(ax)*sin(ax) *c0 *ht *u0 - cos(ax)*c0 *ht*hx
- 2 2 2 2 2 2 3
- + 2*sin(ax) *c0 *ht *hx*u0 + 2*sin(ax) *ht *hx*r0*u0 - 2*hx *r0))/
- 4 4 4 3 3 3 2 2 2 2
- (2*(sin(ax) *ht *u0 - 2*sin(ax) *ht *hx*i*u0 - 2*sin(ax) *ht *hx *u0
- 3 4
- + 2*sin(ax)*ht*hx *i*u0 + hx ))
- 2 2 2 2
- sin(ax) *c0 *ht - 2*hx
- ar22 := ----------------------------
- 2 2 2 2
- 2*(sin(ax) *ht *u0 - hx )
- 2 2 3 2 2 2
- ai22 := (sin(ax)*ht*( - cos(ax)*sin(ax) *c0 *ht *u0 + cos(ax)*c0 *ht*hx
- 2 2 2 2 2 3 3
- + 2*sin(ax) *c0 *ht *hx*u0 - 2*sin(ax) *ht *hx*u0 - 2*hx *u0))/(2*
- 4 4 4 3 3 3 2 2 2 2
- (sin(ax) *ht *u0 - 2*sin(ax) *ht *hx*i*u0 - 2*sin(ax) *ht *hx *u0
- 3 4
- + 2*sin(ax)*ht*hx *i*u0 + hx ))
- cleardenot;
- clear aa,bb,pol;
- %***********************************************************************
- % Example C.4 : Richtmyer, Morton: Difference methods for initial value
- % problems, &10.3. p.262
- coordinates t,x into n,j;
- unfunc v,w;
- matrix aa(1,2),bb(2,2);
- aa(1,1):=(v(n+1)-v(n))/ht-c*(w(j+1/2)-w(j-1/2)+
- w(n+1,j+1/2)-w(n+1,j-1/2))/(2*hx)$
- aa(1,2):=(w(n+1,j-1/2)-w(n,j-1/2))/ht-c*(v(n+1,j)-v(n+1,j-1)+
- v(j)-v(j-1))/(2*hx)$
- bb:=ampmat aa;
- kx*hx
- ax := -------
- 2
- [ hx - i*sin(ax)*c*ht ]
- h1 := [ ]
- [sin(ax)*c*ht*( - i*cos(ax) - sin(ax)) hx*(cos(ax) - i*sin(ax))]
- [ hx i*sin(ax)*c*ht ]
- h0 := [ ]
- [sin(ax)*c*ht*(i*cos(ax) + sin(ax)) hx*(cos(ax) - i*sin(ax))]
- [ 2 2 2 2 ]
- [ - sin(ax) *c *ht + hx 2*i*sin(ax)*c*ht*hx ]
- [-------------------------- ----------------------- ]
- [ 2 2 2 2 2 2 2 2 ]
- [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
- bb := [ ]
- [ 2 2 2 2 ]
- [ 2*i*sin(ax)*c*ht*hx - sin(ax) *c *ht + hx ]
- [ ----------------------- --------------------------]
- [ 2 2 2 2 2 2 2 2 ]
- [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
- bb:=denotemat bb;
- [ ar11 ai12*i]
- bb := [ ]
- [ai21*i ar22 ]
- pol:=charpol bb;
- 2
- pol := lam - lam*(ar11 + ar22) + ai12*ai21 + ar11*ar22
- prdenot;
- 2 2 2 2
- - sin(ax) *c *ht + hx
- ar11 := --------------------------
- 2 2 2 2
- sin(ax) *c *ht + hx
- 2*sin(ax)*c*ht*hx
- ai12 := -----------------------
- 2 2 2 2
- sin(ax) *c *ht + hx
- 2*sin(ax)*c*ht*hx
- ai21 := -----------------------
- 2 2 2 2
- sin(ax) *c *ht + hx
- 2 2 2 2
- - sin(ax) *c *ht + hx
- ar22 := --------------------------
- 2 2 2 2
- sin(ax) *c *ht + hx
- cleardenot;
- clear aa,bb,pol;
- %***********************************************************************
- % Example C.5: Mazurik: Algoritmy resenia zadaci..., Preprint no.24-85,
- % AN USSR SO, Inst. teor. i prikl. mechaniky, p.34
- coordinates t,x,y into n,m,k;
- grid uniform,t,x,y;
- unfunc u1,u2,u3;
- matrix aa(1,3),bb(3,3);
- aa(1,1):=(u1(n+1)-u1(n))/ht+c/2*((-u1(m-1)+2*u1(m)-u1(m+1))/hx +
- (u2(m+1)-u2(m-1))/hx - (u1(k-1)-2*u1(k)+u1(k+1))/hy +
- (u3(k+1)-u3(k-1))/hy)$
- aa(1,2):=(u2(n+1)-u2(n))/ht+c/2*((u1(m+1)-u1(m-1))/hx -
- (u2(m-1)-2*u2(m)+u2(m+1))/hx)$
- aa(1,3):=(u3(n+1)-u3(n))/ht + c/2*((u1(k+1)-u1(k-1))/hy -
- (u3(k-1)-2*u3(k)+u3(k+1))/hy)$
- off prfourmat;
- bb:=ampmat aa;
- ax := kx*hx
- ay := ky*hy
- cos(ax)*c*ht*hy + cos(ay)*c*ht*hx - c*ht*hx - c*ht*hy + hx*hy
- bb := mat((---------------------------------------------------------------,
- hx*hy
- - i*sin(ax)*c*ht - i*sin(ay)*c*ht
- -------------------,-------------------),
- hx hy
- - i*sin(ax)*c*ht cos(ax)*c*ht - c*ht + hx
- (-------------------,--------------------------,0),
- hx hx
- - i*sin(ay)*c*ht cos(ay)*c*ht - c*ht + hy
- (-------------------,0,--------------------------))
- hy hy
- pol:=charpol bb;
- 3 2 2 2
- pol := (lam *hx *hy + lam *hx*hy*( - 2*cos(ax)*c*ht*hy - 2*cos(ay)*c*ht*hx
- + 2*c*ht*hx + 2*c*ht*hy - 3*hx*hy) + lam*(
- 2 2 2 2
- 3*cos(ax)*cos(ay)*c *ht *hx*hy - 3*cos(ax)*c *ht *hx*hy
- 2 2 2 2 2 2 2 2
- - 2*cos(ax)*c *ht *hy + 4*cos(ax)*c*ht*hx*hy + cos(ay) *c *ht *hx
- 2 2 2 2 2
- - 2*cos(ay)*c *ht *hx - 3*cos(ay)*c *ht *hx*hy
- 2 2 2 2 2 2 2 2
- + 4*cos(ay)*c*ht*hx *hy + sin(ay) *c *ht *hx + c *ht *hx
- 2 2 2 2 2 2 2
- + 3*c *ht *hx*hy + 2*c *ht *hy - 4*c*ht*hx *hy - 4*c*ht*hx*hy
- 2 2 2 3 3
- + 3*hx *hy ) - cos(ax)*cos(ay) *c *ht *hx
- 3 3 3 3
- + 2*cos(ax)*cos(ay)*c *ht *hx + 2*cos(ax)*cos(ay)*c *ht *hy
- 2 2 2 3 3
- - 3*cos(ax)*cos(ay)*c *ht *hx*hy - cos(ax)*sin(ay) *c *ht *hx
- 3 3 3 3 2 2
- - cos(ax)*c *ht *hx - 2*cos(ax)*c *ht *hy + 3*cos(ax)*c *ht *hx*hy
- 2 2 2 2 2 3 3
- + 2*cos(ax)*c *ht *hy - 2*cos(ax)*c*ht*hx*hy + cos(ay) *c *ht *hx
- 2 2 2 2 3 3 3 3
- - cos(ay) *c *ht *hx - 2*cos(ay)*c *ht *hx - 2*cos(ay)*c *ht *hy
- 2 2 2 2 2 2
- + 2*cos(ay)*c *ht *hx + 3*cos(ay)*c *ht *hx*hy - 2*cos(ay)*c*ht*hx *hy
- 2 3 3 2 2 2 2 3 3 3 3
- + sin(ay) *c *ht *hx - sin(ay) *c *ht *hx + c *ht *hx + 2*c *ht *hy
- 2 2 2 2 2 2 2 2 2
- - c *ht *hx - 3*c *ht *hx*hy - 2*c *ht *hy + 2*c*ht*hx *hy
- 2 2 2 2 2
- + 2*c*ht*hx*hy - hx *hy )/(hx *hy )
- let
- cos ax=cos ax2**2-sin ax2**2,
- cos ay=cos ay2**2-sin ay2**2,
- sin ax=2*sin ax2*cos ax2,
- sin ay=2*sin ay2*cos ay2,
- cos ax2**2=1-sin ax2**2,
- cos ay2**2=1-sin ay2**2,
- sin ax2=s1,
- sin ay2=s2,
- hx=c*ht/cap1,
- hy=c*ht/cap2;
- order s1,s2;
- pol:=pol;
- 3 2 2 2 2 2
- pol := lam + lam *(4*s1 *cap1 + 4*s2 *cap2 - 3) + lam*(12*s1 *s2 *cap1*cap2
- 2 2 2 2 2 2
- + 4*s1 *cap1 - 8*s1 *cap1 + 4*s2 *cap2 - 8*s2 *cap2 + 3)
- 2 2 2 2 2 2 2 2
- + 8*s1 *s2 *cap1 *cap2 + 8*s1 *s2 *cap1*cap2 - 12*s1 *s2 *cap1*cap2
- 2 2 2 2 2 2
- - 4*s1 *cap1 + 4*s1 *cap1 - 4*s2 *cap2 + 4*s2 *cap2 - 1
- clear cos ax,cos ay,sin ax,sin ay,cos ax2**2,cos ay2**2,sin ax2,sin ay2,
- hx,hy;
- pol:=complexpol pol;
- 2 2
- If 8*s1 *s2 *cap1*cap2*(cap1 + cap2) = 0 and 0
- = 0 , a root of the polynomial is equal to 1.
- 3 2 2 2 2 2
- pol := lam + lam *(4*s1 *cap1 + 4*s2 *cap2 - 3) + lam*(12*s1 *s2 *cap1*cap2
- 2 2 2 2 2 2
- + 4*s1 *cap1 - 8*s1 *cap1 + 4*s2 *cap2 - 8*s2 *cap2 + 3)
- 2 2 2 2 2 2 2 2
- + 8*s1 *s2 *cap1 *cap2 + 8*s1 *s2 *cap1*cap2 - 12*s1 *s2 *cap1*cap2
- 2 2 2 2 2 2
- - 4*s1 *cap1 + 4*s1 *cap1 - 4*s2 *cap2 + 4*s2 *cap2 - 1
- pol1:=hurw pol;
- 3 2 2 2 2 2 2
- pol1 := 8*lam *s1 *s2 *cap1*cap2*(cap1 + cap2) + 8*lam *( - 3*s1 *s2 *cap1 *cap2
- 2 2 2 2 2 2 2 2 2
- - 3*s1 *s2 *cap1*cap2 + 3*s1 *s2 *cap1*cap2 + s1 *cap1 + s2 *cap2
- 2 2 2 2 2 2
- ) + 8*lam*(3*s1 *s2 *cap1 *cap2 + 3*s1 *s2 *cap1*cap2
- 2 2 2 2 2 2 2
- - 6*s1 *s2 *cap1*cap2 - 2*s1 *cap1 + 2*s1 *cap1 - 2*s2 *cap2
- 2 2 2 2 2 2 2
- + 2*s2 *cap2) + 8*( - s1 *s2 *cap1 *cap2 - s1 *s2 *cap1*cap2
- 2 2 2 2 2 2 2
- + 3*s1 *s2 *cap1*cap2 + s1 *cap1 - 2*s1 *cap1 + s2 *cap2
- 2
- - 2*s2 *cap2 + 1)
- denotid cp;
- pol:=denotepol pol;
- 3 2
- pol := lam + lam *cpr02 + lam*cpr01 + cpr00
- prdenot;
- 2 2 2 2 2 2 2 2
- cpr00 := 8*s1 *s2 *cap1 *cap2 + 8*s1 *s2 *cap1*cap2 - 12*s1 *s2 *cap1*cap2
- 2 2 2 2 2 2
- - 4*s1 *cap1 + 4*s1 *cap1 - 4*s2 *cap2 + 4*s2 *cap2 - 1
- cpr01 :=
- 2 2 2 2 2 2 2 2
- 12*s1 *s2 *cap1*cap2 + 4*s1 *cap1 - 8*s1 *cap1 + 4*s2 *cap2 - 8*s2 *cap2 + 3
- 2 2
- cpr02 := 4*s1 *cap1 + 4*s2 *cap2 - 3
- cleardenot;
- clear aa,bb,pol,pol1;
- %***********************************************************************
- % Example C.6 : Lax-Wendrov (V. Ganzha)
- coordinates t,x,y into n,m,k;
- grid uniform,t,x,y;
- let cos ax**2=1-sin ax**2,
- cos ay**2=1-sin ay**2;
- unfunc u1,u2,u3,u4;
- matrix aa(1,4),bb(4,4);
- aa(1,1):=4*(u1(n+1)-u1(n))/ht+
- (w*(u1(m+2)-u1(m-2)+u1(m+1,k+1)+u1(m+1,k-1)-
- u1(m-1,k+1)-u1(m-1,k-1))+p*(u2(m+2)-u2(m-2)+u2(m+1,k+1)+
- u2(m+1,k-1)-u2(m-1,k+1)-u2(m-1,k-1))+
- v*(u1(m+1,k+1)+u1(m-1,k+1)-
- u1(m+1,k-1)-u1(m-1,k-1)+u1(k+2)-u1(k-2))+p*(u3(m+1,k+1)+
- u3(m-1,k+1)-u3(m+1,k-1)-u3(m-1,k-1)+u3(k+2)-u3(k-2)))/hx+ht*
- (2*w**2*(-u1(m+2)+2*u1(m)-u1(m-2))+4*w*p*(-u2(m+2)+2*u2(m)-
- u2(m-2))+2*(-u4(m+2)+2*u4(m)-u4(m-2))+2*v**2*(-u1(k+2)+
- 2*u1(k)-u1(k-2))+4*v*p*(u3(k+2)+2*u3(k)-u3(k-2))+2*(-u4(k+2)+
- 2*u4(k)-u4(k-2))+4*w*v*(-u1(m+1,k+1)+u1(m+1,k-1)+u1(m-1,k+1)-
- u1(m-1,k-1))+4*p*v*(-u2(m+1,k+1)+u2(m+1,k-1)+u2(m-1,k+1)-
- u2(m-1,k-1))+4*w*p*(-u3(m+1,k+1)+u3(m+1,k-1)+u3(m-1,k+1)-
- u3(m-1,k-1)))/hx/hx$
- aa(1,2):=4*p*(u2(n+1)-u2(n))/ht+
- (w*p*(u2(m+2)-u2(m-2)+u2(m+1,k+1)+
- u2(m+1,k-1)-u2(m-1,k+1)-u2(m-1,k-1))+u4(m+2)-u4(m-2)+
- u4(m+1,k+1)+
- u4(m+1,k-1)-u4(m-1,k+1)-u4(m-1,k-1)+
- p*v*(u2(m+1,k+1)+u2(m-1,k+1)+
- u2(k+2)-u2(k-2)-u2(m+1,k-1)-u2(m-1,k-1)))/hx+ht*(2*w**2*p*
- (-u2(m+2)+2*u2(m)-u2(m-2))+2*p*c**2*(-u2(m+2)+2*u2(m)-u2(m-2))
- +4*w*(-u4(m+2)+2*u4(m)-u4(m-2))+2*p*v**2*(-u2(k+2)+2*u2(k)-
- u2(k-2))+4*w*p*v*(-u2(m+1,k+1)+u2(m+1,k-1)+u2(m-1,k+1)-
- u2(m-1,k-1))+2*p*c**2*(-u3(m+1,k+1)+u3(m+1,k-1)+u3(m-1,k+1)
- -u3(m-1,k-1))+4*v*(-u4(m+1,k+1)+u4(m+1,k-1)+u4(m-1,k+1)-
- u4(m-1,k-1)))/hx/hx$
- aa(1,3):=4*p*(u3(n+1)-u3(n))/ht+(w*p*(u3(m+2)-u3(m-2)+u3(m+1,k+1)+
- u3(m+1,k-1)-u3(m-1,k+1)-u3(m-1,k-1))+u4(k+2)-u4(k-2)+
- u4(m+1,k+1)-u4(m+1,k-1)+u4(m-1,k+1)-u4(m-1,k-1)+
- p*v*(u3(m+1,k+1)+u3(m-1,k+1)+u3(k+2)-u3(k-2)-u3(m+1,k-1)-
- u3(m-1,k-1)))/hx+ht*(2*w**2*p*(-u3(m+2)+2*u3(m)-u3(m-2))+
- 2*p*c**2*(-u3(k+2)+2*u3(k)-u3(k-2))+4*v*(-u4(k+2)+
- 2*u4(k)-u4(k-2))+2*p*v**2*(-u3(k+2)+2*u3(k)-u3(k-2))+
- 4*w*p*v*(-u3(m+1,k+1)+u3(m+1,k-1)+u3(m-1,k+1)-
- u3(m-1,k-1))+2*p*c**2*(-u2(m+1,k+1)+u2(m+1,k-1)+
- u2(m-1,k+1)-u2(m-1,k-1))+4*w*(u4(m+1,k+1)+u4(m+1,k-1)+
- u4(m-1,k+1)-u4(m-1,k-1)))/hx/hx$
- aa(1,4):=4*(u4(n+1)-u4(n))/ht+(p*c**2*(u2(m+2)-u2(m-2)+u2(m+1,k+1)+
- u2(m+1,k-1)-u2(m-1,k+1)-u2(m-1,k-1))+w*(u4(m+2)-
- u4(m-2)+u4(m+1,k+1)+u4(m+1,k-1)-u4(m-1,k+1)-u4(m-1,k-1))+
- +p*c**2*(u3(m+1,k+1)+u3(m-1,k+1)-u3(m+1,k-1)-
- u3(m-1,k-1)+u3(k+2)-u3(k-2))+v*(u4(m+1,k+1)+u4(m-1,k+1)-
- u4(m+1,k-1)-u4(m-1,k-1)+u4(k+2)-u4(k-2)))/hx+ht*
- (2*w**2*(-u4(m+2)+2*u4(m)-u4(m-2))+4*w*p*c**2*(-u2(m+2)+
- 2*u2(m)-u2(m-2))+2*c**2*(-u4(m+2)+2*u4(m)-u4(m-2))+
- 4*p*v*c**2*(-u3(k+2)+2*u3(k)-u3(k-2))+2*c**2*(-u4(k+2)+
- 2*u4(k)-u4(k-2))+2*v**2*(-u4(k+2)+2*u4(k)-u4(k-2))+
- 4*p*v*c**2*(-u2(m+1,k+1)+u2(m+1,k-1)+u2(m-1,k+1)-
- u2(m-1,k-1))+4*w*p*c**2*(-u3(m+1,k+1)+u3(m+1,k-1)+
- u3(m-1,k+1)-u3(m-1,k-1))+4*w*v*(-u4(m+1,k+1)+
- u4(m+1,k-1)+u4(m-1,k+1)-u4(m-1,k-1)))/hx/hx$
- bb:=ampmat aa;
- ax := kx*hx
- ay := ky*hy
- bb := mat((( - i*cos(ax)*sin(ax)*ht*hx*w - i*cos(ax)*sin(ay)*ht*hx*v
- - i*cos(ay)*sin(ax)*ht*hx*w - i*cos(ay)*sin(ay)*ht*hx*v
- 2 2 2 2 2 2 2
- - 2*sin(ax) *ht *w - 4*sin(ax)*sin(ay)*ht *v*w - 2*sin(ay) *ht *v
- 2 2
- + hx )/hx ,(sin(ax)*ht*p*( - i*cos(ax)*hx - i*cos(ay)*hx
- 2
- - 4*sin(ax)*ht*w - 4*sin(ay)*ht*v))/hx ,(ht*p*(
- - i*cos(ax)*sin(ay)*hx - 4*i*cos(ay)*sin(ay)*ht*v
- 2
- - i*cos(ay)*sin(ay)*hx - 4*sin(ax)*sin(ay)*ht*w - 2*ht*v))/hx
- 2 2 2
- - 2*ht *(sin(ax) + sin(ay) )
- ,--------------------------------),
- 2
- hx
- (0,( - i*cos(ax)*sin(ax)*ht*hx*w - i*cos(ax)*sin(ay)*ht*hx*v
- - i*cos(ay)*sin(ax)*ht*hx*w - i*cos(ay)*sin(ay)*ht*hx*v
- 2 2 2 2 2 2
- - 2*sin(ax) *c *ht - 2*sin(ax) *ht *w
- 2 2 2 2 2 2
- - 4*sin(ax)*sin(ay)*ht *v*w - 2*sin(ay) *ht *v + hx )/hx ,
- 2 2
- - 2*sin(ax)*sin(ay)*c *ht
- -----------------------------,(sin(ax)*ht*( - i*cos(ax)*hx
- 2
- hx
- 2
- - i*cos(ay)*hx - 4*sin(ax)*ht*w - 4*sin(ay)*ht*v))/(hx *p)),
- 2 2
- - 2*sin(ax)*sin(ay)*c *ht
- (0,-----------------------------,( - i*cos(ax)*sin(ax)*ht*hx*w
- 2
- hx
- - i*cos(ax)*sin(ay)*ht*hx*v - i*cos(ay)*sin(ax)*ht*hx*w
- 2 2 2
- - i*cos(ay)*sin(ay)*ht*hx*v - 2*sin(ax) *ht *w
- 2 2 2 2
- - 4*sin(ax)*sin(ay)*ht *v*w - 2*sin(ay) *c *ht
- 2 2 2 2 2
- - 2*sin(ay) *ht *v + hx )/hx ,(ht*( - 2*cos(ax)*cos(ay)*ht*w
- - 2*i*cos(ax)*sin(ay)*ht*w - i*cos(ax)*sin(ay)*hx
- - 2*i*cos(ay)*sin(ax)*ht*w - i*cos(ay)*sin(ay)*hx
- 2 2
- - 2*sin(ax)*sin(ay)*ht*w - 4*sin(ay) *ht*v))/(hx *p)),
- 2
- (0,(sin(ax)*c *ht*p*( - i*cos(ax)*hx - i*cos(ay)*hx - 4*sin(ax)*ht*w
- 2 2
- - 4*sin(ay)*ht*v))/hx ,(sin(ay)*c *ht*p*( - i*cos(ax)*hx
- 2
- - i*cos(ay)*hx - 4*sin(ax)*ht*w - 4*sin(ay)*ht*v))/hx ,(
- - i*cos(ax)*sin(ax)*ht*hx*w - i*cos(ax)*sin(ay)*ht*hx*v
- - i*cos(ay)*sin(ax)*ht*hx*w - i*cos(ay)*sin(ay)*ht*hx*v
- 2 2 2 2 2 2
- - 2*sin(ax) *c *ht - 2*sin(ax) *ht *w
- 2 2 2 2
- - 4*sin(ax)*sin(ay)*ht *v*w - 2*sin(ay) *c *ht
- 2 2 2 2 2
- - 2*sin(ay) *ht *v + hx )/hx ))
- let
- sin(ax)=s1,
- cos(ax)=c1,
- sin(ay)=s2,
- cos(ay)=c2,
- w=k1*hx/ht,
- v=k2*hx/ht,
- c=k3*hx/ht,
- ht=r1*hx;
- denotid a;
- bb:=denotemat bb;
- [ai11*i + ar11 ai12*i + ar12 ai13*i + ar13 ar14 ]
- [ ]
- [ 0 ai22*i + ar22 ar23 ai24*i + ar24]
- bb := [ ]
- [ 0 ar32 ai33*i + ar33 ai34*i + ar34]
- [ ]
- [ 0 ai42*i + ar42 ai43*i + ar43 ai44*i + ar44]
- clear sin ax,cos ax,sin ay,cos ay,w,v,c,ht;
- pol:=charpol bb;
- 4 3
- pol := lam + lam
- *( - i*ai11 - i*ai22 - i*ai33 - i*ai44 - ar11 - ar22 - ar33 - ar44) +
- 2
- lam *( - ai11*ai22 - ai11*ai33 - ai11*ai44 + i*ai11*ar22 + i*ai11*ar33
- + i*ai11*ar44 - ai22*ai33 - ai22*ai44 + i*ai22*ar11 + i*ai22*ar33
- + i*ai22*ar44 + ai24*ai42 - i*ai24*ar42 - ai33*ai44 + i*ai33*ar11
- + i*ai33*ar22 + i*ai33*ar44 + ai34*ai43 - i*ai34*ar43
- - i*ai42*ar24 - i*ai43*ar34 + i*ai44*ar11 + i*ai44*ar22
- + i*ai44*ar33 + ar11*ar22 + ar11*ar33 + ar11*ar44 + ar22*ar33
- + ar22*ar44 - ar23*ar32 - ar24*ar42 + ar33*ar44 - ar34*ar43) + lam
- *(i*ai11*ai22*ai33 + i*ai11*ai22*ai44 + ai11*ai22*ar33 + ai11*ai22*ar44
- - i*ai11*ai24*ai42 - ai11*ai24*ar42 + i*ai11*ai33*ai44
- + ai11*ai33*ar22 + ai11*ai33*ar44 - i*ai11*ai34*ai43 - ai11*ai34*ar43
- - ai11*ai42*ar24 - ai11*ai43*ar34 + ai11*ai44*ar22 + ai11*ai44*ar33
- - i*ai11*ar22*ar33 - i*ai11*ar22*ar44 + i*ai11*ar23*ar32
- + i*ai11*ar24*ar42 - i*ai11*ar33*ar44 + i*ai11*ar34*ar43
- + i*ai22*ai33*ai44 + ai22*ai33*ar11 + ai22*ai33*ar44
- - i*ai22*ai34*ai43 - ai22*ai34*ar43 - ai22*ai43*ar34 + ai22*ai44*ar11
- + ai22*ai44*ar33 - i*ai22*ar11*ar33 - i*ai22*ar11*ar44
- - i*ai22*ar33*ar44 + i*ai22*ar34*ar43 - i*ai24*ai33*ai42
- - ai24*ai33*ar42 - ai24*ai42*ar11 - ai24*ai42*ar33 + ai24*ai43*ar32
- + i*ai24*ar11*ar42 - i*ai24*ar32*ar43 + i*ai24*ar33*ar42
- - ai33*ai42*ar24 + ai33*ai44*ar11 + ai33*ai44*ar22 - i*ai33*ar11*ar22
- - i*ai33*ar11*ar44 - i*ai33*ar22*ar44 + i*ai33*ar24*ar42
- + ai34*ai42*ar23 - ai34*ai43*ar11 - ai34*ai43*ar22 + i*ai34*ar11*ar43
- + i*ai34*ar22*ar43 - i*ai34*ar23*ar42 + i*ai42*ar11*ar24
- - i*ai42*ar23*ar34 + i*ai42*ar24*ar33 + i*ai43*ar11*ar34
- + i*ai43*ar22*ar34 - i*ai43*ar24*ar32 - i*ai44*ar11*ar22
- - i*ai44*ar11*ar33 - i*ai44*ar22*ar33 + i*ai44*ar23*ar32
- - ar11*ar22*ar33 - ar11*ar22*ar44 + ar11*ar23*ar32 + ar11*ar24*ar42
- - ar11*ar33*ar44 + ar11*ar34*ar43 - ar22*ar33*ar44 + ar22*ar34*ar43
- + ar23*ar32*ar44 - ar23*ar34*ar42 - ar24*ar32*ar43 + ar24*ar33*ar42)
- + ai11*ai22*ai33*ai44 - i*ai11*ai22*ai33*ar44 - ai11*ai22*ai34*ai43
- + i*ai11*ai22*ai34*ar43 + i*ai11*ai22*ai43*ar34 - i*ai11*ai22*ai44*ar33
- - ai11*ai22*ar33*ar44 + ai11*ai22*ar34*ar43 - ai11*ai24*ai33*ai42
- + i*ai11*ai24*ai33*ar42 + i*ai11*ai24*ai42*ar33 - i*ai11*ai24*ai43*ar32
- - ai11*ai24*ar32*ar43 + ai11*ai24*ar33*ar42 + i*ai11*ai33*ai42*ar24
- - i*ai11*ai33*ai44*ar22 - ai11*ai33*ar22*ar44 + ai11*ai33*ar24*ar42
- - i*ai11*ai34*ai42*ar23 + i*ai11*ai34*ai43*ar22 + ai11*ai34*ar22*ar43
- - ai11*ai34*ar23*ar42 - ai11*ai42*ar23*ar34 + ai11*ai42*ar24*ar33
- + ai11*ai43*ar22*ar34 - ai11*ai43*ar24*ar32 - ai11*ai44*ar22*ar33
- + ai11*ai44*ar23*ar32 + i*ai11*ar22*ar33*ar44 - i*ai11*ar22*ar34*ar43
- - i*ai11*ar23*ar32*ar44 + i*ai11*ar23*ar34*ar42 + i*ai11*ar24*ar32*ar43
- - i*ai11*ar24*ar33*ar42 - i*ai22*ai33*ai44*ar11 - ai22*ai33*ar11*ar44
- + i*ai22*ai34*ai43*ar11 + ai22*ai34*ar11*ar43 + ai22*ai43*ar11*ar34
- - ai22*ai44*ar11*ar33 + i*ai22*ar11*ar33*ar44 - i*ai22*ar11*ar34*ar43
- + i*ai24*ai33*ai42*ar11 + ai24*ai33*ar11*ar42 + ai24*ai42*ar11*ar33
- - ai24*ai43*ar11*ar32 + i*ai24*ar11*ar32*ar43 - i*ai24*ar11*ar33*ar42
- + ai33*ai42*ar11*ar24 - ai33*ai44*ar11*ar22 + i*ai33*ar11*ar22*ar44
- - i*ai33*ar11*ar24*ar42 - ai34*ai42*ar11*ar23 + ai34*ai43*ar11*ar22
- - i*ai34*ar11*ar22*ar43 + i*ai34*ar11*ar23*ar42 + i*ai42*ar11*ar23*ar34
- - i*ai42*ar11*ar24*ar33 - i*ai43*ar11*ar22*ar34 + i*ai43*ar11*ar24*ar32
- + i*ai44*ar11*ar22*ar33 - i*ai44*ar11*ar23*ar32 + ar11*ar22*ar33*ar44
- - ar11*ar22*ar34*ar43 - ar11*ar23*ar32*ar44 + ar11*ar23*ar34*ar42
- + ar11*ar24*ar32*ar43 - ar11*ar24*ar33*ar42
- denotid cp;
- pol:=denotepol pol;
- 4 3 2
- pol := lam + lam *(cpi03*i + cpr03) + lam *(cpi02*i + cpr02)
- + lam*(cpi01*i + cpr01) + cpi00*i + cpr00
- pol:=complexpol pol;
- If cpr00 + cpr01 + cpr02 + cpr03 + 1 = 0 and cpi00 + cpi01 + cpi02 + cpi03
- = 0 , a root of the polynomial is equal to 1.
- 8 7 6 2 2
- pol := lam + 2*lam *cpr03 + lam *(cpi03 + 2*cpr02 + cpr03 )
- 5
- + 2*lam *(cpi02*cpi03 + cpr01 + cpr02*cpr03)
- 4 2 2
- + lam *(2*cpi01*cpi03 + cpi02 + 2*cpr00 + 2*cpr01*cpr03 + cpr02 )
- 3
- + 2*lam *(cpi00*cpi03 + cpi01*cpi02 + cpr00*cpr03 + cpr01*cpr02)
- 2 2 2
- + lam *(2*cpi00*cpi02 + cpi01 + 2*cpr00*cpr02 + cpr01 )
- 2 2
- + 2*lam*(cpi00*cpi01 + cpr00*cpr01) + cpi00 + cpr00
- denotid rp;
- pol:=denotepol pol;
- 8 7 6 5 4 3
- pol := lam + lam *rpr07 + lam *rpr06 + lam *rpr05 + lam *rpr04 + lam *rpr03
- 2
- + lam *rpr02 + lam*rpr01 + rpr00
- prdenot;
- 2 2 2 2
- ar11 := - 2*s1 *k1 - 4*s1*s2*k1*k2 - 2*s2 *k2 + 1
- ai11 := - (s1*c1*k1 + s1*c2*k1 + s2*c1*k2 + s2*c2*k2)
- ar12 := - 4*s1*p*r1*(s1*k1 + s2*k2)
- ai12 := - s1*p*r1*(c1 + c2)
- ar13 := 2*p*r1*( - 2*s1*s2*k1 - k2)
- ai13 := s2*p*r1*( - c1 - 4*c2*k2 - c2)
- 2 2 2
- ar14 := - 2*r1 *(s1 + s2 )
- 2 2 2 2 2 2
- ar22 := - 2*s1 *k1 - 2*s1 *k3 - 4*s1*s2*k1*k2 - 2*s2 *k2 + 1
- ai22 := - (s1*c1*k1 + s1*c2*k1 + s2*c1*k2 + s2*c2*k2)
- 2
- ar23 := - 2*s1*s2*k3
- - 4*s1*r1*(s1*k1 + s2*k2)
- ar24 := ----------------------------
- p
- - s1*r1*(c1 + c2)
- ai24 := --------------------
- p
- 2
- ar32 := - 2*s1*s2*k3
- 2 2 2 2 2 2
- ar33 := - 2*s1 *k1 - 4*s1*s2*k1*k2 - 2*s2 *k2 - 2*s2 *k3 + 1
- ai33 := - (s1*c1*k1 + s1*c2*k1 + s2*c1*k2 + s2*c2*k2)
- 2
- 2*r1*( - s1*s2*k1 - 2*s2 *k2 - c1*c2*k1)
- ar34 := ------------------------------------------
- p
- r1*( - 2*s1*c2*k1 - 2*s2*c1*k1 - s2*c1 - s2*c2)
- ai34 := -------------------------------------------------
- p
- 2
- - 4*s1*k3 *p*(s1*k1 + s2*k2)
- ar42 := -------------------------------
- r1
- 2
- - s1*k3 *p*(c1 + c2)
- ai42 := -----------------------
- r1
- 2
- - 4*s2*k3 *p*(s1*k1 + s2*k2)
- ar43 := -------------------------------
- r1
- 2
- - s2*k3 *p*(c1 + c2)
- ai43 := -----------------------
- r1
- 2 2 2 2 2 2 2 2
- ar44 := - 2*s1 *k1 - 2*s1 *k3 - 4*s1*s2*k1*k2 - 2*s2 *k2 - 2*s2 *k3 + 1
- ai44 := - (s1*c1*k1 + s1*c2*k1 + s2*c1*k2 + s2*c2*k2)
- cpr00 := ai11*ai22*ai33*ai44 - ai11*ai22*ai34*ai43 - ai11*ai22*ar33*ar44
- + ai11*ai22*ar34*ar43 - ai11*ai24*ai33*ai42 - ai11*ai24*ar32*ar43
- + ai11*ai24*ar33*ar42 - ai11*ai33*ar22*ar44 + ai11*ai33*ar24*ar42
- + ai11*ai34*ar22*ar43 - ai11*ai34*ar23*ar42 - ai11*ai42*ar23*ar34
- + ai11*ai42*ar24*ar33 + ai11*ai43*ar22*ar34 - ai11*ai43*ar24*ar32
- - ai11*ai44*ar22*ar33 + ai11*ai44*ar23*ar32 - ai22*ai33*ar11*ar44
- + ai22*ai34*ar11*ar43 + ai22*ai43*ar11*ar34 - ai22*ai44*ar11*ar33
- + ai24*ai33*ar11*ar42 + ai24*ai42*ar11*ar33 - ai24*ai43*ar11*ar32
- + ai33*ai42*ar11*ar24 - ai33*ai44*ar11*ar22 - ai34*ai42*ar11*ar23
- + ai34*ai43*ar11*ar22 + ar11*ar22*ar33*ar44 - ar11*ar22*ar34*ar43
- - ar11*ar23*ar32*ar44 + ar11*ar23*ar34*ar42 + ar11*ar24*ar32*ar43
- - ar11*ar24*ar33*ar42
- cpi00 := - ai11*ai22*ai33*ar44 + ai11*ai22*ai34*ar43 + ai11*ai22*ai43*ar34
- - ai11*ai22*ai44*ar33 + ai11*ai24*ai33*ar42 + ai11*ai24*ai42*ar33
- - ai11*ai24*ai43*ar32 + ai11*ai33*ai42*ar24 - ai11*ai33*ai44*ar22
- - ai11*ai34*ai42*ar23 + ai11*ai34*ai43*ar22 + ai11*ar22*ar33*ar44
- - ai11*ar22*ar34*ar43 - ai11*ar23*ar32*ar44 + ai11*ar23*ar34*ar42
- + ai11*ar24*ar32*ar43 - ai11*ar24*ar33*ar42 - ai22*ai33*ai44*ar11
- + ai22*ai34*ai43*ar11 + ai22*ar11*ar33*ar44 - ai22*ar11*ar34*ar43
- + ai24*ai33*ai42*ar11 + ai24*ar11*ar32*ar43 - ai24*ar11*ar33*ar42
- + ai33*ar11*ar22*ar44 - ai33*ar11*ar24*ar42 - ai34*ar11*ar22*ar43
- + ai34*ar11*ar23*ar42 + ai42*ar11*ar23*ar34 - ai42*ar11*ar24*ar33
- - ai43*ar11*ar22*ar34 + ai43*ar11*ar24*ar32 + ai44*ar11*ar22*ar33
- - ai44*ar11*ar23*ar32
- cpr01 := ai11*ai22*ar33 + ai11*ai22*ar44 - ai11*ai24*ar42 + ai11*ai33*ar22
- + ai11*ai33*ar44 - ai11*ai34*ar43 - ai11*ai42*ar24 - ai11*ai43*ar34
- + ai11*ai44*ar22 + ai11*ai44*ar33 + ai22*ai33*ar11 + ai22*ai33*ar44
- - ai22*ai34*ar43 - ai22*ai43*ar34 + ai22*ai44*ar11 + ai22*ai44*ar33
- - ai24*ai33*ar42 - ai24*ai42*ar11 - ai24*ai42*ar33 + ai24*ai43*ar32
- - ai33*ai42*ar24 + ai33*ai44*ar11 + ai33*ai44*ar22 + ai34*ai42*ar23
- - ai34*ai43*ar11 - ai34*ai43*ar22 - ar11*ar22*ar33 - ar11*ar22*ar44
- + ar11*ar23*ar32 + ar11*ar24*ar42 - ar11*ar33*ar44 + ar11*ar34*ar43
- - ar22*ar33*ar44 + ar22*ar34*ar43 + ar23*ar32*ar44 - ar23*ar34*ar42
- - ar24*ar32*ar43 + ar24*ar33*ar42
- cpi01 := ai11*ai22*ai33 + ai11*ai22*ai44 - ai11*ai24*ai42 + ai11*ai33*ai44
- - ai11*ai34*ai43 - ai11*ar22*ar33 - ai11*ar22*ar44 + ai11*ar23*ar32
- + ai11*ar24*ar42 - ai11*ar33*ar44 + ai11*ar34*ar43 + ai22*ai33*ai44
- - ai22*ai34*ai43 - ai22*ar11*ar33 - ai22*ar11*ar44 - ai22*ar33*ar44
- + ai22*ar34*ar43 - ai24*ai33*ai42 + ai24*ar11*ar42 - ai24*ar32*ar43
- + ai24*ar33*ar42 - ai33*ar11*ar22 - ai33*ar11*ar44 - ai33*ar22*ar44
- + ai33*ar24*ar42 + ai34*ar11*ar43 + ai34*ar22*ar43 - ai34*ar23*ar42
- + ai42*ar11*ar24 - ai42*ar23*ar34 + ai42*ar24*ar33 + ai43*ar11*ar34
- + ai43*ar22*ar34 - ai43*ar24*ar32 - ai44*ar11*ar22 - ai44*ar11*ar33
- - ai44*ar22*ar33 + ai44*ar23*ar32
- cpr02 := - ai11*ai22 - ai11*ai33 - ai11*ai44 - ai22*ai33 - ai22*ai44
- + ai24*ai42 - ai33*ai44 + ai34*ai43 + ar11*ar22 + ar11*ar33
- + ar11*ar44 + ar22*ar33 + ar22*ar44 - ar23*ar32 - ar24*ar42
- + ar33*ar44 - ar34*ar43
- cpi02 := ai11*ar22 + ai11*ar33 + ai11*ar44 + ai22*ar11 + ai22*ar33 + ai22*ar44
- - ai24*ar42 + ai33*ar11 + ai33*ar22 + ai33*ar44 - ai34*ar43
- - ai42*ar24 - ai43*ar34 + ai44*ar11 + ai44*ar22 + ai44*ar33
- cpr03 := - (ar11 + ar22 + ar33 + ar44)
- cpi03 := - (ai11 + ai22 + ai33 + ai44)
- 2 2
- rpr00 := cpi00 + cpr00
- rpr01 := 2*(cpi00*cpi01 + cpr00*cpr01)
- 2 2
- rpr02 := 2*cpi00*cpi02 + cpi01 + 2*cpr00*cpr02 + cpr01
- rpr03 := 2*(cpi00*cpi03 + cpi01*cpi02 + cpr00*cpr03 + cpr01*cpr02)
- 2 2
- rpr04 := 2*cpi01*cpi03 + cpi02 + 2*cpr00 + 2*cpr01*cpr03 + cpr02
- rpr05 := 2*(cpi02*cpi03 + cpr01 + cpr02*cpr03)
- 2 2
- rpr06 := cpi03 + 2*cpr02 + cpr03
- rpr07 := 2*cpr03
- cleardenot;
- clear aa,bb,pol;
- %***********************************************************************
- %***** *****
- %***** T e s t Examples --- Module H U R W P *****
- %***** *****
- %***********************************************************************
- % Example H.1
- x0:=lam-1;
- x0 := lam - 1
- x1:=lam-(ar+i*ai);
- x1 := lam - (ai*i + ar)
- x2:=lam-(br+i*bi);
- x2 := lam - (bi*i + br)
- x3:=lam-(cr+i*ci);
- x3 := lam - (ci*i + cr)
- hurwitzp x1;
- Necessary and sufficient conditions are:
- - ar > 0
- cond
- % Example H.2
- x:=hurw(x0*x1);
- x := 2*lam*( - ai*i - ar + 1) + 2*(ai*i + ar + 1)
- hurwitzp x;
- Necessary and sufficient conditions are:
- 2 2
- 4*( - ai - ar + 1) > 0
- cond
- % Example H.3
- x:=(x1*x2);
- 2
- x := lam - lam*(ai*i + ar + bi*i + br) - ai*bi + ai*br*i + ar*bi*i + ar*br
- hurwitzp x;
- Necessary and sufficient conditions are:
- - (ar + br) > 0
- 2 2 2 2
- ar*br*(ai - 2*ai*bi + ar + 2*ar*br + bi + br ) > 0
- cond
- % Example H.4
- x:=(x1*x2*x3);
- 3 2
- x := lam - lam *(ai*i + ar + bi*i + br + ci*i + cr) + lam*( - ai*bi + ai*br*i
- - ai*ci + ai*cr*i + ar*bi*i + ar*br + ar*ci*i + ar*cr - bi*ci + bi*cr*i
- + br*ci*i + br*cr) + ai*bi*ci*i + ai*bi*cr + ai*br*ci - ai*br*cr*i
- + ar*bi*ci - ar*bi*cr*i - ar*br*ci*i - ar*br*cr
- hurwitzp x;
- Necessary and sufficient conditions are:
- - (ar + br + cr) > 0
- 2 2 3 3
- ai *ar*br + ai *ar*cr - 2*ai*ar*bi*br - 2*ai*ar*ci*cr + ar *br + ar *cr
- 2 2 2 2 2 2 3 2
- + 2*ar *br + 4*ar *br*cr + 2*ar *cr + ar*bi *br + ar*br + 4*ar*br *cr
- 2 2 3 2 3
- + 4*ar*br*cr + ar*ci *cr + ar*cr + bi *br*cr - 2*bi*br*ci*cr + br *cr
- 2 2 2 3
- + 2*br *cr + br*ci *cr + br*cr > 0
- 4 2 4 4 2 4 4 2 4 2
- ar*br*cr*( - ai *bi + 2*ai *bi*ci - ai *br - 2*ai *br*cr - ai *ci - ai *cr
- 3 3 3 2 3 2 3
- + 2*ai *bi - 2*ai *bi *ci + 2*ai *bi*br + 4*ai *bi*br*cr
- 3 2 3 2 3 2 3
- - 2*ai *bi*ci + 2*ai *bi*cr + 2*ai *br *ci + 4*ai *br*ci*cr
- 3 3 3 2 2 2 2 2 2
- + 2*ai *ci + 2*ai *ci*cr - 2*ai *ar *bi + 4*ai *ar *bi*ci
- 2 2 2 2 2 2 2 2 2 2 2
- - 2*ai *ar *br - 4*ai *ar *br*cr - 2*ai *ar *ci - 2*ai *ar *cr
- 2 2 2 2 2
- - 2*ai *ar*bi *br - 2*ai *ar*bi *cr + 4*ai *ar*bi*br*ci
- 2 2 3 2 2
- + 4*ai *ar*bi*ci*cr - 2*ai *ar*br - 6*ai *ar*br *cr
- 2 2 2 2 2 2 2 3
- - 2*ai *ar*br*ci - 6*ai *ar*br*cr - 2*ai *ar*ci *cr - 2*ai *ar*cr
- 2 4 2 3 2 2 2 2 2
- - ai *bi - 2*ai *bi *ci - 2*ai *bi *br - 2*ai *bi *br*cr
- 2 2 2 2 2 2 2 2 2
- + 6*ai *bi *ci - 2*ai *bi *cr - 2*ai *bi*br *ci - 8*ai *bi*br*ci*cr
- 2 3 2 2 2 4 2 3
- - 2*ai *bi*ci - 2*ai *bi*ci*cr - ai *br - 2*ai *br *cr
- 2 2 2 2 2 2 2 2 2 3
- - 2*ai *br *ci - 2*ai *br *cr - 2*ai *br*ci *cr - 2*ai *br*cr
- 2 4 2 2 2 2 4 2 3 2 2
- - ai *ci - 2*ai *ci *cr - ai *cr + 2*ai*ar *bi - 2*ai*ar *bi *ci
- 2 2 2 2 2
- + 2*ai*ar *bi*br + 4*ai*ar *bi*br*cr - 2*ai*ar *bi*ci
- 2 2 2 2 2
- + 2*ai*ar *bi*cr + 2*ai*ar *br *ci + 4*ai*ar *br*ci*cr
- 2 3 2 2 3 2
- + 2*ai*ar *ci + 2*ai*ar *ci*cr + 4*ai*ar*bi *cr + 4*ai*ar*bi *br*ci
- 2 2 2
- - 8*ai*ar*bi *ci*cr + 4*ai*ar*bi*br *cr - 8*ai*ar*bi*br*ci
- 2 2 3
- + 8*ai*ar*bi*br*cr + 4*ai*ar*bi*ci *cr + 4*ai*ar*bi*cr
- 3 2 3
- + 4*ai*ar*br *ci + 8*ai*ar*br *ci*cr + 4*ai*ar*br*ci
- 2 4 3 2 3 2
- + 4*ai*ar*br*ci*cr + 2*ai*bi *ci - 2*ai*bi *ci + 2*ai*bi *cr
- 2 2 2 2 3
- + 4*ai*bi *br *ci + 4*ai*bi *br*ci*cr - 2*ai*bi *ci
- 2 2 2 2 2 2
- - 2*ai*bi *ci*cr - 2*ai*bi*br *ci + 2*ai*bi*br *cr
- 2 3 4 2 2
- + 4*ai*bi*br*ci *cr + 4*ai*bi*br*cr + 2*ai*bi*ci + 4*ai*bi*ci *cr
- 4 4 3 2 3
- + 2*ai*bi*cr + 2*ai*br *ci + 4*ai*br *ci*cr + 2*ai*br *ci
- 2 2 4 2 4 4 2 4
- + 2*ai*br *ci*cr - ar *bi + 2*ar *bi*ci - ar *br - 2*ar *br*cr
- 4 2 4 2 3 2 3 2 3
- - ar *ci - ar *cr - 2*ar *bi *br - 2*ar *bi *cr + 4*ar *bi*br*ci
- 3 3 3 3 2 3 2
- + 4*ar *bi*ci*cr - 2*ar *br - 6*ar *br *cr - 2*ar *br*ci
- 3 2 3 2 3 3 2 4 2 3
- - 6*ar *br*cr - 2*ar *ci *cr - 2*ar *cr - ar *bi + 2*ar *bi *ci
- 2 2 2 2 2 2 2 2 2 2 2
- - 2*ar *bi *br - 6*ar *bi *br*cr - 2*ar *bi *ci - 2*ar *bi *cr
- 2 2 2 2 3
- + 2*ar *bi*br *ci + 8*ar *bi*br*ci*cr + 2*ar *bi*ci
- 2 2 2 4 2 3 2 2 2
- + 2*ar *bi*ci*cr - ar *br - 6*ar *br *cr - 2*ar *br *ci
- 2 2 2 2 2 2 3 2 4
- - 10*ar *br *cr - 6*ar *br*ci *cr - 6*ar *br*cr - ar *ci
- 2 2 2 2 4 4 3
- - 2*ar *ci *cr - ar *cr - 2*ar*bi *cr + 4*ar*bi *ci*cr
- 2 2 2 2 2 2
- - 4*ar*bi *br *cr - 2*ar*bi *br*ci - 6*ar*bi *br*cr
- 2 2 2 3 2 3
- - 2*ar*bi *ci *cr - 2*ar*bi *cr + 4*ar*bi*br *ci*cr + 4*ar*bi*br*ci
- 2 4 3 2 3 2
- + 4*ar*bi*br*ci*cr - 2*ar*br *cr - 2*ar*br *ci - 6*ar*br *cr
- 2 2 2 3 4 2 2
- - 6*ar*br *ci *cr - 6*ar*br *cr - 2*ar*br*ci - 4*ar*br*ci *cr
- 4 4 2 4 2 3 3 3 2
- - 2*ar*br*cr - bi *ci - bi *cr + 2*bi *ci + 2*bi *ci*cr
- 2 2 2 2 2 2 2 2 2 3
- - 2*bi *br *ci - 2*bi *br *cr - 2*bi *br*ci *cr - 2*bi *br*cr
- 2 4 2 2 2 2 4 2 3 2 2
- - bi *ci - 2*bi *ci *cr - bi *cr + 2*bi*br *ci + 2*bi*br *ci*cr
- 4 2 4 2 3 2 3 3 2 4
- - br *ci - br *cr - 2*br *ci *cr - 2*br *cr - br *ci
- 2 2 2 2 4
- - 2*br *ci *cr - br *cr ) > 0
- cond
- clear x,x0,x1,x2,x3;
- %***********************************************************************
- %***** *****
- %***** T e s t Examples --- Module L I N B A N D *****
- %***** *****
- %***********************************************************************
- on evallhseqp;
- % So both sides of equations evaluate.
- % Example L.1
- operator v;
- off echo;
- dimension u(200),v(200),acof(200,3),arhs(200),xl(200,3)
- dx=5.0e-2
- x=0.1
- do 25001 i=1,101
- v(i)=x**2/2.0
- x=x+dx
- 25001 continue
- iacof=200
- iarhs=200
- n=1
- ad(n)=1.0
- aucd(n)=0.0
- arhs(n)=v(1)
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n)=1.0
- arhs(n)=v(3)-(2.0*v(2))+v(1)
- do 25002 k=3,99,1
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n)=1.0
- arhs(n)=v(k-1)+v(k+1)-(2.0*v(k))
- 25002 continue
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n)=1.0
- arhs(n)=v(101)-(2.0*v(100))+v(99)
- n=n+1
- alcd(n)=0.0
- ad(n)=1.0
- arhs(n)=v(101)
- call dgtsl(n,alcd,ad,aucd,arhs,ier)
- c n is number of equations
- c alcd,ad,aucd,arhs are arrays of dimension at least (n)
- c if (ier.ne.0) matrix acof is algorithmically singular
- if(ier.ne.0) call errout
- n=1
- u(1)=arhs(n)
- n=n+1
- u(2)=arhs(n)
- do 25003 k=3,99,1
- n=n+1
- u(k)=arhs(n)
- 25003 continue
- n=n+1
- u(100)=arhs(n)
- n=n+1
- u(101)=arhs(n)
- amer=0.0
- arer=0.0
- do 25004 i=1,101
- am=abs(real(u(i)-v(i)))
- ar=am/v(i)
- if(am.gt.amer) amer=am
- if(ar.gt.arer) arer=ar
- 25004 continue
- write(*,100)amer,arer
- stop
- 100 format(' max. abs. error = ',e12.2,' max. rel. error = ',e12.2)
- end
- %***********************************************************************
- % Example L.2
- on nag;
- off echo;
- dimension u(200),v(200),acof(200,3),arhs(200),xl(200,3)
- dx=5.0e-2
- x=0.1
- do 25005 i=1,101
- v(i)=x**2/2.0
- x=x+dx
- 25005 continue
- iacof=200
- iarhs=200
- n=1
- ad(n)=1.0
- aucd(n+1)=0.0
- arhs(n)=v(1)
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n+1)=1.0
- arhs(n)=v(3)-(2.0*v(2))+v(1)
- do 25006 k=3,99,1
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n+1)=1.0
- arhs(n)=v(k-1)+v(k+1)-(2.0*v(k))
- 25006 continue
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n+1)=1.0
- arhs(n)=v(101)-(2.0*v(100))+v(99)
- n=n+1
- alcd(n)=0.0
- ad(n)=1.0
- arhs(n)=v(101)
- ier=0
- call f01lef(n,ad,0.,aucd,alcd,1.e-10,au2cd,in,ier)
- c n is number of equations
- c alcd,ad,aucd,au2cd,arhs are arrays of dimension at least (n)
- c in is integer array of dimension at least (n)
- if(ier.ne.0 .or. in(n).ne.0) call errout
- call f04lef(1,n,ad,aucd,alcd,au2cd,in,arhs,0.,ier)
- if(ier.ne.0) call errout
- n=1
- u(1)=arhs(n)
- n=n+1
- u(2)=arhs(n)
- do 25007 k=3,99,1
- n=n+1
- u(k)=arhs(n)
- 25007 continue
- n=n+1
- u(100)=arhs(n)
- n=n+1
- u(101)=arhs(n)
- amer=0.0
- arer=0.0
- do 25008 i=1,101
- am=abs(real(u(i)-v(i)))
- ar=am/v(i)
- if(am.gt.amer) amer=am
- if(ar.gt.arer) arer=ar
- 25008 continue
- write(*,100)amer,arer
- stop
- 100 format(' max. abs. error = ',e12.2,' max. rel. error = ',e12.2)
- end
- %***********************************************************************
- % Example L.3
- on imsl;
- off echo,nag;
- dimension u(200),v(200),acof(200,3),arhs(200),xl(200,3)
- dx=5.0e-2
- x=0.1
- do 25009 i=1,101
- v(i)=x**2/2.0
- x=x+dx
- 25009 continue
- iacof=200
- iarhs=200
- n=1
- acof(n,1)=0.0
- acof(n,2)=1.0
- acof(n,3)=0.0
- arhs(n)=v(1)
- n=n+1
- acof(n,1)=1.0
- acof(n,2)=-2.0
- acof(n,3)=1.0
- arhs(n)=v(3)-(2.0*v(2))+v(1)
- do 25010 k=3,99,1
- n=n+1
- acof(n,1)=1.0
- acof(n,2)=-2.0
- acof(n,3)=1.0
- arhs(n)=v(k-1)+v(k+1)-(2.0*v(k))
- 25010 continue
- n=n+1
- acof(n,1)=1.0
- acof(n,2)=-2.0
- acof(n,3)=1.0
- arhs(n)=v(101)-(2.0*v(100))+v(99)
- n=n+1
- acof(n,1)=0.0
- acof(n,2)=1.0
- acof(n,3)=0.0
- arhs(n)=v(101)
- call leqt1b(acof,n,1,1,iacof,arhs,1,iarhs,0,xl,ier)
- c iacof is actual 1-st dimension of the acof array
- c iarhs is actual 1-st dimension of the arhs array
- c xl is working array with size n*(nlc+1)
- c where n is number of equations nlc number of lower
- c codiagonals
- c if ier=129( .ne.0) matrix acof is algorithmically singular
- if(ier.ne.0) call errout
- n=1
- u(1)=arhs(n)
- n=n+1
- u(2)=arhs(n)
- do 25011 k=3,99,1
- n=n+1
- u(k)=arhs(n)
- 25011 continue
- n=n+1
- u(100)=arhs(n)
- n=n+1
- u(101)=arhs(n)
- amer=0.0
- arer=0.0
- do 25012 i=1,101
- am=abs(real(u(i)-v(i)))
- ar=am/v(i)
- if(am.gt.amer) amer=am
- if(ar.gt.arer) arer=ar
- 25012 continue
- write(*,100)amer,arer
- stop
- 100 format(' max. abs. error = ',e12.2,' max. rel. error = ',e12.2)
- end
- %***********************************************************************
- % Example L.4
- on essl;
- off echo,imsl;
- dimension u(200),v(200),acof(200,3),arhs(200),xl(200,3)
- dx=5.0e-2
- x=0.1
- do 25013 i=1,101
- v(i)=x**2/2.0
- x=x+dx
- 25013 continue
- iacof=200
- iarhs=200
- n=1
- ad(n)=1.0
- aucd(n)=0.0
- arhs(n)=v(1)
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n)=1.0
- arhs(n)=v(3)-(2.0*v(2))+v(1)
- do 25014 k=3,99,1
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n)=1.0
- arhs(n)=v(k-1)+v(k+1)-(2.0*v(k))
- 25014 continue
- n=n+1
- alcd(n)=1.0
- ad(n)=-2.0
- aucd(n)=1.0
- arhs(n)=v(101)-(2.0*v(100))+v(99)
- n=n+1
- alcd(n)=0.0
- ad(n)=1.0
- arhs(n)=v(101)
- call dgtf(n,alcd,ad,aucd,af,ipvt)
- c n is number of equations
- c alcd,ad,aucd,af,arhs are arrays of dimension at least (n)
- c these arrays are double precision type
- c for single precision change dgtf to sgtf and dgts to sgts
- c ipvt is integer array of dimension at least (n+3)/8
- call dgts(n,alcd,ad,aucd,af,ipvt,arhs)
- n=1
- u(1)=arhs(n)
- n=n+1
- u(2)=arhs(n)
- do 25015 k=3,99,1
- n=n+1
- u(k)=arhs(n)
- 25015 continue
- n=n+1
- u(100)=arhs(n)
- n=n+1
- u(101)=arhs(n)
- amer=0.0
- arer=0.0
- do 25016 i=1,101
- am=abs(real(u(i)-v(i)))
- ar=am/v(i)
- if(am.gt.amer) amer=am
- if(ar.gt.arer) arer=ar
- 25016 continue
- write(*,100)amer,arer
- stop
- 100 format(' max. abs. error = ',e12.2,' max. rel. error = ',e12.2)
- end
- off essl;
- %***********************************************************************
- %***** *****
- %***** T e s t Complex Examples --- More Modules *****
- %***** *****
- %***********************************************************************
- % Example M.1
- off exp;
- coordinates t,x into n,j;
- grid uniform,x,t;
- dependence v(t,x),w(t,x);
- isgrid v(x..one),w(x..half);
- iim aa, v, diff(v,t)=c*diff(w,x),
- w, diff(w,t)=c*diff(v,x);
- *****************************
- ***** Program ***** IIMET Ver 1.1.2
- *****************************
- Partial Differential Equations
- ==============================
- diff(v,t) - diff(w,x)*c = 0
- - diff(v,x)*c + diff(w,t) = 0
- 0 interpolations are needed in t coordinate
- Equation for v variable is integrated in half grid point
- Equation for w variable is integrated in half grid point
- 0 interpolations are needed in x coordinate
- Equation for v variable is integrated in one grid point
- Equation for w variable is integrated in half grid point
- Equations after Discretization Using IIM :
- ==========================================
- 2*j - 1 2*j + 1 2*j + 1 2*j - 1
- ((w(n,---------) - w(n,---------) - w(n + 1,---------) + w(n + 1,---------))*c
- 2 2 2 2
- *ht + 2*(v(n + 1,j) - v(n,j))*hx)/(2*ht*hx) = 0
- ( - (v(n,j + 1) - v(n,j) - v(n + 1,j) + v(n + 1,j + 1))*c*ht
- 2*j + 1 2*j + 1
- + 2*(w(n + 1,---------) - w(n,---------))*hx)/(2*ht*hx) = 0
- 2 2
- on exp;
- center t=1/2;
- functions v,w;
- approx( aa(0,0)=aa(0,1));
- Difference scheme approximates differential equation df(v,t) - df(w,x)*c=0
- with orders of approximation:
- 2
- ht
- 2
- hx
- center x=1/2;
- approx( aa(1,0)=aa(1,1));
- Difference scheme approximates differential equation - df(v,x)*c + df(w,t)=0
- with orders of approximation:
- 2
- ht
- 2
- hx
- let cos ax**2=1-sin ax**2;
- unfunc v,w;
- matrix a(1,2),b(2,2),bt(2,2);
- a(1,1):=aa(0,0);
- 2*j - 1
- a(1,1) := (2*v(n + 1,j)*hx - 2*v(n,j)*hx + w(n + 1,---------)*c*ht
- 2
- 2*j + 1 2*j - 1
- - w(n + 1,---------)*c*ht + w(n,---------)*c*ht
- 2 2
- 2*j + 1
- - w(n,---------)*c*ht)/(2*ht*hx)
- 2
- a(1,2):=aa(1,0);
- a(1,2) := ( - v(n + 1,j + 1)*c*ht + v(n + 1,j)*c*ht - v(n,j + 1)*c*ht
- 2*j + 1 2*j + 1
- + v(n,j)*c*ht + 2*w(n + 1,---------)*hx - 2*w(n,---------)*hx)/(2*ht
- 2 2
- *hx)
- off prfourmat;
- b:=ampmat a;
- kx*hx
- ax := -------
- 2
- [ 2 2 2 2 ]
- [ - sin(ax) *c *ht + hx 2*i*sin(ax)*c*ht*hx ]
- [-------------------------- ----------------------- ]
- [ 2 2 2 2 2 2 2 2 ]
- [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
- b := [ ]
- [ 2 2 2 2 ]
- [ 2*i*sin(ax)*c*ht*hx - sin(ax) *c *ht + hx ]
- [ ----------------------- --------------------------]
- [ 2 2 2 2 2 2 2 2 ]
- [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
- clear a,aa;
- factor lam;
- pol:=charpol b;
- 2 4 4 4 2 2 2 2 4
- pol := (lam *(sin(ax) *c *ht + 2*sin(ax) *c *ht *hx + hx )
- 4 4 4 4 4 4 4
- + 2*lam*(sin(ax) *c *ht - hx ) + sin(ax) *c *ht
- 2 2 2 2 4 4 4 4 2 2 2 2
- + 2*sin(ax) *c *ht *hx + hx )/(sin(ax) *c *ht + 2*sin(ax) *c *ht *hx
- 4
- + hx )
- pol:=troot1 pol;
- 2 2 2
- 4*sin(ax) *c *ht
- If ----------------------- = 0 and 0
- 2 2 2 2
- sin(ax) *c *ht + hx
- = 0 , a root of the polynomial is equal to 1.
- 2 4 4 4 2 2 2 2 4
- pol := (lam *(sin(ax) *c *ht + 2*sin(ax) *c *ht *hx + hx )
- 4 4 4 4 4 4 4
- + 2*lam*(sin(ax) *c *ht - hx ) + sin(ax) *c *ht
- 2 2 2 2 4 4 4 4 2 2 2 2
- + 2*sin(ax) *c *ht *hx + hx )/(sin(ax) *c *ht + 2*sin(ax) *c *ht *hx
- 4
- + hx )
- pol:=hurw num pol;
- pol :=
- 2 2 2 2 2 2 2 2 2 2 2 2 2
- 4*lam *sin(ax) *c *ht *(sin(ax) *c *ht + hx ) + 4*hx *(sin(ax) *c *ht + hx )
- hurwitzp pol;
- Necessary and sufficient conditions are:
- 2
- hx
- ----------------- > 0
- 2 2 2
- sin(ax) *c *ht
- cond
- bt:=tcon b;
- [ 2 2 2 2 ]
- [ - sin(ax) *c *ht + hx - 2*sin(ax)*c*ht*hx*i ]
- [-------------------------- ------------------------ ]
- [ 2 2 2 2 2 2 2 2 ]
- [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
- bt := [ ]
- [ 2 2 2 2 ]
- [ - 2*sin(ax)*c*ht*hx*i - sin(ax) *c *ht + hx ]
- [ ------------------------ --------------------------]
- [ 2 2 2 2 2 2 2 2 ]
- [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
- bt*b;
- [1 0]
- [ ]
- [0 1]
- bt*b-b*bt;
- [0 0]
- [ ]
- [0 0]
- clear aa,a,b,bt;
- %***********************************************************************
- % Example M.2 : Richtmyer, Morton: Difference methods for initial value
- % problems, &10.2. p.261
- coordinates t,x into n,j;
- grid uniform,t,x;
- let cos ax**2=1-sin ax**2;
- unfunc v,w;
- matrix a(1,2),b(2,2),bt(2,2);
- a(1,1):=(v(n+1)-v(n))/ht-c*(w(j+1/2)-w(j-1/2))/hx$
- a(1,2):=(w(n+1,j-1/2)-w(n,j-1/2))/ht-c*(v(n+1,j)-v(n+1,j-1))/hx$
- off prfourmat;
- b:=ampmat a;
- kx*hx
- ax := -------
- 2
- [ 2*i*sin(ax)*c*ht ]
- [ 1 ------------------ ]
- [ hx ]
- [ ]
- b := [ 2 2 2 2 ]
- [ 2*i*sin(ax)*c*ht - 4*sin(ax) *c *ht + hx ]
- [------------------ ----------------------------]
- [ hx 2 ]
- [ hx ]
- clear a;
- factor lam;
- pol:=charpol b;
- 2 2 2 2 2 2 2
- lam *hx + 2*lam*(2*sin(ax) *c *ht - hx ) + hx
- pol := --------------------------------------------------
- 2
- hx
- pol:=hurw num pol;
- 2 2 2 2 2 2 2 2
- pol := 4*lam *sin(ax) *c *ht + 4*( - sin(ax) *c *ht + hx )
- hurwitzp pol;
- Necessary and sufficient conditions are:
- 2 2 2 2
- - sin(ax) *c *ht + hx
- -------------------------- > 0
- 2 2 2
- sin(ax) *c *ht
- cond
- bt:=tcon b;
- [ - 2*sin(ax)*c*ht*i ]
- [ 1 --------------------- ]
- [ hx ]
- [ ]
- bt := [ 2 2 2 2 ]
- [ - 2*sin(ax)*c*ht*i - 4*sin(ax) *c *ht + hx ]
- [--------------------- ----------------------------]
- [ hx 2 ]
- [ hx ]
- bt*b;
- [ 2 2 2 2 3 3 3 ]
- [ 4*sin(ax) *c *ht + hx 8*sin(ax) *c *ht *i ]
- [------------------------- --------------------- ]
- [ 2 3 ]
- [ hx hx ]
- [ ]
- [ 3 3 3 4 4 4 2 2 2 2 4 ]
- [ - 8*sin(ax) *c *ht *i 16*sin(ax) *c *ht - 4*sin(ax) *c *ht *hx + hx ]
- [------------------------ --------------------------------------------------]
- [ 3 4 ]
- [ hx hx ]
- bt*b-b*bt;
- [ 3 3 3 ]
- [ 16*sin(ax) *c *ht *i ]
- [ 0 ----------------------]
- [ 3 ]
- [ hx ]
- [ ]
- [ 3 3 3 ]
- [ - 16*sin(ax) *c *ht *i ]
- [------------------------- 0 ]
- [ 3 ]
- [ hx ]
- clear a,b,bt;
- %***********************************************************************
- % Example M.3: Mazurik: Algoritmy resenia zadaci..., preprint no.24-85,
- % AN USSR SO, Inst. teor. i prikl. mechaniky, p.34
- operator v1,v2;
- matrix a(1,3),b(3,3),bt(3,3);
- a(1,1):=(p(n+1)-p(n))/ht+c/2*((-p(m-1)+2*p(m)-p(m+1))/hx +
- (v1(m+1)-v1(m-1))/hx - (p(k-1)-2*p(k)+p(k+1))/hy +
- (v2(k+1)-v2(k-1))/hy)$
- a(1,2):=(v1(n+1)-v1(n))/ht+c/2*((p(m+1)-p(m-1))/hx -
- (v1(m-1)-2*v1(m)+v1(m+1))/hx)$
- a(1,3):=(v2(n+1)-v2(n))/ht + c/2*((p(k+1)-p(k-1))/hy -
- (v2(k-1)-2*v2(k)+v2(k+1))/hy)$
- coordinates t,x,y into n,m,k;
- functions p,v1,v2;
- for k:=1:3 do approx(a(1,k)=0);
- Difference scheme approximates differential equation
- df(p,t) + df(v1,x)*c + df(v2,y)*c=0
- with orders of approximation:
- 2
- ht
- hx
- hy
- Difference scheme approximates differential equation df(p,x)*c + df(v1,t)=0
- with orders of approximation:
- 2
- ht
- hx
- 1
- Difference scheme approximates differential equation df(p,y)*c + df(v2,t)=0
- with orders of approximation:
- 2
- ht
- 1
- hy
- grid uniform,t,x,y;
- unfunc p,v1,v2;
- hy:=hx;
- hy := hx
- off prfourmat;
- b:=ampmat a;
- ax := kx*hx
- ay := ky*hy
- cos(ax)*c*ht + cos(ay)*c*ht - 2*c*ht + hx - i*sin(ax)*c*ht
- b := mat((-------------------------------------------,-------------------,
- hx hx
- - i*sin(ay)*c*ht
- -------------------),
- hx
- - i*sin(ax)*c*ht cos(ax)*c*ht - c*ht + hx
- (-------------------,--------------------------,0),
- hx hx
- - i*sin(ay)*c*ht cos(ay)*c*ht - c*ht + hx
- (-------------------,0,--------------------------))
- hx hx
- pol:=charpol b;
- 3 3 2 2
- pol := (lam *hx + lam *hx *( - 2*cos(ax)*c*ht - 2*cos(ay)*c*ht + 4*c*ht - 3*hx)
- 2 2 2 2
- + lam*hx*(3*cos(ax)*cos(ay)*c *ht - 5*cos(ax)*c *ht
- 2 2
- + 4*cos(ax)*c*ht*hx - 5*cos(ay)*c *ht + 4*cos(ay)*c*ht*hx
- 2 2 2 3 3
- + 7*c *ht - 8*c*ht*hx + 3*hx ) + 4*cos(ax)*cos(ay)*c *ht
- 2 2 3 3 2 2
- - 3*cos(ax)*cos(ay)*c *ht *hx - 4*cos(ax)*c *ht + 5*cos(ax)*c *ht *hx
- 2 3 3 2 2
- - 2*cos(ax)*c*ht*hx - 4*cos(ay)*c *ht + 5*cos(ay)*c *ht *hx
- 2 3 3 2 2 2 3 3
- - 2*cos(ay)*c*ht*hx + 4*c *ht - 7*c *ht *hx + 4*c*ht*hx - hx )/hx
- let
- cos ax=cos ax2**2-sin ax2**2,
- cos ay=cos ay2**2-sin ay2**2,
- sin ax=2*sin ax2*cos ax2,
- sin ay=2*sin ay2*cos ay2,
- cos ax2**2=1-sin ax2**2,
- cos ay2**2=1-sin ay2**2,
- sin ax2=s1,
- sin ay2=s2,
- hx=c*ht/cap;
- factor lam;
- order s1,s2;
- pol:=troot1 pol;
- 2 2 3
- If 16*s1 *s2 *cap = 0 and 0
- = 0 , a root of the polynomial is equal to 1.
- 3 2 2 2
- pol := lam + lam *(4*s1 *cap + 4*s2 *cap - 3) + lam
- 2 2 2 2 2 2 2 2 2
- *(12*s1 *s2 *cap + 4*s1 *cap - 8*s1 *cap + 4*s2 *cap - 8*s2 *cap + 3)
- 2 2 3 2 2 2 2 2 2
- + 16*s1 *s2 *cap - 12*s1 *s2 *cap - 4*s1 *cap + 4*s1 *cap
- 2 2 2
- - 4*s2 *cap + 4*s2 *cap - 1
- clear cos ax,cos ay,sin ax,sin ay,cos ax2**2,cos ay2**2,sin ax2,sin ay2,
- hx,hy;
- pol:=hurw num pol;
- 3 2 2 3
- pol := 16*lam *s1 *s2 *cap
- 2 2 2 2 2 2 2 2
- + 8*lam *cap *( - 6*s1 *s2 *cap + 3*s1 *s2 + s1 + s2 ) + 16*lam*cap
- 2 2 2 2 2 2 2 2 2
- *(3*s1 *s2 *cap - 3*s1 *s2 *cap - s1 *cap + s1 - s2 *cap + s2 ) + 8*(
- 2 2 3 2 2 2 2 2 2 2 2
- - 2*s1 *s2 *cap + 3*s1 *s2 *cap + s1 *cap - 2*s1 *cap + s2 *cap
- 2
- - 2*s2 *cap + 1)
- hurwitzp pol;
- If we denote:
- 2 2 3
- (1) 16*s1 *s2 *cap > 0
- 2 2 2 2 2 2 2
- (2) 8*cap *( - 6*s1 *s2 *cap + 3*s1 *s2 + s1 + s2 ) > 0
- 2 2 2 2 2 2 2 2 2
- (3) 16*cap*(3*s1 *s2 *cap - 3*s1 *s2 *cap - s1 *cap + s1 - s2 *cap + s2 )
- > 0
- 2 2 3 2 2 2 2 2 2 2 2
- (4) 8*( - 2*s1 *s2 *cap + 3*s1 *s2 *cap + s1 *cap - 2*s1 *cap + s2 *cap
- 2
- - 2*s2 *cap + 1) > 0
- 2 2 2 2 2 2 2
- (5) 8*cap *( - 6*s1 *s2 *cap + 3*s1 *s2 + s1 + s2 ) > 0
- 3 4 4 3 4 4 2 4 4
- (6) 128*cap *( - 16*s1 *s2 *cap + 24*s1 *s2 *cap - 9*s1 *s2 *cap
- 4 2 2 4 2 4 2 4 4
- + 8*s1 *s2 *cap - 10*s1 *s2 *cap + 3*s1 *s2 - s1 *cap + s1
- 2 4 2 2 4 2 4 2 2
- + 8*s1 *s2 *cap - 10*s1 *s2 *cap + 3*s1 *s2 - 2*s1 *s2 *cap
- 2 2 4 4
- + s1 *s2 - s2 *cap + s2 ) > 0
- 3 6 6 6 6 6 5 6 6 4
- (7) 1024*cap *(32*s1 *s2 *cap - 96*s1 *s2 *cap + 90*s1 *s2 *cap
- 6 6 3 6 4 5 6 4 4
- - 27*s1 *s2 *cap - 32*s1 *s2 *cap + 100*s1 *s2 *cap
- 6 4 3 6 4 2 6 2 4
- - 93*s1 *s2 *cap + 27*s1 *s2 *cap + 10*s1 *s2 *cap
- 6 2 3 6 2 2 6 2 6 3
- - 31*s1 *s2 *cap + 26*s1 *s2 *cap - 6*s1 *s2 *cap - s1 *cap
- 6 2 6 4 6 5 4 6 4
- + 3*s1 *cap - 2*s1 *cap - 32*s1 *s2 *cap + 100*s1 *s2 *cap
- 4 6 3 4 6 2 4 4 4
- - 93*s1 *s2 *cap + 27*s1 *s2 *cap + 20*s1 *s2 *cap
- 4 4 3 4 4 2 4 4
- - 76*s1 *s2 *cap + 73*s1 *s2 *cap - 21*s1 *s2 *cap
- 4 2 3 4 2 2 4 2
- - 3*s1 *s2 *cap + 16*s1 *s2 *cap - 14*s1 *s2 *cap
- 4 2 4 4 2 6 4
- + 3*s1 *s2 - s1 *cap + s1 + 10*s1 *s2 *cap
- 2 6 3 2 6 2 2 6
- - 31*s1 *s2 *cap + 26*s1 *s2 *cap - 6*s1 *s2 *cap
- 2 4 3 2 4 2 2 4
- - 3*s1 *s2 *cap + 16*s1 *s2 *cap - 14*s1 *s2 *cap
- 2 4 2 2 2 2 6 3 6 2
- + 3*s1 *s2 - 2*s1 *s2 *cap + s1 *s2 - s2 *cap + 3*s2 *cap
- 6 4 4
- - 2*s2 *cap - s2 *cap + s2 ) > 0
- (c1) (1) AND (2) AND (4)
- (c2) (1) AND (3) AND (4)
- (d1) (5) AND (7)
- (d2) (6)
- Necessary and sufficient conditions are:
- ( (C1) OR (C2) ) AND ( (D1) OR (D2) )
- cond
- bt:=tcon b;
- cos(ax)*c*ht + cos(ay)*c*ht - 2*c*ht + hx sin(ax)*c*ht*i
- bt := mat((-------------------------------------------,----------------,
- hx hx
- sin(ay)*c*ht*i
- ----------------),
- hx
- sin(ax)*c*ht*i cos(ax)*c*ht - c*ht + hx
- (----------------,--------------------------,0),
- hx hx
- sin(ay)*c*ht*i cos(ay)*c*ht - c*ht + hx
- (----------------,0,--------------------------))
- hx hx
- bt*b;
- 2 2 2 2
- mat(((2*cos(ax)*cos(ay)*c *ht - 4*cos(ax)*c *ht + 2*cos(ax)*c*ht*hx
- 2 2 2 2 2 2
- - 4*cos(ay)*c *ht + 2*cos(ay)*c*ht*hx + 6*c *ht - 4*c*ht*hx + hx )/hx ,
- 2 2 2 2
- sin(ax)*c *ht *i*( - cos(ay) + 1) sin(ay)*c *ht *i*( - cos(ax) + 1)
- -----------------------------------,-----------------------------------),
- 2 2
- hx hx
- 2 2
- sin(ax)*c *ht *i*(cos(ay) - 1)
- (--------------------------------,
- 2
- hx
- 2 2 2 2 2
- - 2*cos(ax)*c *ht + 2*cos(ax)*c*ht*hx + 2*c *ht - 2*c*ht*hx + hx
- ----------------------------------------------------------------------,
- 2
- hx
- 2 2
- sin(ax)*sin(ay)*c *ht
- ------------------------),
- 2
- hx
- 2 2 2 2
- sin(ay)*c *ht *i*(cos(ax) - 1) sin(ax)*sin(ay)*c *ht
- (--------------------------------,------------------------,
- 2 2
- hx hx
- 2 2 2 2 2
- - 2*cos(ay)*c *ht + 2*cos(ay)*c*ht*hx + 2*c *ht - 2*c*ht*hx + hx
- ----------------------------------------------------------------------))
- 2
- hx
- bt*b-b*bt;
- 2 2
- 2*sin(ax)*c *ht *i*( - cos(ay) + 1)
- mat((0,-------------------------------------,
- 2
- hx
- 2 2
- 2*sin(ay)*c *ht *i*( - cos(ax) + 1)
- -------------------------------------),
- 2
- hx
- 2 2
- 2*sin(ax)*c *ht *i*(cos(ay) - 1)
- (----------------------------------,0,0),
- 2
- hx
- 2 2
- 2*sin(ay)*c *ht *i*(cos(ax) - 1)
- (----------------------------------,0,0))
- 2
- hx
- clear a,b,bt,pol;
- %***********************************************************************
- end;
- Time for test: 22393 ms
|