numerical solution for coupled pde system with periodic boundary conditions
I would like to solve:
s_t+[S(s,q,s_x,q_x,h_xxx)]_x=0
q_t+[B(s,q,s_x,q_x,h_xxx)]_x=G[s,q]
S and B include functions of s and q and their derivatives...
See also questions close to this topic

How to Mount Android Q Pixel 2XL Device System Partition?
I am trying to mount the Android Q rooted device system partition to add a app as system app. I am using Pixel 2XL device with Android Q version. I tried all the below commands from adb but every thing is failed. Can anyone tell me how I could copy the app in /system/privapp/ location.
mount wo remount /system mount o rw,remount t /sbin/.magisk/block/system_root /system mount o rw,remount t /sbin/block/system_root mount wo remount /system su c mount wo remount /sbin/.magisk/block/system_root$(getprop ro.boot.slot_suffix) /system
Any suggestions ?

Android system landscap and portrait control
I tried to develop an android application that control the android system to be in landscape or portrait mode. I have tried some code but it just control my application in landscap and portrait mode. So here I need your help. Could someone explain to me how to do it please ? I have write some code but I think that it is not interresant to put here.

FIltering out System apps from Recycleview
I've been working on an app that blocks internet traffic on specific apps but the problem is that the list of apps is including the system apps as well. I am having a hard time trying to find a way to filter them out. Is it possible to have them removed? And is the current piece of code enough to help find an answer? If there is more information needed to help with the problem please leave a comment so i can provide it.
public class Rule implements Comparable <Rule> { public PackageInfo info; public String name; public boolean system; public boolean disabled; public boolean wifi_blocked; public boolean other_blocked; public boolean changed; private Rule(PackageInfo info, boolean wifi_blocked, boolean other_blocked, boolean changed, Context context) { PackageManager pm = context.getPackageManager(); this.info = info; this.name = info.applicationInfo.loadLabel(pm).toString(); this.system = ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); int setting = pm.getApplicationEnabledSetting(info.packageName); if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) this.disabled = !info.applicationInfo.enabled; else this.disabled = (setting != PackageManager.COMPONENT_ENABLED_STATE_ENABLED); this.wifi_blocked = wifi_blocked; this.other_blocked = other_blocked; this.changed = changed; } public static List<Rule> getRules(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences wifi = context.getSharedPreferences("wifi", Context.MODE_PRIVATE); SharedPreferences other = context.getSharedPreferences("other", Context.MODE_PRIVATE); boolean wlWifi = prefs.getBoolean("whitelist_wifi", true); boolean wlOther = prefs.getBoolean("whitelist_other", true); List<Rule> listRules = new ArrayList<>(); for (PackageInfo info : context.getPackageManager().getInstalledPackages(0)) { boolean blWifi = wifi.getBoolean(info.packageName, wlWifi); boolean blOther = other.getBoolean(info.packageName, wlOther); boolean changed = (blWifi != wlWifi  blOther != wlOther); listRules.add(new Rule(info, blWifi, blOther, changed, context)); } Collections.sort(listRules); return listRules; } public Drawable getIcon(Context context) { return info.applicationInfo.loadIcon(context.getPackageManager()); } @Override public int compareTo(Rule other) { if (changed == other.changed) { int i = name.compareToIgnoreCase(other.name); return (i == 0 ? info.packageName.compareTo(other.info.packageName) : i); } return (changed ? 1 : 1); } }

How to split numeric and substring from main string in SWIFT?
I have a case where I need to separate the numeric value and other substring from the main given string.
Suppose the main string is
350.55kph
. Then my desired result is350.55
as a numeric value andkph
is other substring.Can someone help me with this?

Curve radius in Python
I have this curve and I would like to compute the radius and the center of the curve below:
The data for this curve https://pastebin.com/FZTi3bAf
My code so far:
poly = np.polyfit(df['x'], df['y'],2) p = np.poly1d(poly)
I need to have new point (x, y) as input in this problem.

