Example #1
0
def main():

    # ---------------------------------------------------------------------
    # Define material
    # ---------------------------------------------------------------------

    ice = material.Material()       # default ice values, 10 thicknesses
    ice.name = 'ice'                # prefer to use our own name instead
                                    # of default
    
    siku.materials.append( ice )    # list of all materials

    # table of material names for convenience
    matnames = {
        'ice': 0,
    }

    # ---------------------------------------------------------------------
    #  Wind initializations (NMC grid example)
    # ---------------------------------------------------------------------

    #start time index
    st_t_ind = 2
    
    siku.uw = wnd.NMCVar( 'u2014.nc', 'uwnd' )
    siku.vw = wnd.NMCVar( 'v2014.nc', 'vwnd' )
    siku.wind = wnd.NMCSurfaceVField( siku.uw, siku.vw, st_t_ind )

######    siku.settings.wind_source_type = siku.WIND_SOURCES['NONE']
    siku.settings.wind_source_type = siku.WIND_SOURCES['NMC']
    #siku.settings.wind_source_type = siku.WIND_SOURCES['TEST']
    siku.settings.wind_source_names = [ 'u2014.nc', 'v2014.nc' ]
    w = wnd.NMCSurfaceVField( siku.uw, siku.vw, st_t_ind )
    w.make_test_field( -0.0, 0.0 )
    siku.wind = w

    # ---------------------------------------------------------------------
    # date/time settings
    # ---------------------------------------------------------------------
    
    hour = datetime.timedelta ( hours = 1 )

    #siku.time.start    = datetime.datetime  ( 2012, 3, 12, 00, 00, 00 )
    siku.time.start = siku.uw.times[st_t_ind]
    siku.time.finish   = siku.time.start + hour * 120 #120

    siku.time.dt       = ( siku.time.finish - siku.time.start ) / 1200 #60
    siku.time.dts      = datetime.timedelta ( seconds = 600 )
    siku.time.last = siku.time.start
    siku.time.last_update = siku.time.last
       
    # ---------------------------------------------------------------------
    # elements
    # ---------------------------------------------------------------------
    
    coords = []
    siku.elements = []
    n_filled = 0
## custom testing polygons for caribbeans # lon, lat convention

    x = 5
    y = 2

    NN = [ 1, 2, 4, 8 ]

    nx = [ x*i for i in NN ]
    ny = [ y*i for i in NN ]

    left_inds = []
    right_inds = []
    left_gi = {}
    right_gi = {}
    
    ###test sections
    for i in range( len( NN ) ):
        cds, links = NG.generate_plus( \
            275.0, 9.0+i*5.0, 285.0, 13.0+i*5.0, nx[i], ny[i], 0., 0. )

        coords = coords + cds
##        siku.settings.links = siku.settings.links + links

##        left_inds = left_inds + \
##                     [ n_filled+j*nx[i] for j in range(ny[i]) ]
##        right_inds = right_inds + \
##                     [ n_filled+j*nx[i]+nx[i]-1 for j in range(0, ny[i]) ]
##
        n_filled += nx[i]*ny[i]

    ###handles
    for i in range( len( NN ) ):
        cds, links = NG.generate_plus( \
            275.0-10.0/nx[i], 9.0+i*5.0, 275.0, 13.0+i*5.0, 1, ny[i], \
            0., 0. )
        coords = coords + cds
        t = [ n_filled+j for j in range(ny[i]) ]
        left_inds = left_inds + t
        for j in t:
            left_gi[j] = i
        n_filled += ny[i]

        cds, links = NG.generate_plus( \
            285.0, 9.0+i*5.0, 285.0+10.0/nx[i], 13.0+i*5.0, 1, ny[i], \
            0., 0. )
        coords = coords + cds
        t = [ n_filled+j for j in range(ny[i]) ]
        right_inds = right_inds + t
        for j in t:
            right_gi[j] = i 
        n_filled += ny[i]

    siku.local.NN = NN
    siku.local.nx = nx
    siku.local.ny = ny
    siku.local.right_inds = right_inds
    siku.local.left_inds = left_inds
    siku.local.right_gi = right_gi
    siku.local.left_gi = left_gi

    # ---
    
    ### Initializing elements with polygon vertices
    for c in coords:
        siku.P.update( c )
     
        # Element declaration
        E = element.Element( polygon = siku.P, imat = matnames['ice'] )
        E.monitor = "drift_monitor"
        gh = [ 0.2, 0.2, 0.4, 0.2, 0.0, 
               0.0, 0.0, 0.0, 0.0, 0.0 ]
        E.set_gh( gh, ice )
        
        # all elements in the list
        siku.elements.append( E )

    # ---------------------------------------------------------------------
    #  Monitor function for the polygon
    # ---------------------------------------------------------------------

    ## Plotter initialization
    siku.plotter = GMT_Plotter( 'caribbean_plot_wnd.py' )

    ### period of picturing
    siku.diagnostics.monitor_period = 30
    siku.drift_monitor = drift_monitor
    siku.diagnostics.step_count = 0

