Ignore:
Timestamp:
06/07/17 10:50:54 (8 years ago)
Author:
Eric.Larour
Message:

CHG: merged branch back to trunk-jpl 21754.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-larour-NatGeoScience2016/test/NightlyRun/test1105.py

    r21060 r21759  
    11#Test Name: ISMIPCHO
    2 import numpy
     2import numpy as np
    33import shutil
    44from model import *
     5from socket import gethostname
    56from squaremesh import *
    67from setmask import *
     
    89from setflowequation import *
    910from solve import *
    10 from MatlabFuncs import *
    11 from PythonFuncs import *
    1211
    1312"""
     
    1817printingflag=False
    1918
    20 L_list=[5000.,10000.,20000.,40000.,80000.,160000.]
     19L_list=[80000.]
    2120results=[]
    2221minvx=[]
     
    3534
    3635        #Create MPCs to have periodic boundary conditions
    37         md.stressbalance.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    38         md.stressbalance.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    39         md.stressbalance.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
     36        md.stressbalance.spcvx=np.nan*np.ones((md.mesh.numberofvertices))
     37        md.stressbalance.spcvy=np.nan*np.ones((md.mesh.numberofvertices))
     38        md.stressbalance.spcvz=np.nan*np.ones((md.mesh.numberofvertices))
    4039
    41         posx=numpy.nonzero(logical_and_n(md.mesh.x==0.,md.mesh.y!=0.,md.mesh.y!=L))[0]
    42         posx2=numpy.nonzero(logical_and_n(md.mesh.x==L,md.mesh.y!=0.,md.mesh.y!=L))[0]
     40        posx=np.where(np.logical_and.reduce((md.mesh.x==0.,md.mesh.y!=0.,md.mesh.y!=L)))[0]
     41        posx2=np.where(np.logical_and.reduce((md.mesh.x==L,md.mesh.y!=0.,md.mesh.y!=L)))[0]
    4342
    44         posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=L))[0]    #Don't take the same nodes two times
    45         posy2=numpy.nonzero(logical_and_n(md.mesh.y==L,md.mesh.x!=0.,md.mesh.x!=L))[0]
     43        posy=np.where(np.logical_and.reduce((md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=L)))[0]    #Don't take the same nodes two times
     44        posy2=np.where(np.logical_and.reduce((md.mesh.y==L,md.mesh.x!=0.,md.mesh.x!=L)))[0]
    4645
    47         md.stressbalance.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
     46        md.stressbalance.vertex_pairing=np.vstack((np.vstack((posx+1,posx2+1)).T,np.vstack((posy+1,posy2+1)).T))
    4847
    4948        #Add spc on the corners
    50         pos=numpy.nonzero(logical_and_n(numpy.logical_or(md.mesh.x==0.,md.mesh.x==L),numpy.logical_or(md.mesh.y==0.,md.mesh.y==L),md.mesh.vertexonbase))
     49        pos=np.where(np.logical_and.reduce((np.logical_or(md.mesh.x==0.,md.mesh.x==L),np.logical_or(md.mesh.y==0.,md.mesh.y==L),md.mesh.vertexonbase)))
    5150        md.stressbalance.spcvx[pos]=0.
    5251        md.stressbalance.spcvy[pos]=0.
     
    7170       
    7271        #Spc the bed at zero for vz
    73         pos=numpy.nonzero(md.mesh.vertexonbase)
     72        pos=np.where(md.mesh.vertexonbase)
    7473        md.stressbalance.spcvz[pos]=0.
    7574
    7675        #Compute the stressbalance
    77         md.cluster=generic('name',oshostname(),'np',8)
     76        md.cluster=generic('name',gethostname(),'np',8)
    7877        md=solve(md,'Stressbalance')
    7978
     
    8382        vz=md.results.StressbalanceSolution.Vz
    8483        results.append(md.results.StressbalanceSolution)
    85         minvx.append(numpy.min(vx[-md.mesh.numberofvertices2d:]))
    86         maxvx.append(numpy.max(vx[-md.mesh.numberofvertices2d:]))
     84        minvx.append(np.min(vx[-md.mesh.numberofvertices2d:]))
     85        maxvx.append(np.max(vx[-md.mesh.numberofvertices2d:]))
    8786
    8887        #Now plot vx, vy, vz and vx on a cross section
     
    9190                pass
    9291#               set(gcf,'Color','w')
    93 #               printmodel(['ismipcHOvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
     92#               printmodel(['ismipcHOvx' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off')
    9493#               shutil.move("ismipcHOvx%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
    9594#       plotmodel(md,'data',vy,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',3)
     
    9796                pass
    9897#               set(gcf,'Color','w')
    99 #               printmodel(['ismipcHOvy' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
     98#               printmodel(['ismipcHOvy' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off')
    10099#               shutil.move("ismipcHOvy%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
    101100#       plotmodel(md,'data',vz,'layer#all',md.mesh.numberoflayers,'xlim',[0 L/10^3],'ylim',[0 L/10^3],'unit','km','figure',4)
     
    103102                pass
    104103#               set(gcf,'Color','w')
    105 #               printmodel(['ismipcHOvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
     104#               printmodel(['ismipcHOvz' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off')
    106105#               shutil.move("ismipcHOvz%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
    107106
     
    133132                pass
    134133#               set(gcf,'Color','w')
    135 #               printmodel(['ismipcHOvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
     134#               printmodel(['ismipcHOvxsec' num2str(L)],'png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off')
    136135#               shutil.move("ismipcHOvxsec%d.png" % L,ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
    137136
    138137#Now plot the min and max values of vx for each size of the square
    139 #plot([5 10 20 40 80 160],minvx);ylim([4 18]);xlim([0 160])
     138#plot([5 10 20 40 80 160],minvx)ylim([4 18])xlim([0 160])
    140139if printingflag:
    141140        pass
    142141#       set(gcf,'Color','w')
    143 #       printmodel('ismipcHOminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
     142#       printmodel('ismipcHOminvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off')
    144143#       shutil.move('ismipcHOminvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
    145 #plot([5 10 20 40 80 160],maxvx);ylim([0 200]); xlim([0 160])
     144#plot([5 10 20 40 80 160],maxvx)ylim([0 200]) xlim([0 160])
    146145if printingflag:
    147146        pass
    148147#       set(gcf,'Color','w')
    149 #       printmodel('ismipcHOmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off');
     148#       printmodel('ismipcHOmaxvx','png','margin','on','marginsize',25,'frame','off','resolution',1.5,'hardcopy','off')
    150149#       shutil.move('ismipcHOmaxvx.png',ISSM_DIR+'/website/doc_pdf/validation/Images/ISMIP/TestC')
    151150
    152151#Fields and tolerances to track changes
    153 field_names     =[\
    154         'Vx5km','Vy5km','Vz5km',\
    155         'Vx10km','Vy10km','Vz10km',\
    156         'Vx20km','Vy20km','Vz20km',\
    157         'Vx40km','Vy40km','Vz40km',\
    158         'Vx80km','Vy80km','Vz80km',\
    159         'Vx160km','Vy160km','Vz160km'
    160 ]
    161 field_tolerances=[\
    162         1e-08,1e-07,1e-07,\
    163         1e-09,1e-07,1e-07,\
    164         1e-09,1e-09,1e-07,\
    165         1e-09,1e-09,1e-08,\
    166         1e-09,1e-08,1e-08,\
    167         1e-09,1e-08,1e-08,\
    168 ]
     152field_names     =['Vx80km','Vy80km','Vz80km']
     153field_tolerances=[1e-09,1e-08,1e-08]
    169154field_values=[]
    170155for result in results:
    171         field_values=field_values+[\
    172                 result.Vx,\
    173                 result.Vy,\
    174                 result.Vz,\
    175                 ]
     156        field_values=field_values+[result.Vx,result.Vy,result.Vz]
Note: See TracChangeset for help on using the changeset viewer.