javascript jquery sort ascociative numeric array ascending order and keep duplicates
i have a numeric key => value array with missing keys. I want to keep the array as is, but sort it in a ascending order, and keep the duplicate key.
This is a keyboard keycodes array:
my codes is as follows:
var keyCodes = { "192" : "~", "49" : "!", "50" : "@", "51" : "#", "52" : "$", "53" : "%", "54" : "^", "55" : "&", "56" : "*", "57" : "(", "48" : ")", "173" : "_", "61" : "+", "219" : "{", "221" : "}", "220" : "", "59" : ":", "222" : "\"", "188" : "<", "190" : ">", "191" : "?", "192" : "`", "219" : "[", "221" : "]", "59" : ";", "222" : "'", "220" : "\\", "188" : ",", "190" : ".", "191" : "/", "49" : "1", "50" : "2", "51" : "33", "51" : "34", "51" : "35", "51" : "3", "52" : "4", "53" : "5", "54" : "6", "55" : "7", "39" : "ArrowRight" };
this is a portion of the array: here there are 4 x 51 key value pairs. i would like that when the array is sorted i get ....."49" : "1", "51" : "3", "51" : "33", "51" : "34", "51" : "35", ......
i have tried almost everything, the last thing i tried was the following:
function checkKeys(arr, key){ for(var i = 0; i < arr.length; i++){ if(arr[i] == key) return 1; } return 0; } $inArr = []; $inArrd = []; $newCodes = {}; Object.keys(keyCodes).forEach(function (key) { var keysC = checkKeys($inArr, key); if(keysC === 1){ /*tried creating an array of duplicates and then later remove or change them in the main array manually*/ $inArrd.push(key); return; } $inArr.push(key); $newCodes[key] = keyCodes[key]; return; }); console.log($inArrd);
did not work properly.

Coupled pdes across various domains in FEniCS
I am a completely new to FEniCS. I am trying to solve the following set of coupled pdes ( variables are p,n and psi) using FEniCS :
qDn∇2n − qun∇.(n∇ψ) = q(n10**11)/10**(6), in Domain 1 qDp∇2p + qup∇.(p∇ψ) = q(p10**21)/10**(6), in Domain 1 e∇2ψ = −(p − n N) in Domain 1 e∇2ψ = 0 in Domain 2, where Domain 1 is the region defined by y<=h and Domain 2 is the region defined by h<y<=h+tox
subjected to the boundary conditions :
p(x,0)= p0, n(x,0)= n0, psi(x,0)= 0, p(x,h)= p0*exp(psi/Vth), n(x,h)= n0*exp(psi/Vth), psi(x,h+tox)= 5
I don't want to solve for the variables 'p' and 'n' in domain 2 but I want to solve for ''psi'' in both the domains. Being completely new to FEniCS, I am facing trouble in formulating this set of coupled pdes across the two domains. Any help regarding this would be hghly appreciated.

