matrix – Nonlinear differential system coupled with discontinuous functions whose values ​​are given by list elements, boundary conditions, NDSolve

enter description of image here
I am very new to math, I searched my problem on Google to no avail, I hope you can help me.
I am currently trying to solve a nonlinear system of two coupled differential equations given by (41) and (42). All variables depend on k (alpha, theta, xhi, phi, as well as matrix elements A11, A22, A12 and A21). Eta is a fixed arbitrary parameter.

I started by calculating all the elements of the matrix for k in a certain range (say k0 to k1) with step s = (k1-k0) / N. so that I have N matrices 2×2 A (k0), A (k0 + s) … A (k1).

My problem is that when I define my equation system on mathematical as well as the following boundary conditions on alpha (alpha (k0) == pi / 8; alpha (k1) == pi / 8) (and none on theta because i don't care at the moment: this is a free setting), i always get an error message which is basically related to the fact that when K varies in the NDSOLVE problem , elements of the matrix are not retrieved, instead of getting something like A12 (k) I get something like A12 ($ NDSOLVE1245845) which is not a valid part specification for a list.

I have tried to summarize my problem as I understand it, but here is the code if you want to try it yourself.

I copied my math notebook here, I give you the A matrices at the start, it is not very nice so I can send the notebook directly if anyone wants.

 (*Here is a list of lists called aMat, each element 
aMat((k)) corresponds to one of the matrices 2x2 A(k) matrix in the 
equations, the process leading to aMat is kinda long so I do not post 
it here!  *)

Nsite = 51;
etad = (Pi)/4;
d = 532*10^-9;

 aMat = {{{8.033808200646101`*^-21 + 
      1.0195947261614721`*^-7 I, -2.259193402732543`*^-14 + 
      5.6606425073577124`*^-8 I}, {-5.579587617378922`*^-14 - 
      1.3979370715909291`*^-7 I, -2.6939288474872005`*^-18 - 
      1.1360855346370705`*^-7 I}}, {{4.920008417679118`*^-21 + 
      2.864988207444914`*^-7 I, 
     6.448591285746703`*^-14 + 
      1.615615344995959`*^-7 I}, {-2.626485508352081`*^-19 - 
      6.4559205290202805`*^-9 I, 
     4.02818142522391`*^-15 + 
      1.0091758074619052`*^-8 I}}, {{9.701612357018`*^-21 + 
      2.8808758498493`*^-7 I, 
     4.941191381151055`*^-18 + 
      1.5994433204297324`*^-7 I}, {-2.612213198258168`*^-19 - 
      1.2747464222971996`*^-8 I, 
     7.580144893918093`*^-19 + 
      1.9940869401651616`*^-8 I}}, {{1.4215083632434476`*^-20 + 
      2.9067525276121966`*^-7 I, 
     2.769500855905615`*^-18 + 
      1.5731234585782317`*^-7 I}, {-2.588987808569906`*^-19 - 
      1.871924893424333`*^-8 I, 
     6.580740142263754`*^-19 + 
      2.9316926956117847`*^-8 I}}, {{1.8346598707244687`*^-20 + 
      2.94176405812251`*^-7 I, 
     1.9604382654454056`*^-18 + 
      1.5375525696154838`*^-7 I}, {-2.5576628331274985`*^-19 - 
      2.423282541976617`*^-8 I, 
     6.265767976797439`*^-19 + 
      3.8012641902104256`*^-8 I}}, {{2.200384369841378`*^-20 + 
      2.984806514429946`*^-7 I, 
     1.523813781806201`*^-18 + 
      1.493887717289512`*^-7 I}, {-2.5193244339608564`*^-19 - 
      2.9172715176654585`*^-8 I, 
     6.095502396476031`*^-19 + 
      4.585226440947448`*^-8 I}}, {{2.5119152956265407`*^-20 + 
      3.0346017235825585`*^-7 I, 
     1.247497168319565`*^-18 + 
      1.443465362831549`*^-7 I}, {-2.4753336539568484`*^-19 - 
      3.345006505614873`*^-8 I, 
     5.9721585438584`*^-19 + 
      5.269690247822571`*^-8 I}}, {{2.7650213281433854`*^-20 + 
      3.0897752252144107`*^-7 I, 
     1.0566155606811343`*^-18 + 
      1.3877179229760157`*^-7 I}, {-2.426853865088762`*^-19 - 
      3.700384427991734`*^-8 I, 
     5.867343436946562`*^-19 + 
      5.844660952900648`*^-8 I}}, {{2.9578655420869275`*^-20 + 
      3.148928398202045`*^-7 I, 
     9.172964717301432`*^-19 + 
      1.328096678093049`*^-7 I}, {-2.375378134195755`*^-19 - 
      3.979986495755983`*^-8 I, 
     5.770644027762974`*^-19 + 
      6.303956594952819`*^-8 I}}, {{3.090708773872836`*^-20 + 
      3.210698904499792`*^-7 I, 
     8.121591406248909`*^-19 + 
      1.2660073581881407`*^-7 I}, {-2.32199340437251`*^-19 - 
      4.182814287649467`*^-8 I, 
     5.678643893447754`*^-19 + 
      6.644898914789824`*^-8 I}}, {{3.165520994795495`*^-20 + 
      3.2738064259815684`*^-7 I, 
     7.311146538100815`*^-19 + 
      1.2027616963291322`*^-7 I}, {-2.268068980986546`*^-19 - 
      4.3099210077193304`*^-8 I, 
     5.59006120501795`*^-19 + 
      6.867854226800027`*^-8 I}}, {{3.185560132672103`*^-20 + 
      3.3370832173128694`*^-7 I, 
     6.681804660377018`*^-19 + 
      1.1395454856529243`*^-7 I}, {-2.2145281297650666`*^-19 - 
      4.363996434159545`*^-8 I, 
     5.505167839307502`*^-19 + 
      6.975699420756697`*^-8 I}}, {{3.1549654442220284`*^-20 + 
      3.399490870570553`*^-7 I, 
     6.194946126444731`*^-19 + 
      1.0774016379153097`*^-7 I}, {-2.162334268759257`*^-19 - 
      4.348953406727124`*^-8 I, 
     5.424303799691056`*^-19 + 
      6.973276185751127`*^-8 I}}, {{3.072979637965408`*^-20 + 
      3.460125773063581`*^-7 I, 
     5.826703023850006`*^-19 + 
      1.0172255486431532`*^-7 I}, {-2.1121053091407048`*^-19 - 
      4.2695495500116656`*^-8 I, 
     5.348145787220257`*^-19 + 
      6.866879461775877`*^-8 I}}, {{2.9583840885090626`*^-20 + 
      3.51821613085182`*^-7 I, 
     5.562736834605877`*^-19 + 
      9.597696338490143`*^-8 I}, {-2.0646443809917233`*^-19 - 
      4.131063934935675`*^-8 I, 
     5.277372434606911`*^-19 + 
      6.663808654963002`*^-8 I}}, {{2.8044775908692463`*^-20 + 
      3.5731133206229025`*^-7 I, 
     5.397324217219753`*^-19 + 
      9.056540111771756`*^-8 I}, {-2.0200689167033389`*^-19 - 
      3.939036686209166`*^-8 I, 
     5.212818970912487`*^-19 + 
      6.371995170785319`*^-8 I}}, {{2.6247451780140498`*^-20 + 
      3.6242799318184524`*^-7 I, 
     5.331247036562746`*^-19 + 
      8.553807289819507`*^-8 I}, {-1.9791340461962209`*^-19 - 
      3.699071121991565`*^-8 I, 
     5.15548745722521`*^-19 + 
      5.999708615932234`*^-8 I}}, {{2.4090528817032664`*^-20 + 
      3.6712763421650144`*^-7 I, 
     5.375201785758898`*^-19 + 
      8.093495114976781`*^-8 I}, {-1.9417830755396824`*^-19 - 
      3.4166927276595516`*^-8 I, 
     5.106517303262318`*^-19 + 
      5.5553366763549385`*^-8 I}}, {{2.1736332854480823`*^-20 + 
      3.7137471524357817`*^-7 I, 
     5.552884482597155`*^-19 + 
      7.678735560534001`*^-8 I}, {-1.9083153269163605`*^-19 - 
      3.097256626088577`*^-8 I, 
     5.067908381052614`*^-19 + 
      5.047229628922304`*^-8 I}}, {{1.918972443974762`*^-20 + 
      3.751408356668874`*^-7 I, 
     5.908999847273977`*^-19 + 
      7.311944143641007`*^-8 I}, {-1.8789836409047963`*^-19 - 
      2.745894444955685`*^-8 I, 
     5.042625743532527`*^-19 + 
      4.483598845297464`*^-8 I}}, {{1.6484488934489734`*^-20 + 
      3.784035769353109`*^-7 I, 
     6.531992545271056`*^-19 + 
      6.994953833221866`*^-8 I}, {-1.8537189059701642`*^-19 - 
      2.3674918938353474`*^-8 I, 
     5.036732002915816`*^-19 + 
      3.872458668850092`*^-8 I}}, {{1.3651087345306606`*^-20 + 
      3.81145497297622`*^-7 I, 
     7.607243135375442`*^-19 + 
      6.72913118158307`*^-8 I}, {-1.8326259355206506`*^-19 - 
      1.9666894588395473`*^-8 I, 
     5.063833558236244`*^-19 + 
      3.221602008658648`*^-8 I}}, {{1.071702867170963`*^-20 + 
      3.833532875741768`*^-7 I, 
     9.597905062862139`*^-19 + 
      6.515473744661214`*^-8 I}, {-1.8157473867785008`*^-19 - 
      1.5478999238071165`*^-8 I, 
     5.162604364852125`*^-19 + 
      2.538601387320923`*^-8 I}}, {{7.70733053769387`*^-21 + 
      3.85017086373458`*^-7 I, 
     1.4104236563210386`*^-18 + 
      6.35468903630958`*^-8 I}, {-1.803060954271949`*^-19 - 
      1.1153377614241531`*^-8 I, 
     5.487471866782634`*^-19 + 
      1.8308286752025182`*^-8 I}}, {{4.6450348089588645`*^-21 + 
      3.861299476885155`*^-7 I, 
     3.45777828374654`*^-18 + 
      6.247255872771278`*^-8 I}, {-1.7946103885000363`*^-19 - 
      6.730566203934185`*^-9 I, 
     7.543375479191052`*^-19 + 
      1.1054881348791118`*^-8 I}}, {{1.5517555266936961`*^-21 + 
      3.866874519217884`*^-7 I, 
     1.894536140693539`*^-18 - 
      6.193469167651351`*^-8 I}, {-1.7903838116380825`*^-19 - 
      2.249921164821364`*^-9 I, -2.9423700996263846`*^-20 - 
      3.696585844110595`*^-9 I}}, {{-1.5637272016006697`*^-21 + 
      3.866874519218525`*^-7 I, -1.8945280793554763`*^-18 - 
      6.193469167662479`*^-8 I}, {1.790388518851441`*^-19 - 
      2.2499211668119864`*^-9 I, 
     2.942484092397458`*^-20 - 
      3.6965858435714946`*^-9 I}}, {{-4.742174432805856`*^-21 + 
      3.861299476885976`*^-7 I, -3.457798716561031`*^-18 + 
      6.247255872778867`*^-8 I}, {1.794622002239326`*^-19 - 
      6.730566202745649`*^-9 I, -7.543402900929096`*^-19 + 
      1.105488134876665`*^-8 I}}, {{-7.804190196500871`*^-21 + 
      3.850170863734963`*^-7 I, -1.41042949354795`*^-18 + 
      6.354689036299113`*^-8 I}, {1.8030775562086866`*^-19 - 
      1.1153377613396663`*^-8 I, -5.487469877992032`*^-19 + 
      1.830828675237706`*^-8 I}}, {{-1.072217587355892`*^-20 + 
      3.833532875741192`*^-7 I, -9.597948862826747`*^-19 + 
      6.515473744655095`*^-8 I}, {1.815736973880872`*^-19 - 
      1.547899923794939`*^-8 I, -5.162600944513975`*^-19 + 
      2.5386013873208913`*^-8 I}}, {{-1.355788229112468`*^-20 + 
      3.811454972975411`*^-7 I, -7.60714470754315`*^-19 + 
      6.729131181592481`*^-8 I}, {1.8326086245605312`*^-19 - 
      1.9666894589467598`*^-8 I, -5.063836859354622`*^-19 + 
      3.221602008635054`*^-8 I}}, {{-1.6414597680533996`*^-20 + 
      3.7840357693517435`*^-7 I, -6.531898766876434`*^-19 + 
      6.99495383323809`*^-8 I}, {1.8537175483580718`*^-19 - 
      2.367491893831529`*^-8 I, -5.036749390236897`*^-19 + 
      3.8724586688078445`*^-8 I}}, {{-1.921725421279006`*^-20 + 
      3.751408356667764`*^-7 I, -5.909171207125913`*^-19 + 
      7.31194414365596`*^-8 I}, {1.878974717179978`*^-19 - 
      2.7458944450273424`*^-8 I, -5.04268334534577`*^-19 + 
      4.483598845268152`*^-8 I}}, {{-2.1777458316409858`*^-20 + 
      3.7137471524352475`*^-7 I, -5.552957621470693`*^-19 + 
      7.678735560547088`*^-8 I}, {1.9083440519447586`*^-19 - 
      3.0972566261077335`*^-8 I, -5.067947372672451`*^-19 + 
      5.0472296289018394`*^-8 I}}, {{-2.4168302854081965`*^-20 + 
      3.6712763421628677`*^-7 I, -5.375185227215908`*^-19 + 
      8.093495114988769`*^-8 I}, {1.9418863411275705`*^-19 - 
      3.4166927275981066`*^-8 I, -5.106556154321534`*^-19 + 
      5.5553366763138164`*^-8 I}}, {{-2.632817352120827`*^-20 + 
      3.624279931815362`*^-7 I, -5.331568308207647`*^-19 + 
      8.55380728985272`*^-8 I}, {1.9791371594348603`*^-19 - 
      3.6990711221359786`*^-8 I, -5.155584220640963`*^-19 + 
      5.999708615869976`*^-8 I}}, {{-2.818109962336356`*^-20 + 
      3.5731133206196647`*^-7 I, -5.397246617010634`*^-19 + 
      9.05654011181913`*^-8 I}, {2.0202438086576516`*^-19 - 
      3.939036686264893`*^-8 I, -5.21280417895509`*^-19 + 
      6.3719951707024`*^-8 I}}, {{-2.9586895515665964`*^-20 + 
      3.5182161308500464`*^-7 I, -5.562991385562087`*^-19 + 
      9.597696338517826`*^-8 I}, {2.0645434923365562`*^-19 - 
      4.131063934951449`*^-8 I, -5.277380643708293`*^-19 + 
      6.663808654914656`*^-8 I}}, {{-3.0676690533857427`*^-20 + 
      3.4601257730656186`*^-7 I, -5.826255321520116`*^-19 + 
      1.0172255486428117`*^-7 I}, {2.1121226387071561`*^-19 - 
      4.2695495500631116`*^-8 I, -5.347976825781128`*^-19 + 
      6.866879461805875`*^-8 I}}, {{-3.1413633840733296`*^-20 + 
      3.399490870573189`*^-7 I, -6.194822088499933`*^-19 + 
      1.0774016379118343`*^-7 I}, {2.1621455849783666`*^-19 - 
      4.348953406570069`*^-8 I, -5.424199991009962`*^-19 + 
      6.973276185810851`*^-8 I}}, {{-3.176580420118423`*^-20 + 
      3.337083217314582`*^-7 I, -6.6816170131315625`*^-19 + 
      1.1395454856494644`*^-7 I}, {2.2144503793694587`*^-19 - 
      4.363996434169416`*^-8 I, -5.505116398374329`*^-19 + 
      6.975699420819069`*^-8 I}}, {{-3.158091513129204`*^-20 + 
      3.273806425978735`*^-7 I, -7.311116952049515`*^-19 + 
      1.20276169633033`*^-7 I}, {2.268030718650996`*^-19 - 
      4.30992100768835`*^-8 I, -5.590139197241613`*^-19 + 
      6.867854226744586`*^-8 I}}, {{-3.084553118990792`*^-20 + 
      3.2106989044961364`*^-7 I, -8.121317943872537`*^-19 + 
      1.2660073581925464`*^-7 I}, {2.3219598122734736`*^-19 - 
      4.182814287779874`*^-8 I, -5.678574394024991`*^-19 + 
      6.64489891468643`*^-8 I}}, {{-2.9586960811889886`*^-20 + 
      3.148928398201589`*^-7 I, -9.172923860730165`*^-19 + 
      1.3280966780965467`*^-7 I}, {2.375323980492081`*^-19 - 
      3.9799864958056516`*^-8 I, -5.770522232961653`*^-19 + 
      6.30395659489623`*^-8 I}}, {{-2.773639454812924`*^-20 + 
      3.089775225213917`*^-7 I, -1.0565548046853918`*^-18 + 
      1.3877179229758124`*^-7 I}, {2.4268947069842577`*^-19 - 
      3.70038442782392`*^-8 I, -5.866989037626828`*^-19 + 
      5.844660952881337`*^-8 I}}, {{-2.5219765064266593`*^-20 + 
      3.0346017235835437`*^-7 I, -1.2475239204315625`*^-18 + 
      1.4434653628306901`*^-7 I}, {2.475259145231046`*^-19 - 
      3.345006505766175`*^-8 I, -5.97196411162458`*^-19 + 
      5.269690247871184`*^-8 I}}, {{-2.201120865499778`*^-20 + 
      2.984806514432385`*^-7 I, -1.523749426424153`*^-18 + 
      1.49388771728884`*^-7 I}, {2.5193381479359126`*^-19 - 
      2.9172715176301558`*^-8 I, -6.095315110032011`*^-19 + 
      4.585226441016985`*^-8 I}}, {{-1.8296693643235808`*^-20 + 
      2.9417640581247653`*^-7 I, -1.960411302002763`*^-18 + 
      1.537552569612602`*^-7 I}, {2.5576456729892`*^-19 - 
      2.4232825419138733`*^-8 I, -6.265738883668753`*^-19 + 
      3.80126419035277`*^-8 I}}, {{-1.4165772515444426`*^-20 + 
      2.906752527612242`*^-7 I, -2.7694897162441683`*^-18 + 
      1.5731234585759723`*^-7 I}, {2.5889508004545654`*^-19 - 
      1.871924893406248`*^-8 I, -6.580711156897425`*^-19 + 
      2.9316926956975514`*^-8 I}}, {{-9.677807805559877`*^-21 + 
      2.8808758498495014`*^-7 I, -4.9411868928239335`*^-18 + 
      1.5994433204294002`*^-7 I}, {2.612202665348913`*^-19 - 
      1.2747464224024206`*^-8 I, -7.580139298539908`*^-19 + 
      1.9940869402047568`*^-8 I}}, {{-4.89633514500996`*^-21 + 
      2.8649882074453543`*^-7 I, -6.44858048312444`*^-14 + 
      1.615615344996214`*^-7 I}, {2.626485507944989`*^-19 - 
      6.455920528462238`*^-9 I, -4.0281746783825426`*^-15 + 
      1.0091758074771626`*^-8 I}}, {{-8.02538333405992`*^-21 + 
      1.0195947261628438`*^-7 I, 
     2.2591971871808648`*^-14 + 
      5.660642507341513`*^-8 I}, {5.5795782702384586`*^-14 - 
      1.3979370715915536`*^-7 I, 
     2.5420215571980736`*^-18 - 1.136085534636542`*^-7 I}}};

 aMat((52))(*2x2 matrix*)

Out(24)= {{-8.02538*10^-21 + 1.01959*10^-7 I, 
  2.2592*10^-14 + 5.66064*10^-8 I}, {5.57958*10^-14 - 1.39794*10^-7 I,
   2.54202*10^-18 - 1.13609*10^-7 I}}

 aMat((1))(*2x2 matrix*)

Out(5)= {{8.03381*10^-21 + 1.01959*10^-7 I, -2.25919*10^-14 + 
   5.66064*10^-8 I}, {-5.57959*10^-14 - 
   1.39794*10^-7 I, -2.69393*10^-18 - 1.13609*10^-7 I}}

(*I define my equations here, notice that I call 
aMat((Round(((d*k/(Pi)+1)*Nsite)/2+1)), that is because in NDSolve k 
varies between -(Pi)/d to (Pi)/d, this function gives the 
corresponding matrix element, for example (Pi)/d will give 52, 
already here the definitionf of eqn1 and eqn2 gives an error !!!*)

 eqn1 = 
  a'(k)/2 == -(Cos(2 t(k))/
      Sin(t(k)))*(Re(
         aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 2))) Cos(
         etad) + Im(
         aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 2))) Sin(
         etad)) - 
    1/(Tan(a(k)/2) Tan(
       t(k)))*(Re(
         aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 2))) Sin(
         etad) - Im(
         aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 2))) Cos(
         etad)) + 
    Cos(t(k)) (aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 1)) - 
       aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((2, 2)));


 eqn2 = 
  t'(k)/2 == (Cos(t(k)) Sin(a(k)))/
     Sin(a(k)/
      2)^2*(Re(
         aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 2))) Cos(
         etad) + Im(
         aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 2))) Sin(
         etad)) - 
    Cos(a(k))/
     Sin(a(k)/
      2)^2*(Re(
         aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 2))) Sin(
         etad) - Im(
         aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 2))) Cos(
         etad)) + 
    1/Tan(a(k)/2) Sin(
      t(k))*(aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((1, 1)) - 
       aMat((Round(((d*k/(Pi) + 1)*Nsite)/2 + 1)))((2, 2)));


