Changeset 26312


Ignore:
Timestamp:
06/09/21 15:22:43 (4 years ago)
Author:
jdquinn
Message:

CHG: Diff merge of materials class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/materials.js

    r26308 r26312  
    1 class materials {//{{{
     1class materials {
    22        /**
    33         * MATERIALS class definition
     
    1111                let nargs = arguments.length;
    1212                if (nargs == 0) {
    13                         this.nature = ['ice'];
     13                        this.nature=['ice'];
    1414                } else {
    15                         this.nature = arguments;
     15                        this.nature=arguments;
    1616                }
    1717
     
    2424
    2525                // Start filling in the dynamic fields (not truly dynamic under JavaScript)
    26                 for (let i = 0; i < this.nature.length; ++i) {
    27                         let nat = this.nature[i];
    28                         if (nat == 'ice') {
    29                                 this.rho_ice = 0;
    30                                 this.rho_water = 0;
    31                                 this.rho_freshwater = 0;
    32                                 this.mu_water = 0;
    33                                 this.heatcapacity = 0;
    34                                 this.latentheat = 0;
    35                                 this.thermalconductivity = 0;
    36                                 this.temperateiceconductivity = 0;
    37                                 this.effectiveconductivity_averaging = 0;
    38                                 this.meltingpoint = 0;
    39                                 this.beta = 0;
    40                                 this.mixed_layer_capacity = 0;
    41                                 this.thermal_exchange_velocity = 0;
    42                                 this.rheology_B = 0;
    43                                 this.rheology_n = 0;
    44                                 this.rheology_law = 0;
    45                         } else if (nat == 'litho') {
    46                                 this.numlayers = 0;
    47                                 this.radius = 0;
    48                                 this.viscosity = 0;
    49                                 this.lame_lambda = 0;
    50                                 this.lame_mu = 0;
    51                                 this.burgers_viscosity = 0;
    52                                 this.burgers_mu = 0;
    53                                 this.ebm_alpha = 0;
    54                                 this.ebm_delta = 0;
    55                                 this.ebm_taul = 0;
    56                                 this.ebm_tauh = 0;
    57                                 this.rheologymodel = 0;
    58                                 this.density = 0;
    59                                 this.issolid = 0;
    60                         } else if (nat == 'hydro') {
    61                                 this.rho_ice = 0;
    62                                 this.rho_water = 0;
    63                                 this.rho_freshwater = 0;
    64                         } else {
    65                                 error('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')');
    66                         }
    67                 }
    68                 this.earth_density = 0;
    69 
    70                 // Set default parameters
    71                 this.setdefaultparameters();
    72         } //}}}
    73 
     26                for (let i = 0; i < length(this.nature); ++i) {
     27                        let nat = this.nature[i];
     28                        switch (nat) {
     29                                case 'ice':
     30                                        this.rho_ice = 0;
     31                                        this.rho_water = 0;
     32                                        this.rho_freshwater = 0;
     33                                        this.mu_water = 0;
     34                                        this.heatcapacity = 0;
     35                                        this.latentheat = 0;
     36                                        this.thermalconductivity = 0;
     37                                        this.temperateiceconductivity = 0;
     38                                        this.effectiveconductivity_averaging = 0;
     39                                        this.meltingpoint = 0;
     40                                        this.beta = 0;
     41                                        this.mixed_layer_capacity = 0;
     42                                        this.thermal_exchange_velocity = 0;
     43                                        this.rheology_B = 0;
     44                                        this.rheology_n = 0;
     45                                        this.rheology_law = 0;
     46                                        break;
     47                                case 'litho':
     48                                        this.numlayers = 0;
     49                                        this.radius = 0;
     50                                        this.viscosity = 0;
     51                                        this.lame_lambda = 0;
     52                                        this.lame_mu = 0;
     53                                        this.burgers_viscosity = 0;
     54                                        this.burgers_mu = 0;
     55                                        this.ebm_alpha = 0;
     56                                        this.ebm_delta = 0;
     57                                        this.ebm_taul = 0;
     58                                        this.ebm_tauh = 0;
     59                                        this.rheologymodel = 0;
     60                                        this.density = 0;
     61                                        this.issolid = 0;
     62                                        break;
     63                                case 'hydro':
     64                                        this.rho_ice = 0;
     65                                        this.rho_water = 0;
     66                                        this.rho_freshwater = 0;
     67                                        break;
     68                                default:
     69                                        error('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')');
     70                        }
     71                        this.earth_density = 0;
     72
     73                        // Set default parameters
     74                        this.setdefaultparameters();
     75                }
     76        } //}}}
    7477        disp() {//{{{
    75                 console.log('WARNING: materials::disp is not yet implemented');
    76         } //}}}
    77 
     78                console.log(sprintf('   Materials:'));
     79
     80                for (let i = 0; i < length(this.nature); ++i) {
     81                        let nat = this.nature[i];
     82                        switch (nat) {
     83                                case 'ice':
     84                                        console.log(sprintf('   \nIce:'));
     85                                        fielddisplay(this,'rho_ice','ice density [kg/m^3]');
     86                                        fielddisplay(this,'rho_water','ocean water density [kg/m^3]');
     87                                        fielddisplay(this,'rho_freshwater','fresh water density [kg/m^3]');
     88                                        fielddisplay(this,'mu_water','water viscosity [N s/m^2]');
     89                                        fielddisplay(this,'heatcapacity','heat capacity [J/kg/K]');
     90                                        fielddisplay(this,'thermalconductivity','ice thermal conductivity [W/m/K]');
     91                                        fielddisplay(this,'temperateiceconductivity','temperate ice thermal conductivity [W/m/K]');
     92                                        fielddisplay(this,'meltingpoint','melting point of ice at 1atm in K');
     93                                        fielddisplay(this,'latentheat','latent heat of fusion [J/kg]');
     94                                        fielddisplay(this,'beta','rate of change of melting point with pressure [K/Pa]');
     95                                        fielddisplay(this,'mixed_layer_capacity','mixed layer capacity [W/kg/K]');
     96                                        fielddisplay(this,'thermal_exchange_velocity','thermal exchange velocity [m/s]');
     97                                        fielddisplay(this,'rheology_B','flow law parameter [Pa s^(1/n)]');
     98                                        fielddisplay(this,'rheology_n','Glen\'s flow law exponent');
     99                                        fielddisplay(this,'rheology_law','law for the temperature dependance of the rheology: \'None\', \'BuddJacka\', \'Cuffey\', \'CuffeyTemperate\', \'Paterson\', \'Arrhenius\', \'LliboutryDuval\', \'NyeCO2\', or \'NyeH2O\'');
     100                                        break;
     101                                case 'litho':
     102                                        console.log(sprintf('   \nLitho:'));
     103                                        fielddisplay(this,'numlayers','number of layers (default: 2)');
     104                                        fielddisplay(this,'radius','array describing the radius for each interface (numlayers+1) [m]');
     105                                        fielddisplay(this,'viscosity','array describing each layer\'s viscosity (numlayers) [Pa.s]');
     106                                        fielddisplay(this,'lame_lambda','array describing the lame lambda parameter (numlayers) [Pa]');
     107                                        fielddisplay(this,'lame_mu','array describing the shear modulus for each layers (numlayers) [Pa]');
     108                                        fielddisplay(this,'burgers_viscosity','array describing each layer\'s transient viscosity, only for Burgers rheologies  (numlayers) [Pa.s]');
     109                                        fielddisplay(this,'burgers_mu','array describing each layer\'s transient shear modulus, only for Burgers rheologies  (numlayers) [Pa]');
     110
     111                                        fielddisplay(this,'ebm_alpha','array describing each layer\'s exponent parameter controlling the shape of shear modulus curve between taul and tauh, only for EBM rheology (numlayers)');
     112                                        fielddisplay(this,'ebm_delta','array describing each layer\'s amplitude of the transient relaxation (ratio between elastic rigity to pre-maxwell relaxation rigity), only for EBM rheology (numlayers)');
     113                                        fielddisplay(this,'ebm_taul','array describing each layer\'s starting period for transient relaxation, only for EBM rheology  (numlayers) [s]');
     114                                        fielddisplay(this,'ebm_tauh','array describing each layer\'s array describing each layer\'s end period for transient relaxation, only for Burgers rheology (numlayers) [s]');
     115
     116                                        fielddisplay(this,'rheologymodel','array describing whether we adopt a Maxwell (0), Burgers (1) or EBM (2) rheology (default: 0)');
     117                                        fielddisplay(this,'density','array describing each layer\'s density (numlayers) [kg/m^3]');
     118                                        fielddisplay(this,'issolid','array describing whether the layer is solid or liquid (default 1) (numlayers)');
     119                                        break;
     120                                case 'hydro':
     121                                        console.log(sprintf('   \nHydro:'));
     122                                        fielddisplay(this,'rho_ice','ice density [kg/m^3]');
     123                                        fielddisplay(this,'rho_water','ocean water density [kg/m^3]');
     124                                        fielddisplay(this,'earth_density','mantle density [kg/m^3]');
     125                                        fielddisplay(this,'rho_freshwater','fresh water density [kg/m^3]');
     126                                        break;
     127                                default:
     128                                        error('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')');
     129                        }
     130                }
     131        } //}}}
    78132        setdefaultparameters() {//{{{
    79133                for (let i = 0; i < this.nature.length; ++i) {
    80134                        let nat = this.nature[i];
    81                         if (nat == 'ice') {
    82                                 // Ice density (kg/m^3)
    83                                 this.rho_ice = 917;
    84 
    85                                 // Ocean water density (kg/m^3)
    86                                 this.rho_water = 1023
    87 
    88                                 // Fresh water density (kg/m^3)
    89                                 this.rho_freshwater = 1000;
    90 
    91                                 // Water viscosity (N.s/m^2)
    92                                 this.mu_water = 0.001787;
    93 
    94                                 // Ice heat capacity cp (J/kg/K)
    95                                 this.heatcapacity = 2093;
    96 
    97                                 // Ice latent heat of fusion L (J/kg)
    98                                 this.latentheat = 3.34 * 1e5;
    99 
    100                                 // Ice thermal conductivity (W/m/K)
    101                                 this.thermalconductivity = 2.4;
    102 
    103                                 // Wet ice thermal conductivity (W/m/K)
    104                                 this.temperateiceconductivity = 0.24;
    105 
    106                                 // Computation of effective conductivity
    107                                 this.effectiveconductivity_averaging = 1;
    108 
    109                                 // The melting point of ice at 1 atmosphere of pressure in K
    110                                 this.meltingpoint = 273.15;
    111 
    112                                 // Rate of change of melting point with pressure (K/Pa)
    113                                 this.beta = 9.8 * 1e-8;
    114 
    115                                 // Mixed layer (ice-water interface) heat capacity (J/kg/K)
    116                                 this.mixed_layer_capacity = 3974;
    117 
    118                                 // Thermal exchange velocity (ice-water interface) (m/s)
    119                                 this.thermal_exchange_velocity = 1.00 * 1e-4;
    120 
    121                                 // Rheology law: what is the temperature dependence of B with T
    122                                 // available: none, paterson and arrhenius
    123                                 this.rheology_law = 'Paterson';
    124 
    125                                 // Rheology fields default
    126                                 this.rheology_B = 1 * 1e8;
    127                                 this.rheology_n = 3;
    128                         } else if (nat == 'litho') {
    129                                 // We default to a configuration that enables running GIA
    130                                 // solutions using giacaron and/or giaivins
    131                                 this.numlayers = 2;
    132 
    133                                 // Center of the earth (approximation, must not be 0), then the
    134                                 // lab (lithosphere/asthenosphere boundary) then the surface
    135                                 // (with 1d3 to avoid numerical singularities)
    136                                 this.radius = [1e3, 6278 * 1e3, 6378 * 1e3];
    137 
    138                                 this.viscosity = [1e21, 1e40]; // Mantle and lithosphere viscosity (respectively) [Pa.s]
    139                                 this.lame_mu = [1.45 * 1e11, 6.7 * 1e10]; // (Pa) // Lithosphere and mantle shear modulus (respectively) [Pa]
    140                                 this.lame_lambda = this.lame_mu; // (Pa) // Mantle and lithosphere lamba parameter (respectively) [Pa]
    141                                 this.burgers_viscosity = [NaN, NaN];
    142                                 this.burgers_mu = [NaN, NaN];
    143 
    144                                 this.ebm_alpha = [NaN, NaN];
    145                                 this.ebm_delta = [NaN, NaN];
    146                                 this.ebm_taul = [NaN, NaN];
    147                                 this.ebm_tauh = [NaN, NaN];
    148                                 this.rheologymodel = [0, 0];
    149                                 this.density = [5.51 * 1e3, 5.50 * 1e3]; // (Pa) // Mantle and lithosphere density [kg/m^3]
    150                                 this.issolid = [1, 1]; // Is layer solid or liquid?
    151                         } else if (nat == 'hydro') {
    152                                 // Ice density (kg/m^3)
    153                                 this.rho_ice = 917;
    154 
    155                                 // Ocean water density (kg/m^3)
    156                                 this.rho_water = 1023;
    157 
    158                                 // Fresh water density (kg/m^3)
    159                                 this.rho_freshwater = 1000;
    160                         } else {
    161                                 error('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')');
     135                        switch (nat) {
     136                                case 'ice':
     137                                        // Ice density (kg/m^3)
     138                                        this.rho_ice = 917;
     139
     140                                        // Ocean water density (kg/m^3)
     141                                        this.rho_water = 1023
     142
     143                                        // Fresh water density (kg/m^3)
     144                                        this.rho_freshwater = 1000;
     145
     146                                        // Water viscosity (N.s/m^2)
     147                                        this.mu_water = 0.001787;
     148
     149                                        // Ice heat capacity cp (J/kg/K)
     150                                        this.heatcapacity = 2093;
     151
     152                                        // Ice latent heat of fusion L (J/kg)
     153                                        this.latentheat = 3.34 * 1e5;
     154
     155                                        // Ice thermal conductivity (W/m/K)
     156                                        this.thermalconductivity = 2.4;
     157
     158                                        // Wet ice thermal conductivity (W/m/K)
     159                                        this.temperateiceconductivity = 0.24;
     160
     161                                        // Computation of effective conductivity
     162                                        this.effectiveconductivity_averaging = 1;
     163
     164                                        // The melting point of ice at 1 atmosphere of pressure in K
     165                                        this.meltingpoint = 273.15;
     166
     167                                        // Rate of change of melting point with pressure (K/Pa)
     168                                        this.beta = 9.8 * 1e-8;
     169
     170                                        // Mixed layer (ice-water interface) heat capacity (J/kg/K)
     171                                        this.mixed_layer_capacity = 3974;
     172
     173                                        // Thermal exchange velocity (ice-water interface) (m/s)
     174                                        this.thermal_exchange_velocity = 1.00 * 1e-4;
     175
     176                                        // Rheology law: what is the temperature dependence of B with T
     177                                        // available: none, paterson and arrhenius
     178                                        this.rheology_law = 'Paterson';
     179
     180                                        // Rheology fields default
     181                                        this.rheology_B = 1 * 1e8;
     182                                        this.rheology_n = 3;
     183                                        break;
     184                                case 'litho':
     185                                        // We default to a configuration that enables running GIA
     186                                        // solutions using giacaron and/or giaivins
     187                                        this.numlayers = 2;
     188
     189                                        // Center of the earth (approximation, must not be 0), then the
     190                                        // lab (lithosphere/asthenosphere boundary) then the surface
     191                                        // (with 1d3 to avoid numerical singularities)
     192                                        this.radius = [1e3, 6278 * 1e3, 6378 * 1e3];
     193
     194                                        this.viscosity = [1e21, 1e40]; // Mantle and lithosphere viscosity (respectively) [Pa.s]
     195                                        this.lame_mu = [1.45 * 1e11, 6.7 * 1e10]; // (Pa) // Lithosphere and mantle shear modulus (respectively) [Pa]
     196                                        this.lame_lambda = this.lame_mu; // (Pa) // Mantle and lithosphere lamba parameter (respectively) [Pa]
     197                                        this.burgers_viscosity = [NaN, NaN];
     198                                        this.burgers_mu = [NaN, NaN];
     199
     200                                        this.ebm_alpha = [NaN, NaN];
     201                                        this.ebm_delta = [NaN, NaN];
     202                                        this.ebm_taul = [NaN, NaN];
     203                                        this.ebm_tauh = [NaN, NaN];
     204                                        this.rheologymodel = [0, 0];
     205                                        this.density = [5.51 * 1e3, 5.50 * 1e3]; // (Pa) // Mantle and lithosphere density [kg/m^3]
     206                                        this.issolid = [1, 1]; // Is layer solid or liquid?
     207                                        break;
     208                                case 'hydro':
     209                                        // Ice density (kg/m^3)
     210                                        this.rho_ice = 917;
     211
     212                                        // Ocean water density (kg/m^3)
     213                                        this.rho_water = 1023;
     214
     215                                        // Fresh water density (kg/m^3)
     216                                        this.rho_freshwater = 1000;
     217                                        break;
     218                                default:
     219                                        error('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')');
    162220                        }
    163221
    164222                        // Average density of the Earth (kg/m^3)
    165                         this.earth_density=5512;
    166                 }
    167         } //}}}
    168 
     223                        this.earth_density = 5512;
     224                }
     225        } //}}}
    169226        checkconsistency(md, solution, analyses) {//{{{
    170227                for (let i = 0; i < this.nature.length; ++i) {
     
    225282                return md;
    226283        } //}}}
    227 
    228284        marshall(md, prefix, fid) {//{{{
    229285                // 1: MatdamageiceEnum 2: MatestarEnum 3: MaticeEnum 4: MatenhancediceEnum 5: MaterialsEnum
     
    281337                }
    282338        } //}}}
    283 
    284339        extrude(md) {//{{{
    285340                for (let i = 0; i < this.nature.length; ++i) {
     
    296351        let intnat = zeros(strnat.length, 1);
    297352        for (let i = 0; i < strnat.length; ++i) {
    298                 let str_nat = strnat[i];
    299                 if (str_nat == 'damageice') {
    300                         intnat[i] = 1;
    301                 } else if (str_nat == 'estar') {
    302                         intnat[i] = 2;
    303                 } else if (str_nat == 'ice') {
    304                         intnat[i] = 3;
    305                 } else if (str_nat == 'enhancedice') {
    306                         intnat[i] = 4;
    307                 //} else if (str_nat == 'materials') { // This case will never happen, kept to ensure equivalent of codes between IoCodeToMaterialsEnum and IoCodeToNatureEnum
    308                 //      intnat[i] = 5;
    309                 } else if (str_nat == 'litho') {
    310                         intnat[i] = 6;
    311                 } else if (str_nat == 'hydro') {
    312                         intnat[i] = 7;
    313                 } else {
    314                         error('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')');
     353                switch (strnat[i]) {
     354                        case 'damageice':
     355                                intnat[i] = 1;
     356                                break;
     357                        case 'estar':
     358                                intnat[i] = 2;
     359                                break;
     360                        case 'ice':
     361                                intnat[i] = 3;
     362                                break;
     363                        case 'enhancedice':
     364                                intnat[i] = 4;
     365                                break;
     366                        //case 'materials': // This case will never happen, kept to ensure equivalent of codes between IoCodeToMaterialsEnum and IoCodeToNatureEnum
     367                        //      intnat[i] = 5;
     368                        //      break;
     369                        case 'litho':
     370                                intnat[i] = 6;
     371                                break;
     372                        case 'hydro':
     373                                intnat[i] = 7;
     374                                break;
     375                        default:
     376                                error('materials constructor error message: nature of the material not supported yet! (\'ice\' or \'litho\' or \'hydro\')');
    315377                }
    316378        }
    317379        return intnat;
    318 } //}}}
     380}// }}}
Note: See TracChangeset for help on using the changeset viewer.