Changeset 25129


Ignore:
Timestamp:
06/23/20 21:34:00 (5 years ago)
Author:
jdquinn
Message:

CHG: Saving progress on MATLAB to Python translations (still need to track down marshalling bug on Python side)

Location:
issm/trunk-jpl
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/m/classes/giaivins.m

    r25056 r25129  
    1111        end
    1212        methods
    13                 function self = extrude(self,md) % {{{
    14                         self.mantle_viscosity=project3d(md,'vector',self.mantle_viscosity,'type','node');
    15                         self.lithosphere_thickness=project3d(md,'vector',self.lithosphere_thickness,'type','node');
    16                 end % }}}
    1713                function self = giaivins(varargin) % {{{
    1814                        switch nargin
     
    7066
    7167                end % }}}
     68                function self = extrude(self,md) % {{{
     69                        self.mantle_viscosity=project3d(md,'vector',self.mantle_viscosity,'type','node');
     70                        self.lithosphere_thickness=project3d(md,'vector',self.lithosphere_thickness,'type','node');
     71                end % }}}
    7272        end
    7373end
  • TabularUnified issm/trunk-jpl/src/m/classes/giaivins.py

    r24213 r25129  
     1import numpy as np
     2
     3from checkfield import checkfield
    14from fielddisplay import fielddisplay
    25from project3d import project3d
    3 from checkfield import checkfield
    46from WriteData import WriteData
    57
     
    79class giaivins(object):
    810    """
    9     GIA class definition
     11    GIA class definition for Ivins and James model
    1012
    1113       Usage:
     
    1315    """
    1416
    15     def __init__(self):  # {{{
    16         self.mantle_viscosity = float('NaN')
    17         self.lithosphere_thickness = float('NaN')
    18         self.cross_section_shape = 0
     17    def __init__(self, *args): #{{{
     18        self.mantle_viscosity       = np.nan
     19        self.lithosphere_thickness  = np.nan
     20        self.cross_section_shape    = 0
    1921
    20     #set defaults
    21         self.setdefaultparameters()
     22        nargin = len(args)
    2223
     24        if nargin == 0:
     25            self.setdefaultparameters()
     26        else:
     27            raise Exception('constructor not supported')
    2328    #}}}
    2429
    25     def __repr__(self):  # {{{
    26         string = '   giaivins solution parameters:'
     30    def __repr__(self): #{{{
     31        s = '   giaivins solution parameters:'
     32        s += "{}\n".format(fielddisplay(self, 'mantle_viscosity', 'mantle viscosity constraints (NaN means no constraint) (Pa s)'))
     33        s += "{}\n".format(fielddisplay(self, 'lithosphere_thickness', 'lithosphere thickness constraints (NaN means no constraint) (m)'))
     34        s += "{}\n".format(fielddisplay(self, 'cross_section_shape', "1: square-edged, 2: elliptical-sedged surface"))
    2735
    28         string = "%s\n%s" % (string, fielddisplay(self, 'mantle_viscosity', 'mantle viscosity constraints (NaN means no constraint) (Pa s)'))
    29         string = "%s\n%s" % (string, fielddisplay(self, 'lithosphere_thickness', 'lithosphere thickness constraints (NaN means no constraint) (m)'))
    30         string = "%s\n%s" % (string, fielddisplay(self, 'cross_section_shape', "1: square-edged, 2: elliptical - edged surface"))
    31         return string
     36        return s
    3237    #}}}
    3338
    34     def extrude(self, md):  # {{{
    35         self.mantle_viscosity = project3d(md, 'vector', self.mantle_viscosity, 'type', 'node')
    36         self.lithosphere_thickness = project3d(md, 'vector', self.lithosphere_thickness, 'type', 'node')
     39    def setdefaultparameters(self): #{{{
     40        self.cross_section_shape = 1
     41
    3742        return self
    3843    #}}}
    3944
    40     def setdefaultparameters(self):  # {{{
    41         self.cross_section_shape = 1
    42         return self
    43     #}}}
    44 
    45     def checkconsistency(self, md, solution, analyses):  # {{{
    46         # Early return
    47         if ('GiaAnalysis' not in analyses):
     45    def checkconsistency(self, md, solution, analyses): #{{{
     46        if not 'GiaAnalysis' in analyses:
    4847            return md
    4948
     
    5655
    5756        return md
    58     # }}}
     57    #}}}
    5958
    60     def marshall(self, prefix, md, fid):  # {{{
    61 
     59    def marshall(self, prefix, md, fid): #{{{
    6260        WriteData(fid, prefix, 'object', self, 'fieldname', 'mantle_viscosity', 'format', 'DoubleMat', 'mattype', 1)
    6361        WriteData(fid, prefix, 'object', self, 'fieldname', 'lithosphere_thickness', 'format', 'DoubleMat', 'mattype', 1, 'scale', 10.**3.)
    6462        WriteData(fid, prefix, 'object', self, 'fieldname', 'cross_section_shape', 'format', 'Integer')
    65     # }}}
     63    #}}}
     64
     65    def extrude(self, md): #{{{
     66        self.mantle_viscosity = project3d(md, 'vector', self.mantle_viscosity, 'type', 'node')
     67        self.lithosphere_thickness = project3d(md, 'vector', self.lithosphere_thickness, 'type', 'node')
     68        return self
     69    #}}}
  • TabularUnified issm/trunk-jpl/src/m/classes/giamme.m

    r25085 r25129  
    1414        end
    1515        methods
    16                 function self = extrude(self,md) % {{{
    17                         for i=1:length(self.Ngia),
    18                                 self.Ngia{i}=project3d(md,'vector',self.Ngia{i},'type','node','layer',1);
    19                                 self.Ugia{i}=project3d(md,'vector',self.Ugia{i},'type','node','layer',1);
    20                         end
    21                 end % }}}
    2216                function self = giamme(varargin) % {{{
    2317                        switch nargin
     
    7468
    7569                end % }}}
     70                function self = extrude(self,md) % {{{
     71                        for i=1:length(self.Ngia),
     72                                self.Ngia{i}=project3d(md,'vector',self.Ngia{i},'type','node','layer',1);
     73                                self.Ugia{i}=project3d(md,'vector',self.Ugia{i},'type','node','layer',1);
     74                        end
     75                end % }}}
    7676        end
    7777end
  • TabularUnified issm/trunk-jpl/src/m/classes/mesh3dsurface.m

    r24919 r25129  
    7373                function obj = setdefaultparameters(obj) % {{{
    7474
    75                         %the connectivity is the averaged number of nodes linked to a
    76                         %given node through an edge. This connectivity is used to initially
    77                         %allocate memory to the stiffness matrix. A value of 16 seems to
    78                         %give a good memory/time ration. This value can be checked in
    79                         %trunk/test/Miscellaneous/runme.m
     75                        %The connectivity is the average number of nodes linked to a given
     76                        %node through an edge. This connectivity is used to initially
     77                        %allocate memory to the stiffness matrix. A value of 16 seems to 
     78                        %give a good memory/time ratio. This value can be checked in
     79                        %test/NightlyRun/runme.py.
    8080                        obj.average_vertex_connectivity=25;
    8181                end % }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/mesh3dsurface.py

    r24919 r25129  
    99
    1010class mesh3dsurface(object):
    11     #MESH3DSURFACE class definition
    12     #
    13     #   Usage:
    14     #      mesh3dsurface = mesh3dsurface();
     11    '''
     12    MESH3DSURFACE class definition
     13
     14        Usage:
     15            mesh3dsurface = mesh3dsurface()
     16    '''
     17
    1518    def __init__(self, *args): # {{{
    1619        self.x = np.nan
     
    8487    # }}}
    8588
    86     def loadobj(self): # {{{
    87         # This def is directly called by matlab when a model() selfect is
    88         # loaded. Update old properties here
    89 
    90         #2014 Oct. 1st
    91         if isstruct(self):
    92             oldself = self
    93             #Assign property values from struct
    94             self = structtoobj(mesh3dsurface(), oldself)
    95             if isfield(oldself, 'hemisphere'):
    96                 print('md.mesh.hemisphere has been automatically converted to EPSG code')
    97                 if strcmpi(oldself.hemisphere, 'n'):
    98                     self.epsg = 3413
    99                 else:
    100                     self.epsg = 3031
    101         return self
    102     # }}}
    103 
    10489    def setdefaultparameters(self): # {{{
    105         #the connectivity is the averaged number of nodes linked to a
    106         #given node through an edge. This connectivity is used to initially
    107         #allocate memory to the stiffness matrix. A value of 16 seems to
    108         #give a good memory / time ration. This value can be checked in
    109         #trunk / test / Miscellaneous / runme.m
     90        #The connectivity is the average number of nodes linked to a given node
     91        #through an edge. This connectivity is used to initially allocate
     92        #memory to the stiffness matrix. A value of 16 seems to give a good
     93        #memory/time ratio. This value can be checked in
     94        #test/NightlyRun/runme.py.
    11095        self.average_vertex_connectivity = 25
     96
    11197        return self
    11298    # }}}
  • TabularUnified issm/trunk-jpl/src/m/classes/model.py

    r25125 r25129  
    5454from transient import transient
    5555from giaivins import giaivins
     56from giamme import giamme
    5657from esa import esa
    5758from autodiff import autodiff
     
    117118        self.calving = calving()
    118119        self.frontalforcings = frontalforcings()
    119         self.gia = giaivins()
     120        self.gia = giamme()
    120121        self.love = fourierlove()
    121122        self.esa = esa()
  • TabularUnified issm/trunk-jpl/src/m/parameterization/parameterize.py

    r24213 r25129  
    44
    55def parameterize(md, parametername):
    6     """
     6    '''
    77    PARAMETERIZE - parameterize a model
    88
    9        from a parameter python file, start filling in all the model fields that were not
    10        filled in by the mesh.py and mask.py model methods.
    11        Warning: the parameter file must be able to be run in Python
     9        From a parameter Python file, start filling in all the model fields
     10        that were not filled in by the mesh.py and mask.py model methods.
     11        Warning: the parameter file must be able to be run in Python
    1212
    13        Usage:
    14           md = parameterize(md, parametername)
     13        Usage:
     14            md = parameterize(md, parametername)
    1515
    16        Example:
    17           md = parameterize(md, 'Square.par')
    18     """
     16        Example:
     17            md = parameterize(md, 'Square.par')
     18    '''
    1919
    2020    #some checks
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2001.py

    r25125 r25129  
    44import numpy as np
    55
     6from giaivins import giaivins
    67from model import *
    78from parameterize import *
     
    3940#Solve for GIA deflection
    4041md.cluster = generic('name', gethostname(), 'np', 3)
     42md.verbose = verbose('1111111')
    4143md = solve(md, 'Gia')
    4244
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2051.py

    r24214 r25129  
    11#Test Name: GiaIvinsBenchmarksAB2dA1
    22import numpy as np
     3
    34from model import *
    45from socket import gethostname
     
    3334field_names = ['GiaW', 'GiadWdt']
    3435field_tolerances = [1e-13, 1e-13]
    35 field_values = [md.results.GiaSolution.GiaW, md.results.GiaSolution.GiadWdt]
     36field_values = [md.results.GiaSolution.UGia, md.results.GiaSolution.UGiaRate]
  • TabularUnified issm/trunk-jpl/test/NightlyRun/test2052.py

    r24214 r25129  
    11#Test Name: GiaIvinsBenchmarksAB2dA2
    22import numpy as np
     3
    34from model import *
    45from socket import gethostname
  • TabularUnified issm/trunk-jpl/test/Par/GiaIvinsBenchmarksAB.py

    r25075 r25129  
    11#Geometry specific to Experiments A and B
    2 
    32import os.path
    43import inspect
     4
    55import numpy as np
     6
    67from arch import *
     8from giaivins import giaivins
    79from InterpFromMeshToMesh2d import *
    810from paterson import *
  • TabularUnified issm/trunk-jpl/test/Par/GiaIvinsBenchmarksCD.py

    r24862 r25129  
    3131md.gia.mantle_viscosity = 1e21 * np.ones((md.mesh.numberofvertices, ))  #in Pa.s
    3232md.gia.lithosphere_thickness = 100 * np.ones((md.mesh.numberofvertices, ))  #in km
    33 md.materials.lithosphere_shear_modulus = 6.7 * 1e10  #in Pa
     33md.materials.lithosphere_shear_modulus = 6.7e10  #in Pa
    3434md.materials.lithosphere_density = 3.32  #in g / cm^3
    35 md.materials.mantle_shear_modulus = 1.45 * 1e11  #in Pa
     35md.materials.mantle_shear_modulus = 1.45e11  #in Pa
    3636md.materials.mantle_density = 3.34  #in g / cm^3
    3737
  • TabularUnified issm/trunk-jpl/test/Par/SquareSheetConstrained.py

    r24862 r25129  
    6363#GIA:
    6464md.gia.lithosphere_thickness = 100. * np.ones((md.mesh.numberofvertices))  # in km
    65 md.gia.mantle_viscosity = 1. * 10**21 * np.ones((md.mesh.numberofvertices))  # in Pa.s
    66 md.materials.lithosphere_shear_modulus = 6.7 * 10**10  # in Pa
     65md.gia.mantle_viscosity = 1.e21 * np.ones((md.mesh.numberofvertices))  # in Pa.s
     66md.materials.lithosphere_shear_modulus = 6.7e10  # in Pa
    6767md.materials.lithosphere_density = 3.32  # in g / cm^ - 3
    68 md.materials.mantle_shear_modulus = 1.45 * 10**11  # in Pa
     68md.materials.mantle_shear_modulus = 1.45e11  # in Pa
    6969md.materials.mantle_density = 3.34  # in g / cm^ - 3
    7070
Note: See TracChangeset for help on using the changeset viewer.