(*boundary conditions*)

 eqn = {eqn1, eqn2};

 bcs = {a(-(Pi)/d) == (Pi)/8, a((Pi)/d) == (Pi)/8};


 system = Join(eqn, bcs);
sol = NDSolve(system, a, {k, -(Pi)/d, (Pi)/d});

And the error log (the first message up to part :: partw: part 2 of the round (1 + 51/2 (1+ (133 k) / (250000000 (Pi)))) The messages are due to the definition of eqn1 and eqn2, basically k is not a number … the last message comes from NDSOLVE):

Part::pkspec1: The expression Round(1+51/2 (1+(133 k)/(250000000 (Pi)))) cannot be used as a part specification.

Part::pkspec1: The expression Round(1+51/2 (1+(133 k)/(250000000 (Pi)))) cannot be used as a part specification.

Part::pkspec1: The expression Round(1+51/2 (1+(133 k)/(250000000 (Pi)))) cannot be used as a part specification.

General::stop: Further output of Part::pkspec1 will be suppressed during this calculation.

Part::partw: Part 2 of Round(1+51/2 (1+(133 k)/(250000000 (Pi)))) does not exist.

Part::pkspec1: The expression Round(1+51/2 (1+(133 k)/(250000000 (Pi)))) cannot be used as a part specification.

