示例#1
0
            (3, 3, 3))[grid[0] // 2:-grid[0] // 2, grid[1] // 2:-grid[1] // 2,
                       grid[2] // 2:-grid[2] //
                       2]  # periodically extend the geometry

        material = periodic_material[index[0], index[1], index[2]].reshape(
            2 * grid)[grid[0] // 2:-grid[0] // 2, grid[1] // 2:-grid[1] // 2,
                      grid[2] // 2:-grid[2] //
                      2]  # extent grains into interface region

        # replace immutable materials with closest mutable ones
        index = ndimage.morphology.distance_transform_edt(
            np.in1d(material, options.immutable).reshape(grid),
            return_distances=False,
            return_indices=True)
        material = material[index[0], index[1], index[2]]

        immutable = np.zeros(material.shape, dtype=np.bool)
        # find locations where immutable materials have been in original structure
        for micro in options.immutable:
            immutable += material_original == micro

        # undo any changes involving immutable materials
        material = np.where(immutable, material_original, material)

    damask.Geom(material = material[0:grid_original[0],0:grid_original[1],0:grid_original[2]],
                size      = geom.size,
                origin    = geom.origin,
                comments  = geom.comments + [scriptID + ' ' + ' '.join(sys.argv[1:])],
               )\
          .save_ASCII(sys.stdout if name is None else name)
示例#2
0
            i += 1

config_header = ['<texture>', '[canal]', '[interstitial]']
for i in range(3, np.max(microstructure)):
    config_header += [
        '[Point{}]'.format(i - 2),
        '(gauss)\tphi1 {:.2f}\tPhi {:.2f}\tphi2 0'.format(Alpha[i], Beta[i])
    ]

config_header = [
    '<microstructure>', '[canal]',
    '(constituent)\tphase 1\ttexture 1\tfraction 1.0', '[interstitial]',
    '(constituent)\tphase 2\ttexture 2\tfraction 1.0'
]
for i in range(3, np.max(microstructure)):
    config_header += [
        '[Point{}]'.format(i - 2),
        '(constituent)\tphase 3\ttexture {}\tfraction 1.0'.format(i)
    ]

header = [scriptID + ' ' + ' '.join(sys.argv[1:])]\
       + config_header
geom = damask.Geom(microstructure.reshape(grid),
                   size,
                   -size / 2,
                   homogenization=options.homogenization,
                   comments=header)
damask.util.croak(geom)

geom.to_file(sys.stdout if name is None else name, pack=False)
示例#3
0
            Beta[i] = beta[x, y]
            i += 1

config_header = ['<texture>', '[canal]', '[interstitial]']
for i in range(3, np.max(microstructure)):
    config_header += [
        '[Point{}]'.format(i - 2),
        '(gauss)\tphi1 {:.2f}\tPhi {:.2f}\tphi2 0'.format(Alpha[i], Beta[i])
    ]

config_header = [
    '<microstructure>', '[canal]',
    '(constituent)\tphase 1\ttexture 1\tfraction 1.0', '[interstitial]',
    '(constituent)\tphase 2\ttexture 2\tfraction 1.0'
]
for i in range(3, np.max(microstructure)):
    config_header += [
        '[Point{}]'.format(i - 2),
        '(constituent)\tphase 3\ttexture {}\tfraction 1.0'.format(i)
    ]

header = [scriptID + ' ' + ' '.join(sys.argv[1:])]\
       + config_header
geom = damask.Geom(microstructure.reshape(grid),
                   size,
                   -size / 2,
                   comments=header)
damask.util.croak(geom)

geom.save_ASCII(sys.stdout if name is None else name)
示例#4
0
        for i, data in enumerate(unique):
            ori = damask.Rotation(data[0:4])
            config_header += [
                '[Grain{}]'.format(i + 1),
                '(gauss)\tphi1 {:.2f}\tPhi {:.2f}\tphi2 {:.2f}'.format(
                    *ori.as_Eulers(degrees=True)),
            ]
            if options.axes is not None:
                config_header += ['axes\t{} {} {}'.format(*options.axes)]

        config_header += ['<microstructure>']
        for i, data in enumerate(unique):
            config_header += [
                '[Grain{}]'.format(i + 1),
                '(constituent)\tphase {}\ttexture {}\tfraction 1.0'.format(
                    int(data[4]), i + 1),
            ]

    header = [scriptID + ' ' + ' '.join(sys.argv[1:])]\
           + config_header
    geom = damask.Geom(microstructure,
                       size,
                       origin,
                       homogenization=options.homogenization,
                       comments=header)
    damask.util.croak(geom)

    geom.to_file(sys.stdout if name is None else os.path.splitext(name)[0] +
                 '.geom',
                 pack=False)
示例#5
0
parser.set_defaults(type = minimal_surfaces[0],
                    threshold = 0.0,
                    periods = 1,
                    grid = (16,16,16),
                    size = (1.0,1.0,1.0),
                    homogenization = 1,
                    microstructure = (1,2),
                   )

(options,filename) = parser.parse_args()


name = None if filename == [] else filename[0]
damask.util.report(scriptName,name)

x,y,z = np.meshgrid(options.periods*2.0*np.pi*(np.arange(options.grid[0])+0.5)/options.grid[0],
                    options.periods*2.0*np.pi*(np.arange(options.grid[1])+0.5)/options.grid[1],
                    options.periods*2.0*np.pi*(np.arange(options.grid[2])+0.5)/options.grid[2],
                    indexing='xy',sparse=True)

microstructure = np.where(options.threshold < surface[options.type](x,y,z),
                          options.microstructure[1],options.microstructure[0])

geom=damask.Geom(microstructure,options.size,
                 homogenization=options.homogenization,
                 comments=[scriptID + ' ' + ' '.join(sys.argv[1:])])
damask.util.croak(geom)

geom.to_file(sys.stdout if name is None else name,pack=False)
                config_header += [
                    '[Grain{}]'.format(ID),
                    '(gauss)\tphi1 {:.2f}\tPhi {:.2f}\tphi2 {:.2f}'.format(
                        *eulers[eulerID])
                ]
                if options.axes:
                    config_header += ['axes\t{} {} {}'.format(*options.axes)]

        config_header += ['<microstructure>']
        for ID in grainIDs:
            config_header += [
                '[Grain{}]'.format(ID),
                '(constituent)\tphase {}\ttexture {}\tfraction 1.0'.format(
                    options.phase, ID)
            ]

        config_header += ['<!skip>']

    header = [scriptID + ' ' + ' '.join(sys.argv[1:])]\
           + config_header
    geom = damask.Geom(indices.reshape(grid),
                       size,
                       origin,
                       homogenization=options.homogenization,
                       comments=header)
    damask.util.croak(geom)

    geom.to_file(sys.stdout if name is None else os.path.splitext(name)[0] +
                 '.geom',
                 pack=False)