# Tag Info

4

bn[a_, T_, f_] := 2/T Integrate[f Sin[(2 π n)/T t], {t, a, T + a}, Assumptions -> T ∈ Reals] bn[0, L, Piecewise[{{0, 0 < t < L/3}, {w, L/3 < t < 2 L/3}, {0, 2 L/3 < t < L}}]]

3

The problem with WhenEvent has to do with the OP's DE. For an event to be detected, there has to be a point at which the condition is crossed, that is, changes from False for t < t0 to True for t > t0. NDSolve then applies a root-finding algorithm to approximate the value of t0 at which the event occurs. In your DE, the solution p1[t] theoretically ...

2

You could try specifying the event differently (this will trigger when the absolute difference between p1 and p2 is smaller than some value): Ad1=10/1000^2; Ad2=1.5*1000^(-2); Ad3=1.5*1000^(-2); Cd1=0.67; Cd2=0.67; Cd3=0.67; V1=10/1000; V2=10/1000; Rho=875; beta=1000*10^6; ps=100*10^5; Q1=Ad1*Cd1*Sqrt[(2/Rho)*(ps-p1[t])]; ...

1

Use a numerical derivative: Clear[band, en, w, fermi, k, T, S, a] << NumericalCalculus k = 86*10^-6; T = 4000; band[en_, w_] := 10000 Exp[-en^2/2 w^2]; fermi[en_, ef_] := 1/(Exp[(en - ef)/(k T)] + 1); S[ef_?NumericQ] := -k NIntegrate[(band[en, w] fermi[en, ef] Log[fermi[en, ef]]) /. w -> 1, {en, -Infinity, Infinity}] ...

1

I've made a number of changes to your code which may speed things up, but I honestly can't say with certainty. Rather than enumerating the changes, I'll just list the code here: ClearAll["Global*"]; integrand[k_?NumericQ, P0_?NumericQ, P1_?NumericQ, rho_?NumericQ, l_?NumericQ] := Module[{x, h}, x = P1*l + P0*(1. - l) - rho; h = HankelH2[0, ...

1

Ok, so this is my attempt at a short discussion and solution (after getting a little bit wiser). Due to these equations being stiff (Wikipedia) as pointed out by @Nasser, certain numerical methods have difficulty at tracking the solution, and thus, approximations of the orifice equations yield complex solutions at some point when p1[t]>ps and/or ...

Only top voted, non community-wiki answers of a minimum length are eligible