Part::pkspec1: The expression Round(1+51/2 (1+(133 k)/(250000000 (Pi)))) cannot be used as a part specification.

Part::pkspec1: The expression Round(1+51/2 (1+(133 k)/(250000000 (Pi)))) cannot be used as a part specification.

General::stop: Further output of Part::pkspec1 will be suppressed during this calculation.

Part::partw: Part 2 of Round(1+51/2 (1+(133 k)/(250000000 (Pi)))) does not exist.

NDSolve::bvdisc: NDSolve is not currently able to solve boundary value problems with discrete variables.

You will notice that this is not the error message which I have complained about, it is because I have removed the problem from all superfluous parameters, it is the basic error message, it seems related to the fact that function A is discontinuous; I don't see why this should be a problem, especially since this type of algorithm is based on discretization methods (?).

As a clarification, in my problem k is in fact discrete it goes from -pi / d to pi / d in step 2pi / (N * d), where d is a certain distance, and N an arbitrary number ….

I'm fed up with this, I thought it would be simple, thank you for any help you can give. Since I am new to math and solving equations, I would also appreciate reporting bad practices (with the exception of the aMat definition of course) and pointers to method options from NDSOLVE (I've tried a few random types). Thank you very much, of course, if you can solve the equations in another way, don't hesitate to share your solution!

