|
1 | | -function varargout = m_imrv2_spectral(varargin) |
| 1 | +% file m_imrv2_spectral.m |
| 2 | +% brief contains module m_imrv2_spectral |
2 | 3 |
|
3 | | -% Description: This code the IMRv2 code expanding beyond IMR from |
4 | | -% Estrada et al. (2018) JMPS. Additional physics have been added including |
5 | | -% the Keller-Miksis with enthalpy and non-Newtonian viscosity. |
| 4 | +% brief This module features a Chebyshev spectral collocation solver of the |
| 5 | +% PDEs involving thermal transport and viscoelasticity to solve |
| 6 | +% Rayleigh-Plesset equations |
| 7 | +function varargout = m_imrv2_spectral(varargin) |
6 | 8 |
|
7 | 9 | % Problem Initialization |
8 | 10 | [eqns_opts, solve_opts, init_opts, tspan_opts, out_opts, acos_opts,... |
|
16 | 18 | masstrans = eqns_opts(7); perturbed = eqns_opts(8); |
17 | 19 | nl = eqns_opts(9); |
18 | 20 | if (stress == 4); ptt = 1; else; ptt = 0; end |
| 21 | + |
19 | 22 | % solver options |
20 | 23 | method = solve_opts(1); spectral = solve_opts(2); |
21 | 24 | divisions = solve_opts(3); Nv = solve_opts(4); |
22 | 25 | Nt = solve_opts(5); Mt = solve_opts(6); |
23 | 26 | Lv = solve_opts(7); Lt = solve_opts(8); |
| 27 | + |
24 | 28 | % dimensionless initial conditions |
25 | 29 | Rzero = init_opts(1); Uzero = init_opts(2); |
26 | 30 | p0star = init_opts(3); P8 = init_opts(4); |
27 | 31 | T8 = init_opts(5); Pv_star = init_opts(6); |
28 | 32 | Req = init_opts(7); S0 = init_opts(8); |
29 | 33 | alphax = init_opts(9); |
30 | | -if perturbed == 1 |
31 | | - azero = init_opts(10:10+nl-1); |
32 | | - adot_zero = init_opts(10+nl:10+2*nl-1); |
33 | | -end |
| 34 | + |
34 | 35 | % time span options |
35 | 36 | tspan = tspan_opts; |
36 | 37 | tfin = tspan(end); |
37 | 38 | % output options |
38 | 39 | dimensionalout = out_opts(1); progdisplay = out_opts(2); |
39 | 40 | plotresult = out_opts(3); |
40 | | -% physical parameters% |
| 41 | + |
| 42 | +% physical parameters |
| 43 | + |
41 | 44 | % acoustic parameters |
42 | 45 | Cstar = acos_opts(1); GAMa = acos_opts(2); |
43 | 46 | kappa = acos_opts(3); nstate = acos_opts(4); |
44 | 47 | % dimensionless waveform parameters |
45 | 48 | om = wave_opts(1); ee = wave_opts(2); |
46 | 49 | tw = wave_opts(3); dt = wave_opts(4); |
47 | 50 | mn = wave_opts(5); wave_type = wave_opts(6); |
48 | | -if perturbed == 1 |
49 | | - l = wave_opts(7:7+nl-1)'; |
50 | | -end |
| 51 | + |
51 | 52 | pvarargin = [om,ee,tw,dt,mn,wave_type]; |
52 | 53 | % dimensionless viscoelastic |
53 | 54 | We = sigma_opts(1); Re8 = sigma_opts(2); |
|
170 | 171 | end |
171 | 172 | Z1 = X(:,ic); |
172 | 173 | Z2 = X(:,id); |
173 | | -if perturbed == 1 |
174 | | - aa = X(:,7:7+nl-1); |
175 | | - adot = X(:,7+nl:7+2*nl-1); |
176 | | -end |
177 | 174 | a = X(:,ia)'; |
178 | 175 | b = X(:,ib)'; |
179 | 176 | c = X(:,ic)'; |
|
317 | 314 | J = 0; |
318 | 315 | JdotX = 0; |
319 | 316 |
|
320 | | - % Kelvin-Voigt with neo-Hookean elasticity |
| 317 | + % compute stress integral |
321 | 318 | elseif stress == 1 |
322 | | - % compute stress integral |
323 | | - % J = (4*(Req/R) + (Req/R)^4 - 5)/(2*Ca) - 4/Re8*U/R; |
324 | | - % JdotX = -2*U*(Req*(1/R)^2 + Req^4*(1/R)^5)/Ca + 4/Re8*U^2/R^2; |
| 319 | + % Kelvin-Voigt with neo-Hookean elasticity |
| 320 | + J = (4*(Req/R) + (Req/R)^4 - 5)/(2*Ca) - 4/Re8*U/R; |
| 321 | + JdotX = -2*U*(Req*(1/R)^2 + Req^4*(1/R)^5)/Ca + 4/Re8*U^2/R^2; |
| 322 | + |
| 323 | + elseif stress == 2 |
| 324 | + % quadratic Kelvin-Voigt with neo-Hookean elasticity |
325 | 325 | J = (3*alphax-1)*(5 - (Req/R)^4 - 4*(Req/R))/(2*Ca) - 4/Re8*U/R + ... |
326 | 326 | (2*alphax/Ca)*(27/40 + (1/8)*(Req/R)^8 + (1/5)*(Req/R)^5 + (1/2)*(Req/R)^2 - ... |
327 | 327 | 2*R/Req); |
|
352 | 352 | JdotX = 2*sum(cdd.*(Z1dot - Z2dot)); |
353 | 353 |
|
354 | 354 | % linear Maxwell, linear Jeffreys, linear Zener |
355 | | - elseif stress == 2 |
| 355 | + elseif stress == 3 |
356 | 356 | % extract |
357 | 357 | Z1 = X(ic); |
358 | 358 | J = Z1/R^3 - 4*LAM/Re8*U/R; |
|
372 | 372 | JdotX = Z1dot/R^3 - 3*U/R^4*Z1 + 4*LAM/Re8*U^2/R^2; |
373 | 373 |
|
374 | 374 | % upper-convected Maxwell, OldRoyd-B |
375 | | - elseif stress == 3 |
| 375 | + elseif stress == 4 |
376 | 376 | % extract stress sub-integrals |
377 | 377 | Z1 = X(ic); Z2 = X(id); |
378 | 378 | % compute new derivatives |
|
398 | 398 | dXdt = [U; Udot; pdot; qdot; Z1dot; Z2dot; Jdot]; |
399 | 399 |
|
400 | 400 | end |
401 | | - |
402 | | - |
403 | | -% display result |
404 | | -if plotresult == 1 |
405 | | - subplot(3,1,1); |
406 | | - plot(t,R,'k','LineWidth',2); |
407 | | - hold('on'); |
408 | | - ylabel('$R$','Interpreter','Latex','FontSize',12); |
409 | | - box on; |
410 | | - if isreal(R) |
411 | | - % oldb sims for certain values were imaginary |
412 | | - % this spits out imaginary solution (BI will take care of it) |
413 | | - axis([0 t(end) 0 (max(R) + min(R))]); |
414 | | - set(gca,'TickLabelInterpreter','latex','FontSize',16) |
415 | | - set(gcf,'color','w'); |
416 | | - end |
417 | | - if bubtherm == 1 |
418 | | - if medtherm == 0 |
419 | | - b = zeros(size(a)); |
420 | | - end |
421 | | - subplot(3,1,2); |
422 | | - hold on; |
423 | | - box on; |
424 | | - semilogy(t,abs(a(end,:)),'k-','LineWidth',2); |
425 | | - semilogy(t,abs(b(end,:)),'b-','LineWidth',2); |
426 | | - ylabel('$a_N$, $b_M$, $e_N$','Interpreter','Latex','FontSize',12); |
427 | | - axis([0 t(end) 1e-20 1]); |
428 | | - set(gca, 'YScale', 'log'); |
429 | | - if masstrans == 0 |
430 | | - leg1 = legend('$a_N$','$b_M$','Location','NorthEast','FontSize',12); |
431 | | - else |
432 | | - leg1 = legend('$a_N$','$b_M$','$e_N$','Location','NorthEast','FontSize',12); |
433 | | - end |
434 | | - set(leg1,'Interpreter','latex'); |
435 | | - set(gca,'TickLabelInterpreter','latex','FontSize',16); |
436 | | - set(gcf,'color','w'); |
437 | | - end |
438 | | - if spectral == 1 |
439 | | - subplot(3,1,3); |
440 | | - hold on; |
441 | | - box on; |
442 | | - semilogy(t,abs(c(end,:)),'k-','LineWidth',2); |
443 | | - semilogy(t,abs(d(end,:)),'b-','LineWidth',2); |
444 | | - xlabel('$t$','Interpreter','Latex','FontSize',12); |
445 | | - ylabel('$c_P$, $d_P$','Interpreter','Latex','FontSize',12); |
446 | | - set(gca, 'YScale', 'log'); |
447 | | - axis([0 t(end) 1e-20 1]); |
448 | | - leg1 = legend('$c_P$','$d_P$','Location','NorthEast','FontSize',12); |
449 | | - set(leg1,'Interpreter','latex'); |
450 | | - set(gca,'TickLabelInterpreter','latex','FontSize',16); |
451 | | - set(gcf,'color','w'); |
452 | | - end |
453 | | -end |
454 | 401 | disp('--- COMPLETED SIMULATION ---'); |
455 | 402 |
|
456 | | - |
457 | 403 | % functions called by solver |
| 404 | + |
458 | 405 | % stress differentiator |
459 | 406 | function [trr,dtrr,t00,dt00] = stressdiff(c,d) |
460 | 407 | if Nv < 650 |
|
0 commit comments