##    siku.settings.force_model = \
##                    siku.CONTACT_FORCE_MODEL['Hopkins_Frankenstein']
    siku.settings.force_model = \
                    siku.CONTACT_FORCE_MODEL['distributed_spring']

    siku.settings.contact_method = siku.CONTACT_METHODS['sweep']

##    siku.settings.phys_consts = [ 5000 , 10000000 , 0.75, -0.00003, 1, \
##                                  -10000.0, 1.00, 0.2, 0.1, \
##                                  0.01 ] #wind interaction adjuster

    siku.settings.phys_consts = { 'rigidity' : 1.0,
                                  'viscosity' : 1.0,
                                  'rotatability' : 0.750,#0.75
                                  'tangency' : -0.00003,#-0.00003
                                  
                                  'elasticity' : 200000.0,#-5000000.0,
                                  'bendability' : 1.0,#1.0,
                                  'solidity' : 0.5,#0.05,
                                  'tensility' : 0.30,#0.615,

                                  'anchority' : 0.0000001,
                                  'windage':    0.00000001,
                                  'fastency' : 0.30, #0.5

                                  'sigma' : 200000.0,        # -//- rigidity
                                  'etha' : 0.0051          # -//- viscosity
                                  }

    # ------------------------- speed settings ----------------------------
 
    for i in left_inds:
        siku.elements[i].flag_state = element.Element.f_static

    
##    siku.settings.manual_inds = right_inds
##    amo = len(right_inds)
##    F = 800.0
##    siku.settings.manual_forces = [ (F/amo, -F/14/amo, 0.0) \
##                                    #-(i/nx)*1.0, -0.2*(i/ny/nx))
##                                    for i in right_inds ]

    for i in right_inds:
        siku.elements[i].velo = (2, -0.1, 0.0)
        siku.elements[i].flag_state = element.Element.f_steady

    # ---------------------------------------------------------------------
    #  Callback flag-mask generator
    # ---------------------------------------------------------------------

    siku.callback.pretimestep = pretimestep
    siku.callback.aftertimestep = aftertimestep
    siku.callback.conclusions = conclusions
    siku.callback.initializations = initializations
    siku.callback.updatewind = updatewind

    ##
    siku.callback.presave = presave

    return 0
Example #2
0
def main():

    # ---------------------------------------------------------------------
    # Define material
    # ---------------------------------------------------------------------

    ice = material.Material()       # default ice values, 10 thicknesses
    ice.name = 'ice'                # prefer to use our own name instead
                                    # of default
    
    siku.materials.append( ice )    # list of all materials

    # table of material names for convenience
    matnames = {
        'ice': 0,
    }

    # ---------------------------------------------------------------------
    #  Wind initializations (NMC grid example)
    # ---------------------------------------------------------------------

    #start time index
    st_t_ind = 2
    
    siku.uw = wnd.NMCVar( 'u2014.nc', 'uwnd' )
    siku.vw = wnd.NMCVar( 'v2014.nc', 'vwnd' )
    siku.wind = wnd.NMCSurfaceVField( siku.uw, siku.vw, st_t_ind )

######    siku.settings.wind_source_type = siku.WIND_SOURCES['NONE']
    siku.settings.wind_source_type = siku.WIND_SOURCES['NMC']
    #siku.settings.wind_source_type = siku.WIND_SOURCES['TEST']
    siku.settings.wind_source_names = [ 'u2014.nc', 'v2014.nc' ]
    w = wnd.NMCSurfaceVField( siku.uw, siku.vw, st_t_ind )
    w.make_test_field( 5.0,0. )
    siku.wind = w

    # ---------------------------------------------------------------------
    # date/time settings
    # ---------------------------------------------------------------------
    
    hour = datetime.timedelta ( hours = 1 )

    #siku.time.start    = datetime.datetime  ( 2012, 3, 12, 00, 00, 00 )
    siku.time.start = siku.uw.times[st_t_ind]
    siku.time.finish   = siku.time.start + hour *  720 #120

    siku.time.dt       = ( siku.time.finish - siku.time.start ) / 1200 #60
    siku.time.dts      = datetime.timedelta ( seconds = 600 )
    siku.time.last = siku.time.start
    siku.time.last_update = siku.time.last
       
    # ---------------------------------------------------------------------
    # elements
    # ---------------------------------------------------------------------
    
    coords = []
    siku.elements = []
## custom testing polygons for caribbeans # lon, lat convention

    nx = 7 #23
    ny = 1 #22
    coords, links \
        = NG.generate_plus( 267.0, 12.0, 280.0, 14.0, nx, ny, 0., 0. )
    siku.settings.links = links
##    nx = 8
##    ny = 3
##    coords = NG.generate( 267.0, 12.0, 281.0, 14.0, nx, ny, 0.0, 0.0 )

    # ---

    coords.append( [
        (280.0, 30.0),
        (283.0, 30.0),
        (283.0, 33.0),
        (280.0, 33.0)
        ] )
##    coords.append( [
##        (282.5, 33.0),
##        (283.0, 30.0),
##        (286.0, 33.0),
##        (283.0, 36.0)
##        ] )

    # ---
    
    ### Initializing elements with polygon vertices
    for c in coords:
        siku.P.update( c )
     
        # Element declaration
        E = element.Element( polygon = siku.P, imat = matnames['ice'] )
        E.monitor = "drift_monitor"
        gh = [ 0.2, 0.2, 0.4, 0.2, 0.0, 
               0.0, 0.0, 0.0, 0.0, 0.0 ]
        E.set_gh( gh, ice )
        
        # all elements in the list
        siku.elements.append( E )

    # ------------------------- speed settings ----------------------------

##    siku.elements[-1].velo = (0.0, -1.0, 0.000005)
##    siku.elements[-1].flag_state = element.Element.f_steady

    #left border is static
    left_inds = [ i*nx for i in range(ny) ]
 
    for i in left_inds:
        siku.elements[i].flag_state = element.Element.f_static

    # ---------------------------------------------------------------------
    #  Monitor function for the polygon
    # ---------------------------------------------------------------------

    ## Plotter initialization
    siku.plotter = GMT_Plotter( 'caribbean_plot_wnd.py' )

    ### period of picturing
    siku.diagnostics.monitor_period = 30
    siku.drift_monitor = drift_monitor
    siku.diagnostics.step_count = 0

##    siku.settings.force_model = \
##                    siku.CONTACT_FORCE_MODEL['Hopkins_Frankenstein']

    siku.settings.contact_method = siku.CONTACT_METHODS['sweep']

##    siku.settings.phys_consts = [ 5000 , 10000000 , 0.75, -0.00003, 1, \
##                                  -10000.0, 1.00, 0.2, 0.1, \
##                                  0.01 ] #wind interaction adjuster
    
    siku.settings.phys_consts = { 'rigidity' : 5000,
                                  'viscosity' : 10000000,
                                  'rotatability' : 0.75,
                                  'tangency' : -0.00003,
                                  
                                  'elasticity' : -10000.0,
                                  'bendability' : 1.0,
                                  'solidity' : 0.2,
                                  'tensility' : 0.1,

                                  'windage': 0.01
                                  }


    right_inds = [ i*nx+nx-1 for i in range(1, ny-1) ]
    
##    siku.settings.manual_inds = right_inds
##    siku.settings.manual_forces = [ (10.0, -0.0, 0.0) #-(i/nx)*1.0, -0.2*(i/ny/nx))
##                                    for i in right_inds ]

##    for i in right_inds:
##        siku.elements[i].velo = (1.0, -0.01, 0.0)
##        siku.elements[i].flag_state = element.Element.f_steady

    # ---------------------------------------------------------------------
    #  Callback flag-mask generator
    # ---------------------------------------------------------------------

    siku.callback.pretimestep = pretimestep
    siku.callback.aftertimestep = aftertimestep
    siku.callback.conclusions = conclusions
    siku.callback.initializations = initializations
    siku.callback.updatewind = updatewind

    ##
    siku.callback.presave = presave

    return 0
Example #3
0
def main():

    # ---------------------------------------------------------------------
    # Define material
    # ---------------------------------------------------------------------

    ice = material.Material()  # default ice values, 10 thicknesses
    ice.name = "ice"  # prefer to use our own name instead
    # of default

    siku.materials.append(ice)  # list of all materials

    # table of material names for convenience
    matnames = {"ice": 0}

    # ---------------------------------------------------------------------
    #  Wind initializations (NMC grid example)
    # ---------------------------------------------------------------------

    # start time index
    st_t_ind = 2

    siku.uw = wnd.NMCVar("u2014.nc", "uwnd")
    siku.vw = wnd.NMCVar("v2014.nc", "vwnd")
    siku.wind = wnd.NMCSurfaceVField(siku.uw, siku.vw, st_t_ind)

    ######    siku.settings.wind_source_type = siku.WIND_SOURCES['NONE']
    siku.settings.wind_source_type = siku.WIND_SOURCES["NMC"]
    # siku.settings.wind_source_type = siku.WIND_SOURCES['TEST']
    siku.settings.wind_source_names = ["u2014.nc", "v2014.nc"]
    w = wnd.NMCSurfaceVField(siku.uw, siku.vw, st_t_ind)
    w.make_test_field(-0.0, 0.0)
    siku.wind = w

    # ---------------------------------------------------------------------
    # date/time settings
    # ---------------------------------------------------------------------

    hour = datetime.timedelta(hours=1)

    # siku.time.start    = datetime.datetime  ( 2012, 3, 12, 00, 00, 00 )
    siku.time.start = siku.uw.times[st_t_ind]
    siku.time.finish = siku.time.start + hour * 120  # 120

    siku.time.dt = (siku.time.finish - siku.time.start) / 1200  # 60
    siku.time.dts = datetime.timedelta(seconds=600)
    siku.time.last = siku.time.start
    siku.time.last_update = siku.time.last

    # ---------------------------------------------------------------------
    # elements
    # ---------------------------------------------------------------------

    coords = []
    siku.elements = []
    ## custom testing polygons for caribbeans # lon, lat convention

    nx = 40  # 23
    ny = 40  # 22
    coords, links = NG.generate_plus(267.0, 12.0, 287.0, 27.0, nx, ny, 0.0, 0.0)  # 0.2, 0.2
    siku.settings.links = links
    ##    nx = 8
    ##    ny = 3
    ##    coords = NG.generate( 267.0, 12.0, 281.0, 14.0, nx, ny, 0.0, 0.0 )

    # ---

    coords.append([(280.0, 30.0), (283.0, 30.0), (283.0, 33.0), (280.0, 33.0)])
    ##    coords.append( [
    ##        (282.5, 33.0),
    ##        (283.0, 30.0),
    ##        (286.0, 33.0),
    ##        (283.0, 36.0)
    ##        ] )

    # ---

    ### Initializing elements with polygon vertices
    for c in coords:
        siku.P.update(c)

        # Element declaration
        E = element.Element(polygon=siku.P, imat=matnames["ice"])
        E.monitor = "drift_monitor"
        gh = [0.2, 0.2, 0.4, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
        E.set_gh(gh, ice)

        # all elements in the list
        siku.elements.append(E)

    # ------------------------- speed settings ----------------------------

    ##    siku.elements[-1].velo = (0.0, -1.0, 0.000005)
    ##    siku.elements[-1].flag_state = element.Element.f_steady

    # left border is static
    left_inds = [i * nx for i in range(ny)]

    for i in left_inds:
        siku.elements[i].flag_state = element.Element.f_static

    # ---------------------------------------------------------------------
    #  Monitor function for the polygon
    # ---------------------------------------------------------------------

    ## Plotter initialization
    siku.plotter = GMT_Plotter("caribbean_plot_wnd.py")

    ### period of picturing
    siku.diagnostics.monitor_period = 30
    siku.drift_monitor = drift_monitor
    siku.diagnostics.step_count = 0

    ##    siku.settings.force_model = \
    ##                    siku.CONTACT_FORCE_MODEL['Hopkins_Frankenstein']
    siku.settings.force_model = siku.CONTACT_FORCE_MODEL["distributed_spring"]

    siku.settings.contact_method = siku.CONTACT_METHODS["sweep"]

    ##    siku.settings.phys_consts = [ 5000 , 10000000 , 0.75, -0.00003, 1, \
    ##                                  -10000.0, 1.00, 0.2, 0.1, \
    ##                                  0.01 ] #wind interaction adjuster

    siku.settings.phys_consts = {
        "rigidity": 1.0,
        "viscosity": 1.0,
        "rotatability": 0.750,  # 0.75
        "tangency": -0.00003,  # -0.00003
        "elasticity": 50000000.0,  # -5000000.0,
        "bendability": 1.0,  # 1.0,
        "solidity": 0.5,  # 0.05,
        "tensility": 0.30,  # 0.615,
        "anchority": 0.0000001,
        "windage": 0.00000001,
        "fastency": 0.50,  # 0.5
        "sigma": 10000000.0,  # -//- rigidity
        "etha": 0.0051,  # -//- viscosity
    }

    right_inds = [i * nx + nx - 1 for i in range(1, ny - 1)]

    ##    siku.settings.manual_inds = right_inds
    ##    amo = len(right_inds)
    ##    F = 800.0
    ##    siku.settings.manual_forces = [ (F/amo, -F/14/amo, 0.0) \
    ##                                    #-(i/nx)*1.0, -0.2*(i/ny/nx))
    ##                                    for i in right_inds ]

    for i in right_inds:
        siku.elements[i].velo = (2, -0.2, 0.0)
        siku.elements[i].flag_state = element.Element.f_steady

    # ---------------------------------------------------------------------
    #  Callback flag-mask generator
    # ---------------------------------------------------------------------

    siku.callback.pretimestep = pretimestep
    siku.callback.aftertimestep = aftertimestep
    siku.callback.conclusions = conclusions
    siku.callback.initializations = initializations
    siku.callback.updatewind = updatewind

    ##
    siku.callback.presave = presave

    return 0