function [dxdt] = odesolver_uniformconcentration_new(t,x) global T_g_0 C1 C2 eps_ref R_g gamma C_0 c_0 R_0 b_0 x_mesh counter pg_0 pa pressure_vec a_dot_vec ... counter_smooth rho_L t_end temp_up temp_low c_vec eta_g tau t_vec... rho_0 M_w rho_vec temp_vec tg_vec ... v Q eps_dot_0 E_R eps_dot_R alpha_R n sigma_plastic_vec stress_vec sigma_rubber mechanism_vec K_H eos_index KH_index ... thickness_vec thickness_check t_min ductility_check T_Tg_vec T_g_0 stree_profile_vec f_int_vec % update counter and time vector counter = counter + 1; t_vec(counter) = t; t % to show time development during simulations b_3 = (x(1)^3-R_0^3+b_0^3); temp = temp_function_exp(t,temp_low,temp_up,t_end,tau); % define temperature profile if counter == 1 p = pg_0; rho = rho_0; c = c_0; else % calculate pressure and density of gas p = ((b_0^3-R_0^3)*C_0+R_0^3*pg_0/(R_g*temp_low))/(x(1)^3/(R_g*temp) + (b_3 - x(1)^3)*K_H); % pressure by gas mol conservation for given a and constant KH rho = p/(R_g*temp)*M_w; c = K_H*p; end tg = tg_function(T_g_0,c,rho_L); a = x(1); [fun] = @(a_dot_var) function_root_adot(a_dot_var,a,p,temp,tg); if counter == 1 a_dot_0 = 0; else a_dot_0 = a_dot_vec(counter-1); end a_dot = fzero(fun,a_dot_0); a_dot_vec(counter) = a_dot; dxdt = [a_dot]; pressure_vec(counter) = p; temp_vec(counter) = temp; tg_vec(counter) = tg; end