Using internal constraint feature in fipy
I am a newbie to fipy. I am trying to solve the following set of coupled pdes ( variables are p,n and psi) using fipy :
qDn∇2n − qun∇.(n∇ψ) = q(n10**11)/10**(6), in Domain 1 qDp∇2p + qup∇.(p∇ψ) = q(p10**21)/10**(6), in Domain 1 e∇2ψ = −(p − n N) in Domain 1 e∇2ψ = 0 in Domain 2, where Domain 1 is the region defined by y<=h and Domain 2 is the region defined by h<y<=h+tox
subjected to the boundary conditions :
p(x,0)= p0, n(x,0)= n0, psi(x,0)= 0, p(x,h)= p0*exp(psi/Vth), n(x,h)= n0*exp(psi/Vth), psi(x,h+tox)= 5
I don't want to solve for the variables 'p' and 'n' in domain 2 but I want to solve for ''psi'' in both the domains. Since fipy does not allow explicit domain partition, I am using the internal constraint feature in fipy to impose the boundary conditions at the position given by
y=h
, since this physical boundary is actually inside the defined mesh i.e. it is not a mesh boundary. Just for keeping up with the generality, I am willing to define the other boundary conditions aty=0
andy=h+tox
also using the internal constraint feature though I suppose thatmesh.facesBottom
andmesh.facesTop
will work for the boundariesy=0
andy=h+tox
respectively. I have already framed the pdes in fipy. But I am facing difficulty in defining the boundary conditions using the internal constraint. The code that I have written has been shown below.! pip install fipy ! pip install pyparse from fipy import * L= 10**(6) h= 20**(6) tox= 0.1*10**(6) q=1.6*10**(19) un=0.14 up=0.045 Vth=0.026 Dp= up*Vth Dn=un*Vth p0= 10**(21) n0= 10**(11) e0=8.854*10**(12) mesh1= Grid2D(dx= L/100,nx=100,dy=h/200,ny=200) # mesh for domain 1 for solving for p and n mesh2= Grid2D(dx= L/100,nx=100,dy=tox/10,ny=10) mesh3= mesh1+(mesh2+[[0],[h]]) # mesh for Domain 1 and Domain 2 for solving for psi x,y= mesh3.cellCenters N= 10**21*(y<=h) # N changes from Domain 1 to Domain 2 e= 11.9*e0*(y<=h)+ 3.9*e0*(y>h) # e changes from Domain 1 to Domain 2 p1=CellVariable(name='hole',mesh=mesh3,hasOld=True,value=p0) n1=CellVariable(name='electron',mesh=mesh3,hasOld=True,value=n0) psi=CellVariable(name='potential',mesh=mesh3,hasOld=True,value=1) p= p1*(y<=h) # for domain partition n= n1*(y<=h) # for domain partition mask1=((y==0)) # Boundary 1 mask2=(y==h) # Boundary2 mask3=(y==(h+tox)) # Boundary 3 largevalue= 1e50 eq1=(DiffusionTerm(coeff=q*Dn,var=n)ConvectionTerm(coeff=q*un*psi.faceGrad,var=n)==ImplicitSourceTerm(coeff=q/10**(6),var=n)q*n0/10**(6)) eq2=(DiffusionTerm(coeff=q*Dp,var=p)+ConvectionTerm(coeff=q*up*psi.faceGrad,var=p)==ImplicitSourceTerm(coeff=q/10**(6),var=p)+q*p0/10**(6)) eq3=(DiffusionTerm(coeff=e,var=psi)==q*(pnN)) eq= eq1 & eq2 & eq3 eq.solve(vars=(n,p,psi))
I am not being able to impose the boundary conditions using the internal constraint feature in fipy. Any help regarding this would be highly appreciated.

