#!/usr/bin/env python # coding: utf-8 # # first calculation with pyiron # ## project object # In[1]: from pyiron import Project # In[2]: pr = Project('demonstration') # In[3]: pr.remove_jobs(recursive=True) # to have a fresh start every time we execute the notebook # In[4]: pr.path # ## structure object # In[5]: structure = pr.create_structure('Al', 'fcc', 4.05) # compatible to the ASE structure object # In[6]: structure # In[7]: structure.plot3d() # ## job object # In[8]: job_lammps = pr.create_job(pr.job_type.Lammps, 'job_lammps_1') # In[9]: job_lammps.structure = structure # In[10]: job_lammps.view_potentials() # In[11]: job_lammps.list_potentials() # In[12]: job_lammps.potential = 'Al_Mg_Mendelev_eam' # In[13]: job_lammps.input.control # In[14]: job_lammps.calc_md(temperature=500.0) # In[15]: job_lammps.input.control # In[16]: job_lammps.run() # In[17]: pr.job_table() # ## Analyse the job # In[18]: job_lammps['output'] # In[19]: job_lammps['output/generic'] # In[20]: job_lammps['output/generic/energy_tot'] # In[21]: import matplotlib.pyplot as plt # In[22]: plt.plot(job_lammps['output/generic/energy_tot']) # In[23]: pr['job_lammps_1/output/generic/energy_tot'] # access from the project level # # Advanced users # In[24]: job_lammps.executable.list_executables() # In[25]: job_lammps.server.list_queues() # In[26]: job_lammps.server.view_queues() # In[27]: job_lammps.server.cores # In[28]: job_lammps.working_directory # In[29]: import os # In[30]: os.listdir(job_lammps.working_directory) # In[31]: job_lammps.decompress() # In[32]: job_lammps['log.lammps'] # Add you own parser for additional output # # Master jobs - multiple jobs in one job object # In[33]: job_lammps_template = pr.create_job(pr.job_type.Lammps, 'job_lammps_template') # In[34]: job_lammps_template.structure = structure # In[35]: job_lammps_template.potential = 'Al_Mg_Mendelev_eam' # In[36]: murn = job_lammps_template.create_job(pr.job_type.Murnaghan, 'murn') # In[37]: murn.input # In[38]: murn.run() # In[39]: murn.plot() # In[40]: murn['output'] # In[41]: plt.plot(murn['output/volume'], murn['output/energy']) # In[42]: pr.job_table() # # Data analytics # In[43]: table = pr.create_job(pr.job_type.TableJob, 'table') # In[44]: def filter_jobs(job): return 'strain' in job.job_name # In[45]: table.filter_function = filter_jobs # In[46]: table.add.get_job_name table.add.get_energy_tot table.add.get_volume # In[47]: job_lammps['output/generic/temperature'] # temperature # In[48]: def custom_function(job): return job['output/generic/temperature'][0] # In[49]: table.add['temperature'] = custom_function # In[50]: table.run() # In[51]: table.get_dataframe() # In[52]: plt.plot(table.get_dataframe()['volume'], table.get_dataframe()['energy_tot']) # # interactive jobs # In[53]: job_lammps.server.run_mode # In[54]: job_lammps.server.run_mode.non_modal # run in background # In[55]: job_interactive = pr.create_job(pr.job_type.Lammps, 'lammps_interactive') # In[56]: job_interactive.structure = structure # In[57]: job_interactive.potential = 'Al_Mg_Mendelev_eam' # In[58]: job_interactive.server.run_mode.interactive = True # In[59]: job_interactive.run() # In[60]: pr.job_table() # In[61]: job_interactive.output.forces # In[62]: structure_displace = structure.copy() # In[63]: structure_displace.positions # In[64]: structure_displace.positions[0] = [0.1, 0.1, 0.1] # In[65]: job_interactive.structure = structure_displace # In[66]: job_interactive.run() # In[67]: job_interactive.output.forces # In[68]: job_interactive.interactive_close() # In[69]: job_inter_mini = pr.create_job(pr.job_type.Lammps, 'lammps_int_template') # In[70]: job_inter_mini.structure = structure_displace # In[71]: job_inter_mini.potential = 'Al_Mg_Mendelev_eam' # In[72]: job_inter_mini.server.run_mode.interactive = True # In[73]: mini = pr.create_job(pr.job_type.ScipyMinimizer, 'mini') # In[74]: mini.ref_job = job_inter_mini # In[75]: mini.run() # In[76]: mini.ref_job.output.energy_tot # In[77]: plt.plot(mini.ref_job.output.energy_tot) # # GUI # In[78]: pr.gui() # In[ ]: