SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
Tools of the Modeling
trade (QM, not catwalk)
Shyue Ping Ong
It’s not just about quantum mechanics
NANO266
2
The four levels of attainment
NANO266
3
Jedi
Master
Jedi Knight
Padawan
Youngling
Does things “manually”.
Lots of mistakes (e.g., typos,
calculations that need to be
repeated, etc. Takes months to
do a basic project.
Knows way around the command line.
Use some basic shell scripting. Maybe
even a little programming to make
some tasks easier.
Mastered most of the tools of the trade.
Can write sophisticated shell/programming
scripts to automate calculations, plot results,
etc. Most PhDs get to this level (hopefully).
Conceptualizes entire software frameworks that
are reusable and extendable by other users.
The most important command in Unix
•  man sed
•  man awk
•  man find
•  man grep
•  man head
•  man tail
•  man less
•  man …
NANO266
4
“man” is short
for manual
Some common Unix commands (other than your
typical cp,mv,cd,ls)
grep Searches any given input files,
selecting lines that match one or
more patterns.
cat Reads files sequentially, writing them
to the standard output
sed Reads the specified files, modifying
the input as specified by a list of
commands.
tail Displays last part of a file
head Displays start of a file
find Recursively descends the directory
tree, evaluating an expression in
terms of each file in the tree.
less View file in terminal
NANO266
5
Unix shells
Many types of Unix shell available, but broadly
falls into
•  Bourne shell – de facto standard
•  C shell – uses C-like syntax
Pick one that suits you and just set all your
resources to go into that shell by default.
NANO266
6
Shell scripts
Next level beyond just typing commands in the terminal
Writing scripts to execute sequence of commands, with
some control flow where necessary
NANO266
7
# Descending into a directory structure
# and running some commands in each directory
cwd=`pwd`
for dir in `find . –type d`
do
cd $dir
<execute some other commands>
cd $cwd
done
Control flow
Specification of the order in which the individual
statements, instructions or function calls of an
imperative program are executed or evaluated.
Two broad-types:
•  Conditional: if-else, case-switch, etc.
•  Loops: for, while, etc.
NANO266
8
Pros and Cons of Shell Scripts
Pros
•  Ubiquitous
•  Quick and dirty
•  Useful for short programs / scripts with
a little bit of control flow
Cons
•  Very error-prone, especially with more
complex programs
•  Doing even simple math is ugly (don’t
even bother trying to do matrix math or
anything more complex)
•  Difficult to extend and build on
NANO266
9
Beyond shell scripts
NANO266
10
Pros and Cons of Programming Languages
Pros
•  Far more powerful than shell
•  Popular ones come with extensive libraries that makes complex math
and plotting etc. easier
•  Usually comes with support tools (compilers, debuggers, IDEs, etc.)
that helps reduce bugs, or at the very least, make them easier to find.
•  Proper use allows the development of extensible packages and
libraries
Cons
•  Compiled languages require an additional compilation step
•  Additional learning curve
•  Not all languages are supported on all systems (though this is usually
not an issue with the popular ones)
NANO266
11
Which programming language should I choose?
Short answer – Whichever one you are most
comfortable with.
Long answer – Depends on what you need it for.
•  If performance is critical (e.g., a DFT code), you probably have to
go with compiled languages like C and Fortran.
•  If speed of development and prototyping outweighs raw
performance, interpreted / scripting languages like Python and
Perl are generally easier to get into.
For this class, we will exclusively use Python.
NANO266
12
NANO266
13
https://xkcd.com/353/
What is ?
General-purpose, high-level programming language
Design emphasizes code readability
Supports multiple programming paradigms (OOP,
imperative, functional, procedural)
Dynamically typed, automatic memory management
and large standard library
Available on almost all platforms
NANO266
14
NANO266
15
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
Java
C++
print("Hello World!”)
Python
Scientific computing with Python
NANO266
16
User-friendly and efficient numerical
routines such as routines for numerical
integration and optimization.
Fundamental package for numerical
computation. Defines array and matrix
types and basic operations on them.
High-performance, easy to use
data structures.
Publication-quality 2D plotting as
well as rudimentary 3D plotting
Rich interactive interface, letting
you quickly process data and
test ideas.
Python Resources
Python documentation
https://www.python.org/doc/
Numpy docs
http://docs.scipy.org/doc/numpy/reference/
NANO266
17
Beyond simple scripts – Libraries for
Computational Materials Science
NANO266
18
https://wiki.fysik.dtu.dk/ase/https://www.pymatgen.org
http://www.aflowlib.org/
Python Materials Genomics (pymatgen)
Core materials analysis powering the
Materials Project
• Defines core extensible Python objects for materials
data representation.
• Provides a robust and well-documented set of
structure and thermodynamic analysis tools relevant to
many applications.
• Establishes an open platform for researchers to
collaboratively develop sophisticated analyses of
materials data.
NANO266
19
Overview of Pymatgen
NANO266
20
Example usage
NANO266
21
Final word on Programming
A little investment in learning a programming
language can yield big dividends in your
efficiency as a materials modeler.
NANO266
22
Prep for Lab2
In Lab2, you will come face-to-face with a practical
example of how using a programming language can
make performing a sizable number of calculations
much easier.
The scripts are relatively simple and makes use of
only Python’s standard library. They offer but a small
glimpse of what is possible.
Start your journey by going through the simple
Python tutorial at http://www.python.org.
NANO266
23

Mais conteúdo relacionado

Mais procurados

Cassandra and Storm at Health Market Sceince
Cassandra and Storm at Health Market SceinceCassandra and Storm at Health Market Sceince
Cassandra and Storm at Health Market Sceince
P. Taylor Goetz
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
Chandler Huang
 

Mais procurados (20)

Developing Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache StormDeveloping Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache Storm
 
Storm Real Time Computation
Storm Real Time ComputationStorm Real Time Computation
Storm Real Time Computation
 
Storm
StormStorm
Storm
 
Real-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache StormReal-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache Storm
 
Distributed real time stream processing- why and how
Distributed real time stream processing- why and howDistributed real time stream processing- why and how
Distributed real time stream processing- why and how
 
Storm: The Real-Time Layer - GlueCon 2012
Storm: The Real-Time Layer  - GlueCon 2012Storm: The Real-Time Layer  - GlueCon 2012
Storm: The Real-Time Layer - GlueCon 2012
 
Cassandra and Storm at Health Market Sceince
Cassandra and Storm at Health Market SceinceCassandra and Storm at Health Market Sceince
Cassandra and Storm at Health Market Sceince
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
 
Using Spark ML on Spark Errors - What do the clusters tell us?
Using Spark ML on Spark Errors - What do the clusters tell us?Using Spark ML on Spark Errors - What do the clusters tell us?
Using Spark ML on Spark Errors - What do the clusters tell us?
 
Apache Storm Tutorial
Apache Storm TutorialApache Storm Tutorial
Apache Storm Tutorial
 
Scaling Apache Storm (Hadoop Summit 2015)
Scaling Apache Storm (Hadoop Summit 2015)Scaling Apache Storm (Hadoop Summit 2015)
Scaling Apache Storm (Hadoop Summit 2015)
 
Hadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureHadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm Architecture
 
Apache Storm 0.9 basic training - Verisign
Apache Storm 0.9 basic training - VerisignApache Storm 0.9 basic training - Verisign
Apache Storm 0.9 basic training - Verisign
 
Debugging PySpark: Spark Summit East talk by Holden Karau
Debugging PySpark: Spark Summit East talk by Holden KarauDebugging PySpark: Spark Summit East talk by Holden Karau
Debugging PySpark: Spark Summit East talk by Holden Karau
 
Yahoo compares Storm and Spark
Yahoo compares Storm and SparkYahoo compares Storm and Spark
Yahoo compares Storm and Spark
 
Beyond parallelize and collect - Spark Summit East 2016
Beyond parallelize and collect - Spark Summit East 2016Beyond parallelize and collect - Spark Summit East 2016
Beyond parallelize and collect - Spark Summit East 2016
 
Storm Anatomy
Storm AnatomyStorm Anatomy
Storm Anatomy
 
Introduction to Apache Storm
Introduction to Apache StormIntroduction to Apache Storm
Introduction to Apache Storm
 
Learning Stream Processing with Apache Storm
Learning Stream Processing with Apache StormLearning Stream Processing with Apache Storm
Learning Stream Processing with Apache Storm
 
Real time and reliable processing with Apache Storm
Real time and reliable processing with Apache StormReal time and reliable processing with Apache Storm
Real time and reliable processing with Apache Storm
 

Destaque

Destaque (20)

NANO266 - Lecture 1 - Introduction to Quantum Mechanics
NANO266 - Lecture 1 - Introduction to Quantum MechanicsNANO266 - Lecture 1 - Introduction to Quantum Mechanics
NANO266 - Lecture 1 - Introduction to Quantum Mechanics
 
NANO266 - Lecture 12 - High-throughput computational materials design
NANO266 - Lecture 12 - High-throughput computational materials designNANO266 - Lecture 12 - High-throughput computational materials design
NANO266 - Lecture 12 - High-throughput computational materials design
 
NANO266 - Lecture 13 - Ab initio molecular dyanmics
NANO266 - Lecture 13 - Ab initio molecular dyanmicsNANO266 - Lecture 13 - Ab initio molecular dyanmics
NANO266 - Lecture 13 - Ab initio molecular dyanmics
 
NANO266 - Lecture 7 - QM Modeling of Periodic Structures
NANO266 - Lecture 7 - QM Modeling of Periodic StructuresNANO266 - Lecture 7 - QM Modeling of Periodic Structures
NANO266 - Lecture 7 - QM Modeling of Periodic Structures
 
NANO266 - Lecture 3 - Beyond the Hartree-Fock Approximation
NANO266 - Lecture 3 - Beyond the Hartree-Fock ApproximationNANO266 - Lecture 3 - Beyond the Hartree-Fock Approximation
NANO266 - Lecture 3 - Beyond the Hartree-Fock Approximation
 
NANO266 - Lecture 2 - The Hartree-Fock Approach
NANO266 - Lecture 2 - The Hartree-Fock ApproachNANO266 - Lecture 2 - The Hartree-Fock Approach
NANO266 - Lecture 2 - The Hartree-Fock Approach
 
NANO266 - Lecture 6 - Molecule Properties from Quantum Mechanical Modeling
NANO266 - Lecture 6 - Molecule Properties from Quantum Mechanical ModelingNANO266 - Lecture 6 - Molecule Properties from Quantum Mechanical Modeling
NANO266 - Lecture 6 - Molecule Properties from Quantum Mechanical Modeling
 
NANO266 - Lecture 4 - Introduction to DFT
NANO266 - Lecture 4 - Introduction to DFTNANO266 - Lecture 4 - Introduction to DFT
NANO266 - Lecture 4 - Introduction to DFT
 
NANO266 - Lecture 8 - Properties of Periodic Solids
NANO266 - Lecture 8 - Properties of Periodic SolidsNANO266 - Lecture 8 - Properties of Periodic Solids
NANO266 - Lecture 8 - Properties of Periodic Solids
 
NANO266 - Lecture 10 - Temperature
NANO266 - Lecture 10 - TemperatureNANO266 - Lecture 10 - Temperature
NANO266 - Lecture 10 - Temperature
 
NANO266 - Lecture 14 - Transition state modeling
NANO266 - Lecture 14 - Transition state modelingNANO266 - Lecture 14 - Transition state modeling
NANO266 - Lecture 14 - Transition state modeling
 
NANO266 - Lecture 11 - Surfaces and Interfaces
NANO266 - Lecture 11 - Surfaces and InterfacesNANO266 - Lecture 11 - Surfaces and Interfaces
NANO266 - Lecture 11 - Surfaces and Interfaces
 
NANO266 - Lecture 5 - Exchange-Correlation Functionals
NANO266 - Lecture 5 - Exchange-Correlation FunctionalsNANO266 - Lecture 5 - Exchange-Correlation Functionals
NANO266 - Lecture 5 - Exchange-Correlation Functionals
 
Creating It from Bit - Designing Materials by Integrating Quantum Mechanics, ...
Creating It from Bit - Designing Materials by Integrating Quantum Mechanics, ...Creating It from Bit - Designing Materials by Integrating Quantum Mechanics, ...
Creating It from Bit - Designing Materials by Integrating Quantum Mechanics, ...
 
UCSD NANO106 - 06 - Plane and Space Groups
UCSD NANO106 - 06 - Plane and Space GroupsUCSD NANO106 - 06 - Plane and Space Groups
UCSD NANO106 - 06 - Plane and Space Groups
 
UCSD NANO106 - 07 - Material properties and tensors
UCSD NANO106 - 07 - Material properties and tensorsUCSD NANO106 - 07 - Material properties and tensors
UCSD NANO106 - 07 - Material properties and tensors
 
UCSD NANO106 - 03 - Lattice Directions and Planes, Reciprocal Lattice and Coo...
UCSD NANO106 - 03 - Lattice Directions and Planes, Reciprocal Lattice and Coo...UCSD NANO106 - 03 - Lattice Directions and Planes, Reciprocal Lattice and Coo...
UCSD NANO106 - 03 - Lattice Directions and Planes, Reciprocal Lattice and Coo...
 
UCSD NANO106 - 13 - Other Diffraction Techniques and Common Crystal Structures
UCSD NANO106 - 13 - Other Diffraction Techniques and Common Crystal StructuresUCSD NANO106 - 13 - Other Diffraction Techniques and Common Crystal Structures
UCSD NANO106 - 13 - Other Diffraction Techniques and Common Crystal Structures
 
UCSD NANO106 - 05 - Group Symmetry and the 32 Point Groups
UCSD NANO106 - 05 - Group Symmetry and the 32 Point GroupsUCSD NANO106 - 05 - Group Symmetry and the 32 Point Groups
UCSD NANO106 - 05 - Group Symmetry and the 32 Point Groups
 
Advanced Molecular Dynamics 2016
Advanced Molecular Dynamics 2016Advanced Molecular Dynamics 2016
Advanced Molecular Dynamics 2016
 

Semelhante a NANO266 - Lecture 9 - Tools of the Modeling Trade

Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
Clay Helberg
 

Semelhante a NANO266 - Lecture 9 - Tools of the Modeling Trade (20)

Chapter 1: Introduction to Command Line
Chapter 1: Introduction  to Command LineChapter 1: Introduction  to Command Line
Chapter 1: Introduction to Command Line
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction to  Command LineChapter 1: Introduction to  Command Line
Chapter 1: Introduction to Command Line
 
Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development Efficiency
 
Os Lamothe
Os LamotheOs Lamothe
Os Lamothe
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood edition
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Android antipatterns
Android antipatternsAndroid antipatterns
Android antipatterns
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
The Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms ProgrammingThe Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms Programming
 
THE BASIC TOOLS
THE BASIC TOOLSTHE BASIC TOOLS
THE BASIC TOOLS
 
Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
 
Practical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profilingPractical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profiling
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 
OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11
 
PVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniquePVS-Studio and static code analysis technique
PVS-Studio and static code analysis technique
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Why Drupal is Rockstar?
Why Drupal is Rockstar?Why Drupal is Rockstar?
Why Drupal is Rockstar?
 
Java - A broad introduction
Java - A broad introductionJava - A broad introduction
Java - A broad introduction
 

Mais de University of California, San Diego

The Materials Project Ecosystem - A Complete Software and Data Platform for M...
The Materials Project Ecosystem - A Complete Software and Data Platform for M...The Materials Project Ecosystem - A Complete Software and Data Platform for M...
The Materials Project Ecosystem - A Complete Software and Data Platform for M...
University of California, San Diego
 

Mais de University of California, San Diego (11)

A*STAR Webinar on The AI Revolution in Materials Science
A*STAR Webinar on The AI Revolution in Materials ScienceA*STAR Webinar on The AI Revolution in Materials Science
A*STAR Webinar on The AI Revolution in Materials Science
 
NANO281 Lecture 01 - Introduction to Data Science in Materials Science
NANO281 Lecture 01 - Introduction to Data Science in Materials ScienceNANO281 Lecture 01 - Introduction to Data Science in Materials Science
NANO281 Lecture 01 - Introduction to Data Science in Materials Science
 
UCSD NANO106 - 12 - X-ray diffraction
UCSD NANO106 - 12 - X-ray diffractionUCSD NANO106 - 12 - X-ray diffraction
UCSD NANO106 - 12 - X-ray diffraction
 
UCSD NANO106 - 11 - X-rays and their interaction with matter
UCSD NANO106 - 11 - X-rays and their interaction with matterUCSD NANO106 - 11 - X-rays and their interaction with matter
UCSD NANO106 - 11 - X-rays and their interaction with matter
 
UCSD NANO106 - 10 - Bonding in Materials
UCSD NANO106 - 10 - Bonding in MaterialsUCSD NANO106 - 10 - Bonding in Materials
UCSD NANO106 - 10 - Bonding in Materials
 
UCSD NANO106 - 09 - Piezoelectricity and Elasticity
UCSD NANO106 - 09 - Piezoelectricity and ElasticityUCSD NANO106 - 09 - Piezoelectricity and Elasticity
UCSD NANO106 - 09 - Piezoelectricity and Elasticity
 
UCSD NANO106 - 08 - Principal Directions and Representation Quadrics
UCSD NANO106 - 08 - Principal Directions and Representation QuadricsUCSD NANO106 - 08 - Principal Directions and Representation Quadrics
UCSD NANO106 - 08 - Principal Directions and Representation Quadrics
 
UCSD NANO106 - 04 - Symmetry in Crystallography
UCSD NANO106 - 04 - Symmetry in CrystallographyUCSD NANO106 - 04 - Symmetry in Crystallography
UCSD NANO106 - 04 - Symmetry in Crystallography
 
UCSD NANO106 - 02 - 3D Bravis Lattices and Lattice Computations
UCSD NANO106 - 02 - 3D Bravis Lattices and Lattice ComputationsUCSD NANO106 - 02 - 3D Bravis Lattices and Lattice Computations
UCSD NANO106 - 02 - 3D Bravis Lattices and Lattice Computations
 
UCSD NANO106 - 01 - Introduction to Crystallography
UCSD NANO106 - 01 - Introduction to CrystallographyUCSD NANO106 - 01 - Introduction to Crystallography
UCSD NANO106 - 01 - Introduction to Crystallography
 
The Materials Project Ecosystem - A Complete Software and Data Platform for M...
The Materials Project Ecosystem - A Complete Software and Data Platform for M...The Materials Project Ecosystem - A Complete Software and Data Platform for M...
The Materials Project Ecosystem - A Complete Software and Data Platform for M...
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 

NANO266 - Lecture 9 - Tools of the Modeling Trade

  • 1. Tools of the Modeling trade (QM, not catwalk) Shyue Ping Ong
  • 2. It’s not just about quantum mechanics NANO266 2
  • 3. The four levels of attainment NANO266 3 Jedi Master Jedi Knight Padawan Youngling Does things “manually”. Lots of mistakes (e.g., typos, calculations that need to be repeated, etc. Takes months to do a basic project. Knows way around the command line. Use some basic shell scripting. Maybe even a little programming to make some tasks easier. Mastered most of the tools of the trade. Can write sophisticated shell/programming scripts to automate calculations, plot results, etc. Most PhDs get to this level (hopefully). Conceptualizes entire software frameworks that are reusable and extendable by other users.
  • 4. The most important command in Unix •  man sed •  man awk •  man find •  man grep •  man head •  man tail •  man less •  man … NANO266 4 “man” is short for manual
  • 5. Some common Unix commands (other than your typical cp,mv,cd,ls) grep Searches any given input files, selecting lines that match one or more patterns. cat Reads files sequentially, writing them to the standard output sed Reads the specified files, modifying the input as specified by a list of commands. tail Displays last part of a file head Displays start of a file find Recursively descends the directory tree, evaluating an expression in terms of each file in the tree. less View file in terminal NANO266 5
  • 6. Unix shells Many types of Unix shell available, but broadly falls into •  Bourne shell – de facto standard •  C shell – uses C-like syntax Pick one that suits you and just set all your resources to go into that shell by default. NANO266 6
  • 7. Shell scripts Next level beyond just typing commands in the terminal Writing scripts to execute sequence of commands, with some control flow where necessary NANO266 7 # Descending into a directory structure # and running some commands in each directory cwd=`pwd` for dir in `find . –type d` do cd $dir <execute some other commands> cd $cwd done
  • 8. Control flow Specification of the order in which the individual statements, instructions or function calls of an imperative program are executed or evaluated. Two broad-types: •  Conditional: if-else, case-switch, etc. •  Loops: for, while, etc. NANO266 8
  • 9. Pros and Cons of Shell Scripts Pros •  Ubiquitous •  Quick and dirty •  Useful for short programs / scripts with a little bit of control flow Cons •  Very error-prone, especially with more complex programs •  Doing even simple math is ugly (don’t even bother trying to do matrix math or anything more complex) •  Difficult to extend and build on NANO266 9
  • 11. Pros and Cons of Programming Languages Pros •  Far more powerful than shell •  Popular ones come with extensive libraries that makes complex math and plotting etc. easier •  Usually comes with support tools (compilers, debuggers, IDEs, etc.) that helps reduce bugs, or at the very least, make them easier to find. •  Proper use allows the development of extensible packages and libraries Cons •  Compiled languages require an additional compilation step •  Additional learning curve •  Not all languages are supported on all systems (though this is usually not an issue with the popular ones) NANO266 11
  • 12. Which programming language should I choose? Short answer – Whichever one you are most comfortable with. Long answer – Depends on what you need it for. •  If performance is critical (e.g., a DFT code), you probably have to go with compiled languages like C and Fortran. •  If speed of development and prototyping outweighs raw performance, interpreted / scripting languages like Python and Perl are generally easier to get into. For this class, we will exclusively use Python. NANO266 12
  • 14. What is ? General-purpose, high-level programming language Design emphasizes code readability Supports multiple programming paradigms (OOP, imperative, functional, procedural) Dynamically typed, automatic memory management and large standard library Available on almost all platforms NANO266 14
  • 15. NANO266 15 public class Hello { public static void main(String[] args) { System.out.println("Hello World!"); } } #include <iostream> int main() { std::cout << "Hello World!" << std::endl; return 0; } Java C++ print("Hello World!”) Python
  • 16. Scientific computing with Python NANO266 16 User-friendly and efficient numerical routines such as routines for numerical integration and optimization. Fundamental package for numerical computation. Defines array and matrix types and basic operations on them. High-performance, easy to use data structures. Publication-quality 2D plotting as well as rudimentary 3D plotting Rich interactive interface, letting you quickly process data and test ideas.
  • 17. Python Resources Python documentation https://www.python.org/doc/ Numpy docs http://docs.scipy.org/doc/numpy/reference/ NANO266 17
  • 18. Beyond simple scripts – Libraries for Computational Materials Science NANO266 18 https://wiki.fysik.dtu.dk/ase/https://www.pymatgen.org http://www.aflowlib.org/
  • 19. Python Materials Genomics (pymatgen) Core materials analysis powering the Materials Project • Defines core extensible Python objects for materials data representation. • Provides a robust and well-documented set of structure and thermodynamic analysis tools relevant to many applications. • Establishes an open platform for researchers to collaboratively develop sophisticated analyses of materials data. NANO266 19
  • 22. Final word on Programming A little investment in learning a programming language can yield big dividends in your efficiency as a materials modeler. NANO266 22
  • 23. Prep for Lab2 In Lab2, you will come face-to-face with a practical example of how using a programming language can make performing a sizable number of calculations much easier. The scripts are relatively simple and makes use of only Python’s standard library. They offer but a small glimpse of what is possible. Start your journey by going through the simple Python tutorial at http://www.python.org. NANO266 23