pyphasefield package

Subpackages

Submodules

pyphasefield.field module

class pyphasefield.field.Field(data=None, simulation=None, name=None, colormap='GnBu')

Bases: object

get_all_cells()
get_cells()
gradient_cell()
gradient_face_left()
gradient_face_right()
laplacian()

pyphasefield.ppf_gpu_utils module

pyphasefield.ppf_gpu_utils.apply_boundary_conditions(sim)
pyphasefield.ppf_gpu_utils.retrieve_fields_from_GPU(sim)
pyphasefield.ppf_gpu_utils.send_fields_to_GPU(sim)
pyphasefield.ppf_gpu_utils.update_temperature_field(sim)

pyphasefield.ppf_utils module

pyphasefield.ppf_utils.CSVtoXDMF(csv_path, T_cutoffs=False, starting_T=None, ending_T=None, reflect_X=False)
class pyphasefield.ppf_utils.TDBContainer(tdb_path, phases=None, components=None)

Bases: object

class pyphasefield.ppf_utils.XDMFLoader(t_file_path)

Bases: object

data(step)
pyphasefield.ppf_utils.make_seed(phi, q1, q4, x, y, angle, seed_radius)
pyphasefield.ppf_utils.successfully_imported_numba()

Checks if numba/cuda is installed. If not, warns the user that gpu-dependent features cannot be used Also tells the user how to install it (if the user has Anaconda)

pyphasefield.ppf_utils.successfully_imported_pycalphad()

Checks if pycalphad is installed. If not, warns the user that pycalphad-dependent features cannot be used Also tells the user how to install it (if the user has Anaconda)

pyphasefield.simulation module

class pyphasefield.simulation.Simulation(dimensions, framework=None, dx=None, dt=None, initial_time_step=0, temperature_type=None, initial_T=None, dTdx=None, dTdy=None, dTdz=None, dTdt=None, temperature_path=None, temperature_units='K', tdb_container=None, tdb_path=None, tdb_components=None, tdb_phases=None, save_path=None, autosave=False, save_images=False, autosave_rate=None, boundary_conditions=None, user_data={})

Bases: object

add_field(array, array_name, colormap='GnBu')
apply_boundary_conditions()
default_value(var, value)
generate_python_script()
get_cell_spacing()
get_dimensions()
get_dt()
get_dx()
get_framework()
get_time_step_counter()
get_time_step_length()
increment_time_step_counter()
init_boundary_conditions()
init_fields()
init_sim_CahnAllen(dim=[200], solver='explicit', gmres=False, adi=False)
init_sim_CahnHilliard(dim=[200], solver='explicit', gmres=False, adi=False)
init_sim_Diffusion(dim=[200], solver='explicit', gmres=False, adi=False)
init_sim_DiffusionGPU(dim=[200, 200], cuda_blocks=(16, 16), cuda_threads_per_block=(256, 1))
init_sim_NCGPU(dim=[200, 200], sim_type='seed', number_of_seeds=1, tdb_path='Ni-Cu_Ideal.tdb', temperature_type='isothermal', initial_temperature=1574, temperature_gradient=0, cooling_rate=0, temperature_file_path='T.xdmf', initial_concentration_array=[0.40831], cell_spacing=4.6e-06, d_ratio=1.0638297872340425, solver='explicit', nbc=['periodic', 'periodic'], cuda_blocks=(16, 16), cuda_threads_per_block=(256, 1))
init_sim_NComponent(dim=[200, 200], sim_type='seed', number_of_seeds=1, tdb_path='Ni-Cu_Ideal.tdb', temperature_type='isothermal', initial_temperature=1574, temperature_gradient=0, cooling_rate=0, temperature_file_path='T.xdmf', initial_concentration_array=[0.40831], cell_spacing=4.6e-06, d_ratio=1.0638297872340425, solver='explicit', nbc=['periodic', 'periodic'])
init_sim_Warren1995(dim=[200, 200], diamond_size=15)
init_tdb_params()
init_temperature_field()
initialize_fields_and_imported_data()
just_before_simulating()
load_simulation(file_path=None, step=- 1)
Loads a simulation from a .npz file. Either a filename, step, or both must be provided.

If no step is specified, checks filename for step #. If no filename is specified, a file with the specified step number is loaded from the _save_path.

plot_all_fields()

Plots each field in self.fields and saves them to the save_path in a separate dir Recommended for when the number of fields used would clutter the data folder

plot_field(f, save_path=None)

Plots each field as a matplotlib 2d image. Takes in a field object as arg and saves the image to the data folder as namePlot_step_n.png

plot_simulation(fields=None, interpolation='bicubic', units='cells', save_images=False, show_images=True, size=None, norm=False)
progress_bar()
retrieve_fields_from_GPU()
save_simulation()

Saves all fields in a .npz in either the user-specified save path or a default path. Step number is saved in the file name. TODO: save data for simulation instance in header file

send_fields_to_GPU()
set_autosave_flag(autosave_flag)
set_autosave_rate(autosave_rate)
set_autosave_save_images_flag(autosave_save_images_flag)
set_boundary_conditions(boundary_conditions_type)
set_cell_spacing(dx)
set_debug_mode_flag(debug_mode_flag)
set_dimensions(dimensions)
set_dt(dt)
set_dx(dx)
set_framework(framework)
set_save_path(save_path)
set_tdb_components(tdb_components)
set_tdb_container(tdb_container)
set_tdb_path(tdb_path)
set_tdb_phases(tdb_phases)
set_temperature_dTdt(dTdt)
set_temperature_dTdx(dTdx)
set_temperature_dTdy(dTdy)
set_temperature_dTdz(dTdz)
set_temperature_initial_T(initial_T)
set_temperature_path(temperature_path)
set_temperature_type(temperature_type)
set_temperature_units(temperature_units)
set_time_step_counter(time_step_counter)
set_time_step_length(dt)
set_user_data(data)
simulate(number_of_timesteps)

Evolves the simulation for a specified number of timesteps If a length of timestep is not specified, uses the timestep length stored within the Simulation instance For each timestep, the method:

  • Increments the timestep counter by 1

  • Runs the engine function (a function which only takes the Simulation instance as a

    parameter, and evolves the fields contained within the instance by one time step

  • Updates the thermal field of the simulation depending on which thermal type the simulation is:
    • Isothermal: Do nothing

    • Gradient: Add dT/dt, multiplied by the timestep length, to the thermal field

    • File: Use linear interpolation to find the thermal field of the new timestep

  • If the timestep counter is a multiple of time_steps_per_checkpoint, save a checkpoint of the simulation

simulation_loop()
update_temperature_field(force_cpu=False)

Updates the thermal field, method assumes only one timestep has passed

Module contents