import com.comsol.model.*;
import com.comsol.model.util.*;
import java.util.Arrays;
/** 3D continuum cavity plus exact PFP coexistence and finite-inventory screening.
 * The gel radius and shape respond to pressure and retained energy; no cavity displacement is imposed.
 * The vapor-liquid phase closure applies after activation; it does not predict nucleation.
 */
public class FreeCoreShellFine3D {
  static final String ROOT="./";
  static void installEOS(Model m) { 
    m.func().create("pfpp","Analytic");
    m.func("pfpp").set("funcname","pfpp");
    m.func("pfpp").set("args","TK,rr");
    m.func("pfpp").set("expr","rr*28.866254046397302*TK*(1+((0.036359237000000003)*(rr/625.03377999999998)^4*(421/TK)^1)*(4)+((1.1222855)*(rr/625.03377999999998)^1*(421/TK)^0.19)*(1)+((-0.63721963999999998)*(rr/625.03377999999998)^1*(421/TK)^1)*(1)+((-1.3599905999999999)*(rr/625.03377999999998)^2*(421/TK)^1)*(2)+((0.24995429)*(rr/625.03377999999998)^3*(421/TK)^0.33000000000000002)*(3)+((-2.2913320000000001)*(rr/625.03377999999998)^1*(421/TK)^1.51*exp(-(rr/625.03377999999998)^2))*(1-2*(rr/625.03377999999998)^2)+((-0.95997986000000002)*(rr/625.03377999999998)^3*(421/TK)^2.2200000000000002*exp(-(rr/625.03377999999998)^2))*(3-2*(rr/625.03377999999998)^2)+((1.2463966)*(rr/625.03377999999998)^2*(421/TK)^0.96999999999999997*exp(-(rr/625.03377999999998)^1))*(2-1*(rr/625.03377999999998)^1)+((-0.41785522000000003)*(rr/625.03377999999998)^2*(421/TK)^2.54*exp(-(rr/625.03377999999998)^2))*(2-2*(rr/625.03377999999998)^2)+((-0.49360387)*(rr/625.03377999999998)^1*(421/TK)^0.75*exp(-1.1679999999999999*((rr/625.03377999999998)-0.317)^2-2.1299999999999999*((421/TK)-1.1399999999999999)^2))*(1-2*1.1679999999999999*(rr/625.03377999999998)*((rr/625.03377999999998)-0.317))+((1.8336733000000001)*(rr/625.03377999999998)^1*(421/TK)^0.375*exp(-0.94399999999999995*((rr/625.03377999999998)-0.70199999999999996)^2-2.1299999999999999*((421/TK)-1.1850000000000001)^2))*(1-2*0.94399999999999995*(rr/625.03377999999998)*((rr/625.03377999999998)-0.70199999999999996))+((-0.27152336999999999)*(rr/625.03377999999998)^1*(421/TK)^0.5*exp(-2.2799999999999998*((rr/625.03377999999998)-0.68600000000000005)^2-2.1299999999999999*((421/TK)-0.94999999999999996)^2))*(1-2*2.2799999999999998*(rr/625.03377999999998)*((rr/625.03377999999998)-0.68600000000000005))+((-0.11731069)*(rr/625.03377999999998)^3*(421/TK)^1*exp(-1.486*((rr/625.03377999999998)-1.2569999999999999)^2-1.865*((421/TK)-1.02)^2))*(3-2*1.486*(rr/625.03377999999998)*((rr/625.03377999999998)-1.2569999999999999))+((-0.48844599999999999)*(rr/625.03377999999998)^2*(421/TK)^0.81499999999999995*exp(-1.78*((rr/625.03377999999998)-0.94699999999999995)^2-1.5900000000000001*((421/TK)-1.0249999999999999)^2))*(2-2*1.78*(rr/625.03377999999998)*((rr/625.03377999999998)-0.94699999999999995)))");
    m.func("pfpp").set("argunit",new String[]{"1","1"});
    m.func("pfpp").set("fununit","1");
    m.func().create("pfpu","Analytic");
    m.func("pfpu").set("funcname","pfpu");
    m.func("pfpu").set("args","TK,rr");
    m.func("pfpu").set("expr","28.866254046397302*TK*((-6.5375660406399998)*(421/TK)+14+5.7610000000000001*1.152019002375297*(421/TK)/(exp(1.152019002375297*(421/TK))-1)+19.370000000000001*2.4370546318289787*(421/TK)/(exp(2.4370546318289787*(421/TK))-1)+7.0960000000000001*4.7719714964370548*(421/TK)/(exp(4.7719714964370548*(421/TK))-1)+((0.036359237000000003)*(rr/625.03377999999998)^4*(421/TK)^1)*1+((1.1222855)*(rr/625.03377999999998)^1*(421/TK)^0.19)*0.19+((-0.63721963999999998)*(rr/625.03377999999998)^1*(421/TK)^1)*1+((-1.3599905999999999)*(rr/625.03377999999998)^2*(421/TK)^1)*1+((0.24995429)*(rr/625.03377999999998)^3*(421/TK)^0.33000000000000002)*0.33000000000000002+((-2.2913320000000001)*(rr/625.03377999999998)^1*(421/TK)^1.51*exp(-(rr/625.03377999999998)^2))*1.51+((-0.95997986000000002)*(rr/625.03377999999998)^3*(421/TK)^2.2200000000000002*exp(-(rr/625.03377999999998)^2))*2.2200000000000002+((1.2463966)*(rr/625.03377999999998)^2*(421/TK)^0.96999999999999997*exp(-(rr/625.03377999999998)^1))*0.96999999999999997+((-0.41785522000000003)*(rr/625.03377999999998)^2*(421/TK)^2.54*exp(-(rr/625.03377999999998)^2))*2.54+((-0.49360387)*(rr/625.03377999999998)^1*(421/TK)^0.75*exp(-1.1679999999999999*((rr/625.03377999999998)-0.317)^2-2.1299999999999999*((421/TK)-1.1399999999999999)^2))*(0.75-2*2.1299999999999999*(421/TK)*((421/TK)-1.1399999999999999))+((1.8336733000000001)*(rr/625.03377999999998)^1*(421/TK)^0.375*exp(-0.94399999999999995*((rr/625.03377999999998)-0.70199999999999996)^2-2.1299999999999999*((421/TK)-1.1850000000000001)^2))*(0.375-2*2.1299999999999999*(421/TK)*((421/TK)-1.1850000000000001))+((-0.27152336999999999)*(rr/625.03377999999998)^1*(421/TK)^0.5*exp(-2.2799999999999998*((rr/625.03377999999998)-0.68600000000000005)^2-2.1299999999999999*((421/TK)-0.94999999999999996)^2))*(0.5-2*2.1299999999999999*(421/TK)*((421/TK)-0.94999999999999996))+((-0.11731069)*(rr/625.03377999999998)^3*(421/TK)^1*exp(-1.486*((rr/625.03377999999998)-1.2569999999999999)^2-1.865*((421/TK)-1.02)^2))*(1-2*1.865*(421/TK)*((421/TK)-1.02))+((-0.48844599999999999)*(rr/625.03377999999998)^2*(421/TK)^0.81499999999999995*exp(-1.78*((rr/625.03377999999998)-0.94699999999999995)^2-1.5900000000000001*((421/TK)-1.0249999999999999)^2))*(0.81499999999999995-2*1.5900000000000001*(421/TK)*((421/TK)-1.0249999999999999)))");
    m.func("pfpu").set("argunit",new String[]{"1","1"});
    m.func("pfpu").set("fununit","1");
    m.func().create("pfpg","Analytic");
    m.func("pfpg").set("funcname","pfpg");
    m.func("pfpg").set("args","TK,rr");
    m.func("pfpg").set("expr","28.866254046397302*TK*(1+log((rr/625.03377999999998))+9.4767038900500005+(-6.5375660406399998)*(421/TK)+14*log((421/TK))+5.7610000000000001*log(1-exp(-1.152019002375297*(421/TK)))+19.370000000000001*log(1-exp(-2.4370546318289787*(421/TK)))+7.0960000000000001*log(1-exp(-4.7719714964370548*(421/TK)))+(0.036359237000000003)*(rr/625.03377999999998)^4*(421/TK)^1+(1.1222855)*(rr/625.03377999999998)^1*(421/TK)^0.19+(-0.63721963999999998)*(rr/625.03377999999998)^1*(421/TK)^1+(-1.3599905999999999)*(rr/625.03377999999998)^2*(421/TK)^1+(0.24995429)*(rr/625.03377999999998)^3*(421/TK)^0.33000000000000002+(-2.2913320000000001)*(rr/625.03377999999998)^1*(421/TK)^1.51*exp(-(rr/625.03377999999998)^2)+(-0.95997986000000002)*(rr/625.03377999999998)^3*(421/TK)^2.2200000000000002*exp(-(rr/625.03377999999998)^2)+(1.2463966)*(rr/625.03377999999998)^2*(421/TK)^0.96999999999999997*exp(-(rr/625.03377999999998)^1)+(-0.41785522000000003)*(rr/625.03377999999998)^2*(421/TK)^2.54*exp(-(rr/625.03377999999998)^2)+(-0.49360387)*(rr/625.03377999999998)^1*(421/TK)^0.75*exp(-1.1679999999999999*((rr/625.03377999999998)-0.317)^2-2.1299999999999999*((421/TK)-1.1399999999999999)^2)+(1.8336733000000001)*(rr/625.03377999999998)^1*(421/TK)^0.375*exp(-0.94399999999999995*((rr/625.03377999999998)-0.70199999999999996)^2-2.1299999999999999*((421/TK)-1.1850000000000001)^2)+(-0.27152336999999999)*(rr/625.03377999999998)^1*(421/TK)^0.5*exp(-2.2799999999999998*((rr/625.03377999999998)-0.68600000000000005)^2-2.1299999999999999*((421/TK)-0.94999999999999996)^2)+(-0.11731069)*(rr/625.03377999999998)^3*(421/TK)^1*exp(-1.486*((rr/625.03377999999998)-1.2569999999999999)^2-1.865*((421/TK)-1.02)^2)+(-0.48844599999999999)*(rr/625.03377999999998)^2*(421/TK)^0.81499999999999995*exp(-1.78*((rr/625.03377999999998)-0.94699999999999995)^2-1.5900000000000001*((421/TK)-1.0249999999999999)^2)+((0.036359237000000003)*(rr/625.03377999999998)^4*(421/TK)^1)*(4)+((1.1222855)*(rr/625.03377999999998)^1*(421/TK)^0.19)*(1)+((-0.63721963999999998)*(rr/625.03377999999998)^1*(421/TK)^1)*(1)+((-1.3599905999999999)*(rr/625.03377999999998)^2*(421/TK)^1)*(2)+((0.24995429)*(rr/625.03377999999998)^3*(421/TK)^0.33000000000000002)*(3)+((-2.2913320000000001)*(rr/625.03377999999998)^1*(421/TK)^1.51*exp(-(rr/625.03377999999998)^2))*(1-2*(rr/625.03377999999998)^2)+((-0.95997986000000002)*(rr/625.03377999999998)^3*(421/TK)^2.2200000000000002*exp(-(rr/625.03377999999998)^2))*(3-2*(rr/625.03377999999998)^2)+((1.2463966)*(rr/625.03377999999998)^2*(421/TK)^0.96999999999999997*exp(-(rr/625.03377999999998)^1))*(2-1*(rr/625.03377999999998)^1)+((-0.41785522000000003)*(rr/625.03377999999998)^2*(421/TK)^2.54*exp(-(rr/625.03377999999998)^2))*(2-2*(rr/625.03377999999998)^2)+((-0.49360387)*(rr/625.03377999999998)^1*(421/TK)^0.75*exp(-1.1679999999999999*((rr/625.03377999999998)-0.317)^2-2.1299999999999999*((421/TK)-1.1399999999999999)^2))*(1-2*1.1679999999999999*(rr/625.03377999999998)*((rr/625.03377999999998)-0.317))+((1.8336733000000001)*(rr/625.03377999999998)^1*(421/TK)^0.375*exp(-0.94399999999999995*((rr/625.03377999999998)-0.70199999999999996)^2-2.1299999999999999*((421/TK)-1.1850000000000001)^2))*(1-2*0.94399999999999995*(rr/625.03377999999998)*((rr/625.03377999999998)-0.70199999999999996))+((-0.27152336999999999)*(rr/625.03377999999998)^1*(421/TK)^0.5*exp(-2.2799999999999998*((rr/625.03377999999998)-0.68600000000000005)^2-2.1299999999999999*((421/TK)-0.94999999999999996)^2))*(1-2*2.2799999999999998*(rr/625.03377999999998)*((rr/625.03377999999998)-0.68600000000000005))+((-0.11731069)*(rr/625.03377999999998)^3*(421/TK)^1*exp(-1.486*((rr/625.03377999999998)-1.2569999999999999)^2-1.865*((421/TK)-1.02)^2))*(3-2*1.486*(rr/625.03377999999998)*((rr/625.03377999999998)-1.2569999999999999))+((-0.48844599999999999)*(rr/625.03377999999998)^2*(421/TK)^0.81499999999999995*exp(-1.78*((rr/625.03377999999998)-0.94699999999999995)^2-1.5900000000000001*((421/TK)-1.0249999999999999)^2))*(2-2*1.78*(rr/625.03377999999998)*((rr/625.03377999999998)-0.94699999999999995)))");
    m.func("pfpg").set("argunit",new String[]{"1","1"});
    m.func("pfpg").set("fununit","1");
    m.func().create("pfhp","Analytic");
    m.func("pfhp").set("funcname","pfhp");
    m.func("pfhp").set("args","TK,rr");
    m.func("pfhp").set("expr","rr*24.59594552747884*TK*(1+((0.035689273000000001)*(rr/616.92664999999988)^4*(448/TK)^1)*(4)+((0.89834616)*(rr/616.92664999999988)^1*(448/TK)^0.14599999999999999)*(1)+((-0.11619206999999999)*(rr/616.92664999999988)^1*(448/TK)^1)*(1)+((-1.6558706999999999)*(rr/616.92664999999988)^2*(448/TK)^1)*(2)+((0.30904009999999998)*(rr/616.92664999999988)^3*(448/TK)^0.39000000000000001)*(3)+((-3.0212884999999998)*(rr/616.92664999999988)^1*(448/TK)^1.5600000000000001*exp(-(rr/616.92664999999988)^2))*(1-2*(rr/616.92664999999988)^2)+((-1.309987)*(rr/616.92664999999988)^3*(448/TK)^2.25*exp(-(rr/616.92664999999988)^2))*(3-2*(rr/616.92664999999988)^2)+((1.4611604)*(rr/616.92664999999988)^2*(448/TK)^0.98699999999999999*exp(-(rr/616.92664999999988)^1))*(2-1*(rr/616.92664999999988)^1)+((-0.63849402)*(rr/616.92664999999988)^2*(448/TK)^2.6019999999999999*exp(-(rr/616.92664999999988)^2))*(2-2*(rr/616.92664999999988)^2)+((-0.40480926)*(rr/616.92664999999988)^1*(448/TK)^1.8700000000000001*exp(-0.87749999999999995*((rr/616.92664999999988)-0.35999999999999999)^2-1.171*((448/TK)-1.254)^2))*(1-2*0.87749999999999995*(rr/616.92664999999988)*((rr/616.92664999999988)-0.35999999999999999))+((2.3673483000000002)*(rr/616.92664999999988)^1*(448/TK)^0.96999999999999997*exp(-1*((rr/616.92664999999988)-0.755)^2-1.1399999999999999*((448/TK)-1.3120000000000001)^2))*(1-2*1*(rr/616.92664999999988)*((rr/616.92664999999988)-0.755))+((0.40072213000000001)*(rr/616.92664999999988)^1*(448/TK)^2.2200000000000002*exp(-1.327*((rr/616.92664999999988)-1.6930000000000001)^2-0.64500000000000002*((448/TK)-1.1779999999999999)^2))*(1-2*1.327*(rr/616.92664999999988)*((rr/616.92664999999988)-1.6930000000000001))+((-0.43534683000000002)*(rr/616.92664999999988)^3*(448/TK)^1.7*exp(-1.1020000000000001*((rr/616.92664999999988)-1.04)^2-0.65800000000000003*((448/TK)-1.3260000000000001)^2))*(3-2*1.1020000000000001*(rr/616.92664999999988)*((rr/616.92664999999988)-1.04))+((-0.90267664000000003)*(rr/616.92664999999988)^2*(448/TK)^1.3100000000000001*exp(-1.274*((rr/616.92664999999988)-0.64600000000000002)^2-0.72699999999999998*((448/TK)-0.90200000000000002)^2))*(2-2*1.274*(rr/616.92664999999988)*((rr/616.92664999999988)-0.64600000000000002)))");
    m.func("pfhp").set("argunit",new String[]{"1","1"});
    m.func("pfhp").set("fununit","1");
    m.func().create("pfhu","Analytic");
    m.func("pfhu").set("funcname","pfhu");
    m.func("pfhu").set("args","TK,rr");
    m.func("pfhu").set("expr","24.59594552747884*TK*((-9.8030217139900007)*(448/TK)+16+4.9020000000000001*0.9665178571428571*(448/TK)/(exp(0.9665178571428571*(448/TK))-1)+23.43*2.03125*(448/TK)/(exp(2.03125*(448/TK))-1)+10.52*4.4241071428571432*(448/TK)/(exp(4.4241071428571432*(448/TK))-1)+((0.035689273000000001)*(rr/616.92664999999988)^4*(448/TK)^1)*1+((0.89834616)*(rr/616.92664999999988)^1*(448/TK)^0.14599999999999999)*0.14599999999999999+((-0.11619206999999999)*(rr/616.92664999999988)^1*(448/TK)^1)*1+((-1.6558706999999999)*(rr/616.92664999999988)^2*(448/TK)^1)*1+((0.30904009999999998)*(rr/616.92664999999988)^3*(448/TK)^0.39000000000000001)*0.39000000000000001+((-3.0212884999999998)*(rr/616.92664999999988)^1*(448/TK)^1.5600000000000001*exp(-(rr/616.92664999999988)^2))*1.5600000000000001+((-1.309987)*(rr/616.92664999999988)^3*(448/TK)^2.25*exp(-(rr/616.92664999999988)^2))*2.25+((1.4611604)*(rr/616.92664999999988)^2*(448/TK)^0.98699999999999999*exp(-(rr/616.92664999999988)^1))*0.98699999999999999+((-0.63849402)*(rr/616.92664999999988)^2*(448/TK)^2.6019999999999999*exp(-(rr/616.92664999999988)^2))*2.6019999999999999+((-0.40480926)*(rr/616.92664999999988)^1*(448/TK)^1.8700000000000001*exp(-0.87749999999999995*((rr/616.92664999999988)-0.35999999999999999)^2-1.171*((448/TK)-1.254)^2))*(1.8700000000000001-2*1.171*(448/TK)*((448/TK)-1.254))+((2.3673483000000002)*(rr/616.92664999999988)^1*(448/TK)^0.96999999999999997*exp(-1*((rr/616.92664999999988)-0.755)^2-1.1399999999999999*((448/TK)-1.3120000000000001)^2))*(0.96999999999999997-2*1.1399999999999999*(448/TK)*((448/TK)-1.3120000000000001))+((0.40072213000000001)*(rr/616.92664999999988)^1*(448/TK)^2.2200000000000002*exp(-1.327*((rr/616.92664999999988)-1.6930000000000001)^2-0.64500000000000002*((448/TK)-1.1779999999999999)^2))*(2.2200000000000002-2*0.64500000000000002*(448/TK)*((448/TK)-1.1779999999999999))+((-0.43534683000000002)*(rr/616.92664999999988)^3*(448/TK)^1.7*exp(-1.1020000000000001*((rr/616.92664999999988)-1.04)^2-0.65800000000000003*((448/TK)-1.3260000000000001)^2))*(1.7-2*0.65800000000000003*(448/TK)*((448/TK)-1.3260000000000001))+((-0.90267664000000003)*(rr/616.92664999999988)^2*(448/TK)^1.3100000000000001*exp(-1.274*((rr/616.92664999999988)-0.64600000000000002)^2-0.72699999999999998*((448/TK)-0.90200000000000002)^2))*(1.3100000000000001-2*0.72699999999999998*(448/TK)*((448/TK)-0.90200000000000002)))");
    m.func("pfhu").set("argunit",new String[]{"1","1"});
    m.func("pfhu").set("fununit","1");
    m.func().create("pfhg","Analytic");
    m.func("pfhg").set("funcname","pfhg");
    m.func("pfhg").set("args","TK,rr");
    m.func("pfhg").set("expr","24.59594552747884*TK*(1+log((rr/616.92664999999988))+14.486127460400001+(-9.8030217139900007)*(448/TK)+16*log((448/TK))+4.9020000000000001*log(1-exp(-0.9665178571428571*(448/TK)))+23.43*log(1-exp(-2.03125*(448/TK)))+10.52*log(1-exp(-4.4241071428571432*(448/TK)))+(0.035689273000000001)*(rr/616.92664999999988)^4*(448/TK)^1+(0.89834616)*(rr/616.92664999999988)^1*(448/TK)^0.14599999999999999+(-0.11619206999999999)*(rr/616.92664999999988)^1*(448/TK)^1+(-1.6558706999999999)*(rr/616.92664999999988)^2*(448/TK)^1+(0.30904009999999998)*(rr/616.92664999999988)^3*(448/TK)^0.39000000000000001+(-3.0212884999999998)*(rr/616.92664999999988)^1*(448/TK)^1.5600000000000001*exp(-(rr/616.92664999999988)^2)+(-1.309987)*(rr/616.92664999999988)^3*(448/TK)^2.25*exp(-(rr/616.92664999999988)^2)+(1.4611604)*(rr/616.92664999999988)^2*(448/TK)^0.98699999999999999*exp(-(rr/616.92664999999988)^1)+(-0.63849402)*(rr/616.92664999999988)^2*(448/TK)^2.6019999999999999*exp(-(rr/616.92664999999988)^2)+(-0.40480926)*(rr/616.92664999999988)^1*(448/TK)^1.8700000000000001*exp(-0.87749999999999995*((rr/616.92664999999988)-0.35999999999999999)^2-1.171*((448/TK)-1.254)^2)+(2.3673483000000002)*(rr/616.92664999999988)^1*(448/TK)^0.96999999999999997*exp(-1*((rr/616.92664999999988)-0.755)^2-1.1399999999999999*((448/TK)-1.3120000000000001)^2)+(0.40072213000000001)*(rr/616.92664999999988)^1*(448/TK)^2.2200000000000002*exp(-1.327*((rr/616.92664999999988)-1.6930000000000001)^2-0.64500000000000002*((448/TK)-1.1779999999999999)^2)+(-0.43534683000000002)*(rr/616.92664999999988)^3*(448/TK)^1.7*exp(-1.1020000000000001*((rr/616.92664999999988)-1.04)^2-0.65800000000000003*((448/TK)-1.3260000000000001)^2)+(-0.90267664000000003)*(rr/616.92664999999988)^2*(448/TK)^1.3100000000000001*exp(-1.274*((rr/616.92664999999988)-0.64600000000000002)^2-0.72699999999999998*((448/TK)-0.90200000000000002)^2)+((0.035689273000000001)*(rr/616.92664999999988)^4*(448/TK)^1)*(4)+((0.89834616)*(rr/616.92664999999988)^1*(448/TK)^0.14599999999999999)*(1)+((-0.11619206999999999)*(rr/616.92664999999988)^1*(448/TK)^1)*(1)+((-1.6558706999999999)*(rr/616.92664999999988)^2*(448/TK)^1)*(2)+((0.30904009999999998)*(rr/616.92664999999988)^3*(448/TK)^0.39000000000000001)*(3)+((-3.0212884999999998)*(rr/616.92664999999988)^1*(448/TK)^1.5600000000000001*exp(-(rr/616.92664999999988)^2))*(1-2*(rr/616.92664999999988)^2)+((-1.309987)*(rr/616.92664999999988)^3*(448/TK)^2.25*exp(-(rr/616.92664999999988)^2))*(3-2*(rr/616.92664999999988)^2)+((1.4611604)*(rr/616.92664999999988)^2*(448/TK)^0.98699999999999999*exp(-(rr/616.92664999999988)^1))*(2-1*(rr/616.92664999999988)^1)+((-0.63849402)*(rr/616.92664999999988)^2*(448/TK)^2.6019999999999999*exp(-(rr/616.92664999999988)^2))*(2-2*(rr/616.92664999999988)^2)+((-0.40480926)*(rr/616.92664999999988)^1*(448/TK)^1.8700000000000001*exp(-0.87749999999999995*((rr/616.92664999999988)-0.35999999999999999)^2-1.171*((448/TK)-1.254)^2))*(1-2*0.87749999999999995*(rr/616.92664999999988)*((rr/616.92664999999988)-0.35999999999999999))+((2.3673483000000002)*(rr/616.92664999999988)^1*(448/TK)^0.96999999999999997*exp(-1*((rr/616.92664999999988)-0.755)^2-1.1399999999999999*((448/TK)-1.3120000000000001)^2))*(1-2*1*(rr/616.92664999999988)*((rr/616.92664999999988)-0.755))+((0.40072213000000001)*(rr/616.92664999999988)^1*(448/TK)^2.2200000000000002*exp(-1.327*((rr/616.92664999999988)-1.6930000000000001)^2-0.64500000000000002*((448/TK)-1.1779999999999999)^2))*(1-2*1.327*(rr/616.92664999999988)*((rr/616.92664999999988)-1.6930000000000001))+((-0.43534683000000002)*(rr/616.92664999999988)^3*(448/TK)^1.7*exp(-1.1020000000000001*((rr/616.92664999999988)-1.04)^2-0.65800000000000003*((448/TK)-1.3260000000000001)^2))*(3-2*1.1020000000000001*(rr/616.92664999999988)*((rr/616.92664999999988)-1.04))+((-0.90267664000000003)*(rr/616.92664999999988)^2*(448/TK)^1.3100000000000001*exp(-1.274*((rr/616.92664999999988)-0.64600000000000002)^2-0.72699999999999998*((448/TK)-0.90200000000000002)^2))*(2-2*1.274*(rr/616.92664999999988)*((rr/616.92664999999988)-0.64600000000000002)))");
    m.func("pfhg").set("argunit",new String[]{"1","1"});
    m.func("pfhg").set("fununit","1");
 }
  public static Model run()throws Exception {
    Model m=ModelUtil.create("free_coreshell_pfp_fine_3d");
    m.label("Theory 2: full 3D PFP/gel finite-energy coupling - freely responding radius and shape");m.modelPath(ROOT+"scratch");
    m.param().set("a","300[nm]","Reference cavity radius");
    m.param().set("B","20","Outer radius / cavity radius");m.param().set("BK","1000","Bulk/shear modulus control");
    m.param().set("G","10[kPa]","Reference PAAm shear modulus; E approximately 30 kPa");m.param().set("lam","1.8","Analytic verification target and initial guess only; no displacement constraint");
    m.component().create("c",true);m.component("c").geom().create("g",3);
    for(String s:new String[]{"outer","inner"}) {m.component("c").geom("g").create(s,"Sphere");m.component("c").geom("g").feature(s).set("r",s.equals("outer")?"B*a":"a");}
    m.component("c").geom("g").create("dif","Difference");m.component("c").geom("g").feature("dif").selection("input").set("outer");m.component("c").geom("g").feature("dif").selection("input2").set("inner");m.component("c").geom("g").run();
    m.component("c").selection().create("cavity","Box");m.component("c").selection("cavity").set("entitydim",2);m.component("c").selection("cavity").set("condition","inside");
    for(String q:new String[]{"x","y","z"}) {m.component("c").selection("cavity").set(q+"min","-1.001*a");m.component("c").selection("cavity").set(q+"max","1.001*a");}
    System.out.println("CAVITY="+Arrays.toString(m.component("c").selection("cavity").entities(2)));
    m.save(ROOT+"scratch/free_coreshell3d_fine_geometry.mph");
    m.component("c").physics().create("solid","SolidMechanics","g");m.component("c").physics("solid").create("hyp","HyperelasticModel",3);m.component("c").physics("solid").feature("hyp").selection().all();
    m.component("c").physics("solid").feature("hyp").set("MaterialModel","NeoHookean");
    m.component("c").physics("solid").feature("hyp").set("Compressibility_NeoHookean","NearlyIncompressible");
    m.component("c").physics("solid").feature("hyp").set("MixedFormulation","pFormulation");m.component("c").physics("solid").feature("hyp").set("IsotropicOption","KG");
    m.component("c").physics("solid").feature("hyp").set("kappa","BK*G");
    m.component("c").physics("solid").feature("hyp").set("G_mat","userdef");m.component("c").physics("solid").feature("hyp").set("G","G");
    m.component("c").physics("solid").feature("hyp").set("K_mat","userdef");m.component("c").physics("solid").feature("hyp").set("K","BK*G");
    m.component("c").physics("solid").feature("hyp").set("rho_mat","userdef");m.component("c").physics("solid").feature("hyp").set("rho","1006.5[kg/m^3]");
    String f="(((X^2+Y^2+Z^2)^(3/2)+a^3*(lam^3-1))^(1/3)/sqrt(X^2+Y^2+Z^2)-1)";
    m.component("c").physics("solid").feature("init1").set("u",new String[]{f+"*X",f+"*Y",f+"*Z"});
    m.component("c").cpl().create("ic","Integration");m.component("c").cpl("ic").selection().geom("g",2);m.component("c").cpl("ic").selection().named("cavity");m.component("c").cpl("ic").set("frame","material");
    m.component("c").cpl().create("iv","Integration");m.component("c").cpl("iv").selection().geom("g",3);m.component("c").cpl("iv").selection().all();m.component("c").cpl("iv").set("frame","material");
    m.component("c").mesh().create("mesh","g");
    m.component("c").mesh("mesh").feature("size").set("custom",true);m.component("c").mesh("mesh").feature("size").set("hmax","B*a/4");
    m.component("c").mesh("mesh").feature("size").set("hmin","a/6");m.component("c").mesh("mesh").feature("size").set("hgrad",1.45);m.component("c").mesh("mesh").feature("size").set("hcurve",0.25);
    m.component("c").mesh("mesh").create("local","Size");m.component("c").mesh("mesh").feature("local").selection().geom("g",2);m.component("c").mesh("mesh").feature("local").selection().named("cavity");
    m.component("c").mesh("mesh").feature("local").set("custom",true);m.component("c").mesh("mesh").feature("local").set("hmaxactive",true);m.component("c").mesh("mesh").feature("local").set("hmax","a/5");
    m.component("c").mesh("mesh").create("tet","FreeTet");m.component("c").mesh("mesh").run();m.save(ROOT+"scratch/free_coreshell3d_fine_meshed.mph");

    m.param().set("sigTest","sigLL","Reference constant surface energy coefficient");
    m.param().set("pLoad","G/2*(5-4/lam-lam^(-4))+2*sigTest/(a*lam)","Known pressure for the independent spherical elastic/capillary control");
    m.component("c").physics("solid").create("rms","RigidMotionSuppression",3);m.component("c").physics("solid").feature("rms").selection().all();
    m.component("c").physics("solid").create("pressure","BoundaryLoad",2);m.component("c").physics("solid").feature("pressure").selection().named("cavity");m.component("c").physics("solid").feature("pressure").set("forceType","FollowerPressure");m.component("c").physics("solid").feature("pressure").set("pressure","pLP-p0");
    m.component("c").variable().create("surfenergy");
    String[] xyz={"X","Y","Z"};String[] uu={"u","v","w"};
    for(int i=0;i<3;i++)for(int j=0;j<3;j++)m.component("c").variable("surfenergy").set("F"+(i+1)+(j+1)+"p",(i==j?"1+":"")+"mean(d("+uu[i]+","+xyz[j]+"))");
    for(int i=0;i<3;i++)for(int j=0;j<3;j++) {
      int r1=(i+1)%3+1,r2=(i+2)%3+1,c1=(j+1)%3+1,c2=(j+2)%3+1;
      m.component("c").variable("surfenergy").set("CF"+(i+1)+(j+1),"F"+r1+c1+"p*F"+r2+c2+"p-F"+r1+c2+"p*F"+r2+c1+"p");
    }
    m.component("c").variable("surfenergy").set("JF","F11p*CF11+F12p*CF12+F13p*CF13");
    for(int i=1;i<=3;i++) {
      m.component("c").variable("surfenergy").set("CN"+i,"-(CF"+i+"1*X+CF"+i+"2*Y+CF"+i+"3*Z)/a");
    }
    m.component("c").variable("surfenergy").set("Js","sqrt(CN1^2+CN2^2+CN3^2)");
    for(int i=1;i<=3;i++)m.component("c").variable("surfenergy").set("ns"+i,"CN"+i+"/Js");
    String weak="";
    for(int i=1;i<=3;i++)for(int j=1;j<=3;j++) {
      String proj="CF"+i+j+"-ns"+i+"*(ns1*CF1"+j+"+ns2*CF2"+j+"+ns3*CF3"+j+")";
      weak+="-sigTest*Js/JF*("+proj+")*test(dtang("+uu[i-1]+","+xyz[j-1]+"))";
    }
    m.component("c").physics("solid").create("surface","WeakContribution",2);m.component("c").physics("solid").feature("surface").selection().named("cavity");m.component("c").physics("solid").feature("surface").set("quadratureFrame","material");m.component("c").physics("solid").feature("surface").set("weakExpression",weak);
    m.component("c").variable("surfenergy").set("Vfree","-ic((X+u)*CN1+(Y+v)*CN2+(Z+w)*CN3)/3");
    m.component("c").variable("surfenergy").set("Rfree","(3*Vfree/(4*pi))^(1/3)");m.component("c").variable("surfenergy").set("Afree","ic(Js)");
    m.param().set("Qdep","11.55[pJ]","Net retained subsystem energy after supplied activation; no optical efficiency inferred");
    installEOS(m);
    m.param().set("sigLV","0.00941[N/m]","PFP / saturated-air room-temperature reference; heated/nanoscale use is conditional");
    m.param().set("nucleusFloor","a/100","Numerical radius floor only; accepted states must be far above it");
    m.param().set("sigLL","0.054[N/m]","Pure PFP/water liquid-liquid reference; actual surfactant formulation is unresolved");
    m.param().set("Tref","293.15[K]");m.param().set("rhoLref","1621.2304497568995[kg/m^3]");m.param().set("rhoVref","8.781946533312483[kg/m^3]");
    m.param().set("ad","a","Equivalent PFP droplet radius; distinct from the preformed cavity radius a");
    m.param().set("rhoD","1623.3028161533516[kg/m^3]");m.param().set("mp","4*pi*ad^3*rhoD/3");
    m.param().set("p0","100[kPa]");m.param().set("sig","sigLL","Unused legacy alias: assumed PFP/gel outer coefficient; active loads use sigLL");
    m.param().set("lamFail","2.1","PAAm ultimate-stretch reference from Movahed 2016, not a certification of Li 2024 formulation");
    m.component("c").variable().create("thermo");
    String radial="(solid.sxx*(X/a)^2+solid.syy*(Y/a)^2+solid.szz*(Z/a)^2+2*solid.sxy*X*Y/a^2+2*solid.sxz*X*Z/a^2+2*solid.syz*Y*Z/a^2)";
    m.component("c").variable("thermo").set("pGel","pLP-p0-2*sigLL/Rfree");
    m.component("c").variable("thermo").set("Temp","Tref*theta");
    m.component("c").variable("thermo").set("rhoLP","rhoLref*exp(qL)");m.component("c").variable("thermo").set("rhoVP","rhoVref*exp(qV)");
    m.component("c").variable("thermo").set("Vb","Vfree");
    m.component("c").variable("thermo").set("pNeed","pLP");
    m.component("c").variable("thermo").set("pLP","pfpp(Temp/1[K],rhoLP/(1[kg/m^3]))*1[Pa]");m.component("c").variable("thermo").set("pVP","pfpp(Temp/1[K],rhoVP/(1[kg/m^3]))*1[Pa]");
    m.component("c").variable("thermo").set("gLP","pfpg(Temp/1[K],rhoLP/(1[kg/m^3]))*1[J/kg]");m.component("c").variable("thermo").set("gVP","pfpg(Temp/1[K],rhoVP/(1[kg/m^3]))*1[J/kg]");
    m.component("c").variable("thermo").set("uLP","pfpu(Temp/1[K],rhoLP/(1[kg/m^3]))*1[J/kg]");m.component("c").variable("thermo").set("uVP","pfpu(Temp/1[K],rhoVP/(1[kg/m^3]))*1[J/kg]");
    m.component("c").variable("thermo").set("fv","(Vb-mp/rhoLP)/(mp*(1/rhoVP-1/rhoLP))");
    m.component("c").variable("thermo").set("fvDropSized","(Vb-(4*pi*a^3*rhoD/3)/rhoLP)/((4*pi*a^3*rhoD/3)*(1/rhoVP-1/rhoLP))");
    m.component("c").variable("thermo").set("UP","mp*((1-fv)*uLP+fv*uVP)");
    m.component("c").variable("thermo").set("Vgas","fv*mp/rhoVP");
    m.component("c").variable("thermo").set("Rg","(max(Vgas,4*pi*nucleusFloor^3/3)*3/(4*pi))^(1/3)");
    m.component("c").variable("thermo").set("shellThickness","Rfree-Rg");
    m.component("c").variable("thermo").set("WsTotal","iv(solid.Ws)");
    m.component("c").variable("thermo").set("Qmin","UP-mp*pfpu(Tref/1[K],rhoD/(1[kg/m^3]))*1[J/kg]+WsTotal+p0*(Vb-4*pi*ad^3/3)+sigLL*Afree+4*pi*sigLV*Rg^2-4*pi*sigLL*ad^2");
    m.component("c").variable("thermo").set("massResidual","(rhoVP*(Vb-(1-fv)*mp/rhoLP)-fv*mp)/mp");
    m.component("c").physics().create("ge","GlobalEquations");
    m.component("c").physics("ge").feature("ge1").set("name",new String[]{"theta","qL","qV"});
    m.component("c").physics("ge").feature("ge1").set("equation",new String[]{"(pVP-pLP-2*sigLV/Rg)/p0","(gLP-gVP)/(100[kJ/kg])","(Qmin-Qdep)/(mp*100[kJ/kg])"});
    m.component("c").physics("ge").feature("ge1").set("initialValueU",new String[]{"1.1655711769961976","-0.11475258143625314","1.5473196370961337"});m.component("c").physics("ge").feature("ge1").set("initialValueUt",new String[]{"0","0","0"});


    m.component("c").cpl().create("maxd","Maximum");m.component("c").cpl("maxd").selection().geom("g",3);m.component("c").cpl("maxd").selection().all();
    m.component("c").variable().create("post");m.component("c").variable("post").set("stretch","Rfree/a");
    String[] coords={"X","Y","Z"};String[] disp={"u","v","w"};
    for(int i=0;i<3;i++)for(int j=0;j<3;j++)m.component("c").variable("post").set("F"+(i+1)+(j+1)+"d",(i==j?"1+":"")+"d("+disp[i]+","+coords[j]+")");
    for(int i=1;i<=3;i++)for(int j=i;j<=3;j++) {
      String e="";for(int k=1;k<=3;k++)e+=(k>1?"+":"")+"F"+k+i+"d*F"+k+j+"d";
      m.component("c").variable("post").set("C"+i+j+"d",e);
    }
    m.component("c").variable("post").set("qd","(C11d+C22d+C33d)/3");m.component("c").variable("post").set("pd","sqrt(max(1e-24,((C11d-qd)^2+(C22d-qd)^2+(C33d-qd)^2+2*(C12d^2+C13d^2+C23d^2))/6))");
    String det="(C11d-qd)*(C22d-qd)*(C33d-qd)+2*C12d*C13d*C23d-(C11d-qd)*C23d^2-(C22d-qd)*C13d^2-(C33d-qd)*C12d^2";
    m.component("c").variable("post").set("rd","min(1,max(-1,("+det+")/(2*pd^3)))");m.component("c").variable("post").set("stretchMax","sqrt(max(0,qd+2*pd*cos(acos(rd)/3)))");
    m.study().create("std");m.study("std").label("Retained-energy-driven partial PFP phase state and unconstrained 3D gel deformation");m.study("std").create("stat","Stationary");m.study("std").feature("stat").set("geometricNonlinearity",true);
    m.study("std").feature("stat").set("useparam","on");m.study("std").feature("stat").set("pname",new String[]{"Qdep"});m.study("std").feature("stat").set("plistarr",new String[]{"11.55 11.65 11.75 11.82 11.9"});m.study("std").feature("stat").set("punit",new String[]{"pJ"});m.study("std").feature("stat").set("preusesol","yes");m.study("std").createAutoSequences("all");
    m.sol("sol1").feature("v1").feature("c_u").set("scalemethod","manual");m.sol("sol1").feature("v1").feature("c_u").set("scaleval","a");m.sol("sol1").feature("v1").feature("c_solid_hyp_pw").set("scalemethod","manual");m.sol("sol1").feature("v1").feature("c_solid_hyp_pw").set("scaleval","G");m.sol("sol1").feature("v1").feature("c_ODE1").set("scalemethod","manual");m.sol("sol1").feature("v1").feature("c_ODE1").set("scaleval","1");
    m.sol("sol1").feature("s1").create("directAll","Direct");m.sol("sol1").feature("s1").feature("directAll").set("linsolver","pardiso");m.sol("sol1").feature("s1").create("coupledAll","FullyCoupled");m.sol("sol1").feature("s1").feature("coupledAll").set("linsolver","directAll");m.sol("sol1").feature("s1").feature("coupledAll").set("maxiter",50);m.sol("sol1").feature("s1").set("stol","1e-7");
    if(Arrays.asList(m.sol("sol1").feature("s1").feature().tags()).contains("se1"))m.sol("sol1").feature("s1").feature().remove("se1");
    m.save(ROOT+"scratch/free_coreshell3d_fine_configured.mph");try{m.sol("sol1").runAll();}catch(Exception e){m.save(ROOT+"scratch/free_coreshell3d_fine_failed.mph");throw e;}
    m.save(ROOT+"scratch/free_coreshell3d_fine_solved.mph");
    m.result().table().create("tbl","Table");m.result().numerical().create("eval","EvalGlobal");m.result().numerical("eval").set("table","tbl");
    String[] ex={"Qdep","c.stretch","c.Temp","c.pLP","c.pVP","c.rhoLP","c.rhoVP","c.fv","c.Rg","c.shellThickness","c.Qmin","(c.Qmin-Qdep)/Qdep","c.massResidual","c.pVP-c.pLP-2*sigLV/c.Rg","c.gLP-c.gVP","c.pGel","G/2*(5-4/c.stretch-c.stretch^(-4))","c.WsTotal","2*pi*G*a^3*(5*c.stretch^3/3-2*c.stretch^2+1/c.stretch-2/3)","c.Afree/(4*pi*c.Rfree^2)","c.maxd(c.stretchMax)","c.maxd(c.stretchMax)/lamFail","c.Rg/nucleusFloor"};
    m.result().numerical("eval").set("expr",ex);m.result().numerical("eval").set("descr",ex);m.result().numerical("eval").setResult();m.result().table("tbl").save(ROOT+"data/free_coreshell3d_fine_control.csv");m.save(ROOT+"scratch/free_coreshell3d_fine_solved.mph");System.out.println("FREE_ENERGY_PFP_GEL_3D_SOLVED="+Arrays.toString(m.sol("sol1").getSize()));return m;
  }
  public static void main(String[]args)throws Exception{run();}
}