For MATLAB R2018b: how do you define a nonconstant boundary condition for solvepde?
I am using MATLAB to solve a couple of PDEs. I have used the function solvepde to obtain a solution to the 2D Laplace equation for two different functions. Mu(x,y) has a Dirichlet boundary condition on the left and a section of Dirichlet boundary condition on the right with zero flux boundary conditions around that section and on the top and bottom. Phi(x,y) has similar boundary conditions with a Dirichlet boundary condition on the left but a section of Neumann boundary condition on the right and zero flux around that section and on the top and bottom. The calculation for phi relies on the results of the calculation for mu because the value of the Neumann boundary condition on right side at a specific y value, which I have defined as A in the code below, is a function of dmu/dx at that y value. However, in the code below, I have defined A as the same constant everywhere on the boundary. This is ok for most of the boundary since dmu/dx is the same for most values of y along the boundary but not for the regions around y=0.025 and y=0.075. Does anyone know how to make it so that A is actually a function of y and is evaluated at each y coordinate on the boundary within the solvepde for phi? Additionally, the next step is to evaluate and plot I = [sigi/(4e)] * grad(mu)  sigi * grad(phi), how can I do this using the solutions for mu and phi from solvepde? Here is the code. Apologies for the length, there is a lot to set up the problem, but the sections I need help with are the last three. Thanks!
% Define constants e = 1.60217662*10^19; l = 10*10^6; sigi = 18; T = 1000; R = 8.314; kb = 1.381*10^23; h = 6.626*10^34; F = 96485; n = 0.02; c = 1; pH2 = 0.2; pH2O = 1pH2; % Determine value of mu at the right boundary G = 247500+55.85*T; keq = exp(G/(R*T)); pO2 = (pH2O/pH2)^2*(1/keq^2); mu2 = kb*T*log(pO2); % Rectangle is code 3, 4 sides, followed by xcoordinates and then ycoordinates R1 = [3,4,0,l,l,0,0,0,.025,.025]'; R2 = [3,4,0,l,l,0,0.025,0.025,.075,.075]'; R3 = [3,4,0,l,l,0,0.075,0.075,.1,.1]'; geom = [R1,R2,R3]; % Names for the two geometric objects ns = (char('R1','R2','R3'))'; % Set formula sf = 'R1+R2+R3'; % Create geometry g = decsg(geom,sf,ns); % Create mu geometry model mumodel = createpde; % Include the geometry in the model and view the geometry geometryFromEdges(mumodel,g); % Apply boundary conditions applyBoundaryCondition(mumodel,'dirichlet','Edge',8,'u',0); applyBoundaryCondition(mumodel,'dirichlet','Edge',9,'u',0); applyBoundaryCondition(mumodel,'dirichlet','Edge',10,'u',0); applyBoundaryCondition(mumodel,'dirichlet','Edge',6,'u',mu2); applyBoundaryCondition(mumodel,'neumann','Edge',1,'g',0); applyBoundaryCondition(mumodel,'neumann','Edge',3,'g',0); applyBoundaryCondition(mumodel,'neumann','Edge',4,'g',0); applyBoundaryCondition(mumodel,'neumann','Edge',2,'g',0); applyBoundaryCondition(mumodel,'neumann','Edge',5,'g',0); applyBoundaryCondition(mumodel,'neumann','Edge',7,'g',0); % Solve for phi with these boundary conditions specifyCoefficients(mumodel,'m',0,'d',0,'c',1,'a',0,'f',0); generateMesh(mumodel,'Hmax',l); solmu = solvepde(mumodel); mu = solmu.NodalSolution; f1=figure; pdeplot(mumodel,'XYData',mu) % Create phi geometry model phimodel = createpde; % Include the geometry in the model and view the geometry geometryFromEdges(phimodel,g); % Calculate constant for Neumann boundary condition Ie = 2*F*(c*pO2^n); xq = ones(1,100)*l; yq = linspace(0.025,0.075,100); [gradx,grady]=evaluateGradient(solmu,xq,yq); % Use value from the middle region of the boundary to approximate for value everywhere ****this is what I need to change**** A = (sigi/(4*e)*gradx(52)Ie)/sigi; % Apply boundary conditions applyBoundaryCondition(phimodel,'dirichlet','Edge',8,'u',0); applyBoundaryCondition(phimodel,'dirichlet','Edge',9,'u',0); applyBoundaryCondition(phimodel,'dirichlet','Edge',10,'u',0); applyBoundaryCondition(phimodel,'neumann','Edge',6,'g',A); applyBoundaryCondition(phimodel,'neumann','Edge',1,'g',0); applyBoundaryCondition(phimodel,'neumann','Edge',3,'g',0); applyBoundaryCondition(phimodel,'neumann','Edge',4,'g',0); applyBoundaryCondition(phimodel,'neumann','Edge',2,'g',0); applyBoundaryCondition(phimodel,'neumann','Edge',5,'g',0); applyBoundaryCondition(phimodel,'neumann','Edge',7,'g',0); % Solve for phi with these boundary conditions specifyCoefficients(phimodel,'m',0,'d',0,'c',1,'a',0,'f',0); generateMesh(phimodel,'Hmax',l); solphi = solvepde(phimodel); phi = solphi.NodalSolution; f2=figure; pdeplot(phimodel,'XYData',phi)