Runge-Kutta on coupled equations – Mathematica Stack Exchange

cpb = 15(*J/gK*); h = 1;
Mb = PB0/(Rsh2 Tu(ruf)) (4/3 (Pi)) rb0^3;
C0 = (3 Mb Rsh2)/(4 (Pi));

func = {Fb(t) == 
        Integrate((4 (Pi) r(Prime)^2 (Dt(Pu(r, (CapitalOmega)0), r) + 
               Pu(r, (CapitalOmega)0)/r) /. (r -> Rb(t) + r(Prime))) // 
          FullSimplify, {r(Prime), 0, rb(t)}, 
         Assumptions -> Element({Rb(t), rb(t)}, Reals)),
       Pb(t) == (C0 Tb(t))/(rb(t))^3,
       (Rho)b(t) == Pb(t)/(Rsh2 Tb(t)),
       Rb''(t) == -(Fb(t)/Mb),
       rb(t) == (2 (Sigma))/(Pb(t) - Pu(Rb(t), (CapitalOmega)0)),
       Pb'(t) == (4 (Pi) h Rsh2)/cpb (Tu(Rb(t)) - Tb(t)) (rb(t))^2};

yinit = {Pb(0) == PB0, Tb(0) == Tu(ruf), Rb(0) == ruf, rb(0) == rb0, 
       Rb'(0) == 0, rb'(0) == 0, Rb''(0) == 0};

y = {Fb(t), Pb(t), (Rho)b(t), Tb(t), Rb(t), rb(t)};

tf = 0.010;
tstep = 0.001;
sol = NDSolve(Join(func, yinit), y, {t, 0, tf}, Method -> CRK4, 
  StartingStepSize -> tstep)

I'm still fairly new to Mathematica and I have a few problems solving these coupled equations, I came across a few different answers here that I tried to implement, but I haven't yet was lucky. Any suggestions would be greatly appreciated.

Thank you

PDE equation coupled or boundary condition creating a singularity problem

Previous article: Use of NDSolve and PieceWise for the boundary conditions of coupled PDEs

I realize that my previous post was very vague, so I hope this post clears up any confusion. I have looked at the code more closely and I am much closer to getting a solution. Currently, the problem I am facing is that I have 4 PDEs that I want to solve to use NDSolve:

pumpIntEqnF = -D(IPF(z, t), z) - (n/c) D(IPF(z, t), t) - 
  gP IPF(z, t)*(IS1F(z, t) (*+ IS1B(z,t)*)) - alphaP IPF(z, t)
pumpIntEqnB = 
 D(IPB(z, t), z) - (n/c) D(IPB(z, t), t) - 
  gP IPB(z, t) (IS1F(z, t) (*+ IS1B(z,t)*)) - alphaP IPB(z, t)
firStoEqnF = -D(IS1F(z, t), z) - (n/c) D(IS1F(z, t), t) + 
  gS1 IS1F(z, t) (IPF(z, t) + IPB(z, t)) - alphaS1 IS1F(z, t) + 
  sigmaSP (IPF(z, t) + IPB(z, t))
firStoEqnB = 
 D(IS1B(z, t), z) - (n/c) D(IS1B(z, t), t) + 
  gS1 IS1B(z, t) (IPF(z, t) + IPB(z, t)) - alphaS1 IS1B(z, t) + 
  sigmaSP (IPF(z, t) + IPB(z, t))

However, each time I run the code to resolve in NDSolve:

solIntEqn = 
 NDSolve({pumpIntEqnF == 0, pumpIntEqnB == 0, firStoEqnF == 0, 
   firStoEqnB == 0,
   IPF(0, t) == PumpPeak*Exp(-0.5 ((t - toffset)/twidth)^2), 
   IPB(lR, t) == IPF(lR, t) ROCP, IS1F(0, t) == IS1B(0, t) RICS1, 
   IS1B(lR, t) == IS1F(lR, t) ROCS1,
   IPB(z, 0) == PumpPeak*Exp(-0.5 ((-toffset)/twidth)^2), 
   IPF(z, 0) == PumpPeak*Exp(-0.5 ((-toffset)/twidth)^2), 
   IS1F(z, 0) ==  0, IS1B(z, 0) ==  0},
  {IPF, IPB, IS1F, IS1B}, {t, 0, 20}, {z, 0, lR}, 
  MaxSteps -> Infinity, PrecisionGoal -> 2, AccuracyGoal -> 50, 
  Method -> {"MethodOfLines", 
    "SpatialDiscretization" -> {"TensorProductGrid", 
      "MinPoints" -> ppR, "MaxPoints" -> ppR, "DifferenceOrder" -> 2},
     Method -> {"Adams", "MaxDifferenceOrder" -> 1}})

I get the error:

NDSolve :: ndsz: At t == 1.7666146472527202`, the step size is effectively zero; suspicion of singularity or stiffness.

My question is how to fix this problem?

Settings:

ROCP = 1;
RICP = 0;
ROCS1 = 0.5;
RICS1 = 1;
L = 5 10^-2;
n = 1.556;
c = 30;
lR = 3;
R1 = 0.99;

gP = 20;
gS1 = 20;
sigmaSP = 10^-13;

toffset = 10;
twidth = 10;
Energy = 1.3 10^-4;
rad = 0.015;
PumpInt = ((Energy)/(twidth))/(Pi rad^2) ;
PumpPeak = Exp(0.5 ((-toffset)/(twidth))^2) PumpInt;

lc = n lR;
alphaP = 0 L/(2 lc)
alphaS1 = 0 (L - Log(R1))/(2 lc)

tmax = 20;
ppR = 90;

My attempts to resolve the problem

After many attempts to resolve this problem, I discovered that changing the boundary condition:

IS1F(0, t) == IS1B(0, t) RICS1

at:

IS1F(0, t) == 0

I get what I think is the right solution, but the boundary condition I replace is important because it means that IS1F is generated when IS1B hits the starting "wall".

In addition, I took a closer look at my problem and discovered that the omission of the fourth PDE and the setting IS1B (z, t) = 0 (i.e. only the resolution for IPF, IPB and IS1F) gives me a reasonable answer, which strongly suggests that IS1B (z, t) is the source of the problem.

Is there a general solution to this system of first order coupled nonlinear differential equations related to enzyme kinetics

In an irreversible enzyme kinetics system for binary bond reactions, we often come across a system of form equations

$$ frac {dc_i} {dt} = sum_ {j} sum_ {k} beta_ {ijk} c_jc_k $$

or $ c_i $ is the concentration of species or complexes $ i $ and $ beta_ {ijk} $ is the activation rate for cash $ j $ and cash $ k $ stick together to form species $ i $ (when $ i neq j $ and $ i neq k $, in which case $ beta_ {ijk} geq 0 $) or, in the event that $ i = j $, then we would have the activation rate for $ i $ stick to $ k $ and the formation of other species, in which case $ beta_ {iik} leq 0 $. Note the current retention rule, where

$$ beta_ {iik} = – sum_ {j neq i} beta_ {ijk} $$

and $ beta_ {iii} equiv 0 $.

Does this system have a general analytical solution and what approaches could we adopt to try to find it?

Solution of coupled differential equations

I was wondering if someone could help me solve the following two coupled differential equations …
$$ Delta u _ {, xx} = d ; w _ {, xxx} + frac {K} {EA} Delta u \ $$
$$ – EI_ infty ; w _ {, xxxx} + 2d ; EA ; Delta u _ {, xxx} + q = 0 $$

i tried the next step in Mathematica

DSolve({-EIinf w''''(x) + 2 d EA du'''(x) + q(x) == 0, du''(x) == d w'''(x) + K/EA du(x)}, {du, w}, x)

I also tried to add the boundary conditions to the DSolve function but it didn't work either.
The evaluation continues "forever" which I have to give up after a while.

FYI: I have the following boundary conditions:

w(0)==0 | w(l)==0 | w''(0)==0 | w''(l)==0 | w''''(0)==q(0)/(EI0) | w''''(l)==q(l)/(EI0) | du'(0)==0 | du'(l)==0 

If I transfer the two differential equations to a 6th order DE, I get an analytical solution. Why is this not the case if I solve the two equations simultaneously? Thanks in advance!

differential equations – Use of NDSolve and PieceWise for the boundary conditions of coupled PDEs

I decided to try using PieceWise in my boundary conditions for my 4 paired PDEs, but it doesn't seem to be working properly. I get the error:

NDSolve :: overdet: There are less dependent variables, {IPB (z, t), IPF (z, t), IS1B (z, t), IS1F (z, t)}, than equations, therefore the system is overdetermined.

Settings:

ROCP = 1;
RICP = 0;
ROCS1 = 0.5;
RICS1 = 1;
L = 5 10^-2;
n = 1.556;
c = 3 10^10;
lR = 3;
R1 = 0.99;

gP = 20;
gS1 = 20;
sigmaSP = 10^-13;

toffset = 5 10^-9;
twidth = 10 10^-9;
Energy = 1.3 10^-13;
rad = 0.015;
PumpInt = ((Energy)/(twidth ))/(Pi rad^2) ;
PumpPeak = Exp(0.5 ((-toffset)/(twidth))^2) PumpInt;

lc = n lR;
alphaP = L/(2 lc);
alphaS1 = (L - Log(R1))/(2 lc);

tmax = 20 10^-9;

The 4 PDEs that I solve are:

PDE = {D(IPF(z, t), z) == -(n/c) D(IPF(z, t), t) - 
     gP IPF(z, t)*(IS1F(z, t) + IS1B(z, t)) - alphaP IPF(z, t),
   -D(IPB(z, t), z) == -(n/c) D(IPB(z, t), t) - 
     gP IPB(z, t) (IS1F(z, t) + IS1B(z, t)) - alphaP IPB(z, t),
   D(IS1F(z, t), z) == -(n/c) D(IS1F(z, t), t) + 
     gS1 IS1F(z, t) (IPF(z, t) + IPB(z, t)) - alphaS1 IS1F(z, t) + 
     sigmaSP (IPF(z, t) + IPB(z, t)),
   -D(IS1B(z, t), z) == -(n/c) D(IS1B(z, t), t) + 
     gS1 IS1B(z, t) (IPF(z, t) + IPB(z, t)) - alphaS1 IS1B(z, t) + 
     sigmaSP (IPF(z, t) + IPB(z, t))};

And the boundary conditions are:

BC = {IPF(z, t) == 
    PieceWise({{PumpPeak*Exp(-0.5 ((t - toffset)/twidth)^2), 
       z == 0 && t > 0}, {0, 0 <= z <= lR && t == 0}}),
   IPB(z, 0) == 0, IPB(lR, t) == IPF(lR, t) ROCP,
   IS1F(0, t) == IS1B(0, t) RICS1, IS1B(lR, t) == IS1F(lR, t) ROCS1, 
   IS1F(z, 0) ==  0, IS1B(z, 0) ==  0};

And the NDSolve:

solInt = NDSolve({PDE, BC}, {IPF, IPB, IS1F, IS1B}, {z, 0, lR}, {t, 0,
     tmax}, MaxStepFraction -> {1/750, 1/10}, 
   Method -> {"BDF", "MaxDifferenceOrder" -> 5}, 
   InterpolationOrder -> All);

The main idea behind the boundary conditions is that IPF (z, t) = 0 at time t = 0 and for all z in the range 0 - lR, but for t> 0 and z = 0, it will have the form of the Gaussian Equation.

Is it possible to impose these initial conditions?

Side note: Sorry if my post is similar, I didn't know if I should piggyback on my last question or if it was something I should ask from scratch.

Cheers!

replacement – How can I use the solutions of a coupled nonlinear equation as a function of the parameters?

You can first define your duties as

(*here i ranges from 1 to 6*)
xsol(i_)(t_):=Part((x/.Solve({x^2-5x+6 AA == 0, y^3 -AA x^2 ==0}))/.AA->t, i)

ysol(i_)(t_):=Part((x/.Solve({x^2-5x+6 AA == 0, y^3 - AA x^2 ==0},{x,y}))/.AA->t, i)

Plot(Evaluate(Table(xsol(i)(t), {i,1,6})),{t,-2,2})
Plot(Evaluate(Table(ysol(i)(t),{i,1,6})),{t,-2,2})

enter description of image here

enter description of image here

I can't get DSolve to work on coupled equations

When trying to solve a geodesic equation, I have these coupled equations:

eq1 = Derivative(2)(u)(l) - Cos(u(l))*Sin(u(l))*D(v(l), l)*D(v(l), l) == 0; 
eq2 = Derivative(2)(v)(l) + 2*Cot(u(l))*D(u(l), l)*D(v(l), l) == 0; 
eq3 = u(0) == 1; 
eq4 = v(0) == 1; 
eq5 = Derivative(1)(u)(0) == 1; 
eq6 = Derivative(1)(v)(0) == 1; 

Now I want a solution for the functions u, v. So I'm trying this:

DSolve({eq1, eq2, eq3, eq4, eq5, eq6}, {u, v}, l)

And I get:

DSolve({-Cos(u(l)) Sin(u(l)) Derivative(1)(v)(l)^2 + (u^(Prime)(Prime))(l) == 0, 2 Cot(u(l)) Derivative(1)(u)(l) Derivative(1)(v)(l) + (v^(Prime)(Prime))(l) == 0, u(0) == 1, v(0) == 1, Derivative(1)(u)(0) == 1, Derivative(1)(v)(0) == 1}, {u, v}, l)

Which just tells me that Mathematica didn't recognize my entry. What am i doing wrong?

object oriented – Creation of a JavaScript GroupPicker class tightly coupled to the HTML structure. Is it an anti-model?

I build a GroupPicker class which basically manages an interface which allows the user to move elements between two columns "assigned" vs "not assigned". The items in the columns have a hierarchy of parents and children, so if a child is affected, the parent is too.

What I am doing might be fine, but it seems to me that a smell of code has HTML coupled in the class itself. The class must be flexible because sometimes the elements are not hierarchical, sometimes we do not want to be able to delete the elements already assigned, etc., and coupling it with HTML seems to make it fairly rigid.

What is the best practice when it comes to a class whose sole purpose is to manage the state of HTML and the values ​​of entries?

Imgur



Contact groups available
    <li id = "list" data-id = "" data counter = "" data-parent = "" data-children = "" data-treelevel = "" data-disabled = "" >
    <img src = "https://codereview.stackexchange.com/images/add_icon.png" data-assign = ""/>
Contact groups affected
    <li id = "list" data-id = "" data counter = "" data-parent = "" data-children = "" data-treelevel = "" data-disabled = "false" >
    <img src = "images / remove_icon.png" data-unassign = ""/>
<entry type = "hidden" id = "assigned values" name = "assigned values" value = ""autocomplete =" off "/> <input type = "hidden" id = "unassignedValues" name = "unassignedValues" value = ""autocomplete =" off "/>

Here is the start of the GroupPicker class. The constructor, _init() and assign:

// GroupPicker.js

function GroupPicker( element ) {
   var self = this;

   self.el = element;
   self.elUnassignedInput = self.el.querySelector( 'input#unassignedValues' );
   self.elAssignedInput = self.el.querySelector( 'input#assignedValues' );

   self._init();
}

GroupPicker.prototype._init = function() {
   var self = this;

   self.el.addEventListener( 'click', function( event ) {
      if ( event.target.dataset.assign ) {
         var elItem = self.el.querySelector( 'ul#unassigned li(data-id="' + event.target.dataset.assign + '")' );
         self.assign( elItem );
      } else if ( event.target.dataset.unassign ) {
         var elItem = self.el.querySelector( 'ul#assigned li(data-id="' + event.target.dataset.unassign + '")' );
         self.unassign( elItem );
      }
   });

   var disabledUnassigned = ().slice.call( self.el.querySelectorAll( 'ul#unassigned li(data-disabled="true")' ) );
   disabledUnassigned.forEach( function( elItem ) {
      self._checkDescendants( elItem );
   });
};

GroupPicker.prototype.assign = function( elItem ) {
   var self = this;
   var itemId = elItem.dataset.id;

   self.unassigned = ().slice.call( self.el.querySelectorAll( 'ul#unassigned li' ) );
   self.assigned = ().slice.call( self.el.querySelectorAll( 'ul#assigned li' ) );

   self._addToAssignedInput( itemId );
   self._removeFromUnassignedInput( itemId );

   self._cloneToAssignedList( elItem );
   self._checkDescendants( elItem );
   self._handleParent( elItem );
};

I think the best example of my problem is in the method _deleteParent:

GroupPicker.prototype._deleteParent = function( elParent ) {
   var self = this;
   self.unassigned = ().slice.call( self.el.querySelectorAll( 'ul#unassigned li' ) );
   var elParentDescendants = elParent.dataset.children.split( '|' );
   var hasUnassignedDescendants = self.unassigned.some( function( elUnassignedItem ) {
      return elParentDescendants.indexOf( elUnassignedItem.dataset.id ) !== -1 && elUnassignedItem.dataset.disabled == 'false';
   });
   var elItemHasParent = Number( elParent.dataset.parent );
   var elItemParent = self.el.querySelector( 'ul#unassigned li(data-id="' + elParent.dataset.parent + '")' );

   if ( ! hasUnassignedDescendants ) {
      elParent.parentNode.removeChild( elParent );
   }

   if ( elItemHasParent && elItemParent ) {
      self._deleteParent( self.el.querySelector( 'ul#unassigned li(data-id="' + elParent.dataset.parent + '")' ) );
   }
};

When the last descendant of an element is assigned, the deactivated ancestors are deleted. You can see examples of hypotheses made on the HTML structure that make me intrinsically nervous like: var elItemParent = self.el.querySelector( 'ul#unassigned li(data-id="' + elParent.dataset.parent + '")' );.

If you were to write a class that had similar responsibilities, how would you do it? Thanks for everything you can teach me – I would love to have good resources on this as well. I couldn't find anything on Google about it.

EDIT: Even if I give an example here, I think the root of my question does not require a code review per se. It boils down to a question of how we write classes that manage the state of a DOM and its data and whether methods on classes directly modifying state are a smart thing to do. , especially when we make assumptions about its structure when it doesn't & # 39; & # 39; Don't have control over this aspect.

Coupled differential equations

for example, I have pde1 = -y1 & # 39; & # 39; (x) – (2 * y1- (x)) / x + (10 ^ -19 * (y1 (x)) ^ 2 + y2 (x)) * y1 (x) == 0;
pde2 = y2 & # 39; & # 39; (x) + (2 * y2 & (x)) / x – (10 ^ -25)(y1 (x)) ^ 2 == 0
sol = NDSolve ({pde1, pde2, y1 (1) = 0.001, y2 (1) == -0.001, y1 (0.001) == 0.001, y2 (0.001) == 0.001}, { y1, y2}, {x, 30})
{{y1 -> InterpolatingFunction ({{0., 30}}, <>),
y2-> InterpolatingFunction ({{0., 30}}, <>)}}
I need to trace the integration of (solution (y1)
x ^ 2)