Changeset 2448


Ignore:
Timestamp:
Feb 24, 2006, 6:22:02 PM (18 years ago)
Author:
ole
Message:

Created stochastic version of okushiri with multiple realisations

Location:
development/stochastic_study
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • development/stochastic_study/project.py

    r2424 r2448  
    44# Inputs
    55boundary_filename = 'input_wave.tms'
    6 bathymetry_filename = 'bathymetry.txt'
     6bathymetry_filename = 'bathymetry.pts'
    77
    88# Model name
    99basename = 'simulation'
    1010mesh_filename = basename + '.msh'
     11
     12# Stats (Suresh ?)
     13number_of_samples = 300
     14std_dev = 0.01
     15mean = 0.0
     16blocksize = 100 #How many realisations to fit at a time
     17
     18
     19
    1120
    1221
  • development/stochastic_study/run_model.py

    r2433 r2448  
    2222import os
    2323import time
     24import cPickle
    2425
    2526# Related major packages
     
    3334# Application specific imports
    3435import project                 # Definition of file names and polygons
     36
     37
    3538
    3639
     
    4750print 'The extent is ', domain.get_extent()
    4851
    49 domain.set_name(project.basename)
    5052domain.set_datadir('.')
    5153domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
    5254
    53 domain.check_integrity()
    54 
    55 
    56 #------------------------------------------------------------------------------
    57 # Setup initial conditions
    58 #------------------------------------------------------------------------------
    59 domain.set_quantity('elevation',
    60                     filename = project.bathymetry_filename[:-4] + '.pts',
    61                     alpha = 0.001,
    62                     verbose = True,
    63                     use_cache = True)
    64 
    65 domain.set_quantity('friction', 0.0)
    66 domain.set_quantity('stage', 0.0)
     55#domain.check_integrity()
    6756
    6857
     
    8069
    8170#------------------------------------------------------------------------------
    82 # Evolve system through time
     71# Setup initial conditions
    8372#------------------------------------------------------------------------------
    84 t0 = time.time()
    85 for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5):
    86     domain.write_time()
    87     domain.write_boundary_statistics(tags = 'wave')         
     73domain.set_quantity('friction', 0.0)
     74domain.set_quantity('stage', 0.0)
    8875
    89 print 'That took %.2f seconds' %(time.time()-t0)
     76# Get prefitted realisations
     77realisation = 0
     78for filename in os.listdir('.'):
     79    if filename.startswith(project.basename) and filename.endswith('.pck'):
     80        print 'Reading %s' %filename
     81        fid = open(filename)
     82        V = cPickle.load(fid)
     83        fid.close()
     84
     85        # For each column (each realisation)
     86        for i in range(V.shape[1]):
     87            name = project.basename + '_realisation_%d' %realisation
     88            domain.set_name(name)                     #Output name
     89            domain.set_quantity('elevation', V[:,i])  #Assign bathymetry
     90
     91            #---------------------------------------------------
     92            # Evolve system through time
     93            #---------------------------------------------------
     94            print 'Running realisation %d of %d in block %s'\
     95                  %(i, V.shape[1], filename)
     96            t0 = time.time()
     97            for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5):
     98                domain.write_time()
     99                #domain.write_boundary_statistics(tags = 'wave')         
     100       
     101            print 'Realisation %d took %.2f seconds'\
     102                  %(realisation, time.time()-t0)
     103
     104            realisation += 1
Note: See TracChangeset for help on using the changeset viewer.