Adding Rappture to MATLAB Applications

Slides:



Advertisements
Similar presentations
View-Based Application Development Lecture 1 1. Flows of Lecture 1 Before Lab Introduction to the Game to be developed in this workshop Comparison between.
Advertisements

1 Input/Output and Debugging  How to use IO Streams  How to debug programs  Help on coursework.
1 Input/Output and Debugging  How to use IO Streams  How to debug programs.
Cluster Computing at IQSS Alex Storer, Research Technology Consultant.
1 What’s Under the Hood? Michael McLennan HUBzero® Platform for Scientific Collaboration Purdue University This work licensed under Creative Commons See.
Carol Song Sr. Research Scientist Rosen Center for Advanced Computing Thanks to M. McLennan for the Rappture slides!
RCAC Research Computing Presents: DiaGird Overview Tuesday, September 24, 2013.
Rappture with C and Fortran Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration.
1 Rappture with C and Fortran Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration This work licensed under Creative Commons.
File processing with functions H&K Chapter 3 Instructor – Gokcen Cilingir Cpt S 121 (June 27, 2011) Washington State University.
EGR 106 – Truss Design Project (cont.) Truss design programs Graphical interface tools in Matlab Saving and loading data Formatted output Project Assignment.
Operating Systems Simulator Jessica Craddock Kelvin Whyms CPSC 410.
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
1 Using Workspaces to Develop Simulation Tools Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration This work licensed under.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
1 Uploading and Publishing New Tools Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration This work licensed under Creative.
1 More Rappture Objects Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration This work licensed under Creative Commons See.
MATLAB Second Seminar. Previous lesson Last lesson We learnt how to: Interact with MATLAB in the MATLAB command window by typing commands at the command.
FrmModule-SY. Change #1 When you change the New Company Code more than once, it stack the company codes in the Destination Path Y05 = c:\cmswin11.2\y05.
1 More Rappture Objects Michael McLennan HUBzero® Platform for Scientific Collaboration Purdue University This work licensed under Creative Commons See.
Regression Testing Michael McLennan HUBzero® Platform for Scientific Collaboration Purdue University This work licensed under Creative Commons See license.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
OpenSees on NEEShub Frank McKenna UC Berkeley. Bell’s Law Bell's Law of Computer Class formation was discovered about It states that technology.
Building PERL Scripts on a Windows system* *and running those scripts on an Apache server!
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
1 Advanced Visualization Michael McLennan HUBzero® Platform for Scientific Collaboration Purdue University This work licensed under Creative Commons See.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Advanced Rappture Concepts and Tips Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
Fall 08, Oct 31ELEC Lecture 8 (Updated) 1 Lecture 8: Design, Simulation Synthesis and Test Tools ELEC 2200: Digital Logic Circuits Nitin Yogi
1 Input / Output Input – reads/gets data for the program Output – the product, after processing Both can be: interactive I/O (while program is running)
Graphical User Interface You will be used to using programs that have a graphical user interface (GUI). So far you have been writing programs that have.
ENG College of Engineering Engineering Education Innovation Center 1 More Script Files in MATLAB Script File I/O : Chapter 4 1.Global Variables.
Introducing the Rappture Toolkit Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration.
What’s Under the Hood? Michael McLennan HUBzero® Platform for Scientific Collaboration Purdue University This work licensed under Creative Commons See.
Java Programming, Second Edition Appendix A Working with Java SDK 1.4.
COMP 116: Introduction to Scientific Programming Lecture 29: File I/O.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Sequencing The most simple type of program uses sequencing, a set of instructions carried out one after another. Start End Display “Computer” Display “Science”
File Handling in QBASIC
Juanita Cano City of Sacramento Spring 2014 Geography 375.
1 Introducing the Rappture Toolkit Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration This work licensed under Creative.
AHM04: Sep 2004 Nottingham CCLRC e-Science Centre eMinerals: Environment from the Molecular Level Managing simulation data Lisa Blanshard e- Science Data.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
1 Regression Testing Michael McLennan HUBzero® Platform for Scientific Collaboration Purdue University This work licensed under Creative Commons See license.
Ganga/Dirac Data Management meeting October 2003 Gennady Kuznetsov Production Manager Tools and Ganga (New Architecture)
Creating Flexible, Script-Controlled Autonomous Software Example Explanation.
“Port Monitor”: progress & open questions Torsten Wilde and James Kohl Oak Ridge National Laboratory CCA Forum Quarterly Meeting Santa Fe, NM ~ October.
Rappture with Fortran Michael McLennan HUBzero® Platform for Scientific Collaboration Purdue University This work licensed under Creative Commons See license.
VLSI Synthesis and Simulation Tools Nitin Yogi 01/09/2009
Topic 2: Hardware and Software
Development Environment
MATLAB – More Script Files
BAHASA PEMROGRAMAN MATLAB as an Engineering Tool & Programming Language a lecture note for Civil Engineering students of PETRA Christian University Doddy.
How to change the LOGO on PecStarWeb V3.6
SQL and SQL*Plus Interaction
OpenGL project setup.
Lesson 1 An Introduction
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
Managing results files
Gannon University Frank Xu
How to Create a KPI Dashboard Report
Software Installation
HOW TO CREATE A CLASS Steps:
Code Analysis, Repository and Modelling for e-Neuroscience
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
DAT2343 LMC Simulator Usage © Alan T. Pinck / Algonquin College; 2003.
Scripts In Matlab.
Presentation transcript:

Adding Rappture to MATLAB Applications Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration

Example: Matlab/Octave Tool The usual way… The Rappture way… % matlab -nodisplay -r fermi Enter the Fermi level (eV): Ef = 2.4 Enter the temperature (K): T = 77 % more out.dat FERMI-DIRAC FUNCTION F1/2 f1/2 Energy (eV) ------------ ------------ 0.999955 2.33365 0.99995 2.33431 0.999944 2.33498 https://developer.nanohub.org/projects/rappture source code: rappture/examples/app-fermi

How does it work? tool.xml executable description of tool, including inputs and outputs Rappture GUI Produces the user interface automatically!

What is the interface? number number curve Input Physics Output disp('Enter the Fermi level (eV):'); Ef = input(' Ef = '); disp('Enter the temperature (K):'); T = input(' T = '); kT = 8.61734e-5 * T; Emin = Ef - 10*kT; Emax = Ef + 10*kT; E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); fid = fopen('out.dat','w'); fprintf(fid,'FERMI-DIRAC FUNCTION F1/2\n\n'); fprintf(fid,‘f1/2 Energy (eV)\n'); fprintf(fid,'------------ ------------\n'); fprintf(fid,'%12g %12g\n', [f; E]); fclose(fid); quit; number curve

Describing inputs Rappture description of a number input <number id="Ef"> <about> <label>Fermi Level</label> <description>Energy at center of distribution.</description> </about> <units>eV</units> <min>-10eV</min> <max>10eV</max> <default>0eV</default> </number> disp('Enter the Fermi level (eV):'); Ef = input(' Ef = '); disp('Enter the temperature (K):'); T = input(' T = '); kT = 8.61734e-5 * T; Emin = Ef - 10*kT; Emax = Ef + 10*kT; E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); fid = fopen('out.dat','w'); fprintf(fid,'FERMI-DIRAC FUNCTION F1/2\n\n'); fprintf(fid,‘f1/2 Energy (eV)\n'); fprintf(fid,'------------ ------------\n'); fprintf(fid,'%12g %12g\n', [f; E]); fclose(fid); quit; Rappture description of a number input

Describing inputs disp('Enter the Fermi level (eV):'); Ef = input(' Ef = '); disp('Enter the temperature (K):'); T = input(' T = '); kT = 8.61734e-5 * T; Emin = Ef - 10*kT; Emax = Ef + 10*kT; E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); fid = fopen('out.dat','w'); fprintf(fid,'FERMI-DIRAC FUNCTION F1/2\n\n'); fprintf(fid,‘f1/2 Energy (eV)\n'); fprintf(fid,'------------ ------------\n'); fprintf(fid,'%12g %12g\n', [f; E]); fclose(fid); quit; <number id="temperature"> <about> <label>Ambient temperature</label> <description>Temperature of the environment.</description> </about> <units>K</units> <min>0K</min> <max>500K</max> <default>300K</default> <preset> <value>77K</value> <label>77K (liquid nitrogen)</label> </preset> … </number>

Describing outputs disp('Enter the Fermi level (eV):'); Ef = input(' Ef = '); disp('Enter the temperature (K):'); T = input(' T = '); kT = 8.61734e-5 * T; Emin = Ef - 10*kT; Emax = Ef + 10*kT; E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); fid = fopen('out.dat','w'); fprintf(fid,'FERMI-DIRAC FUNCTION F1/2\n\n'); fprintf(fid,‘f1/2 Energy (eV)\n'); fprintf(fid,'------------ ------------\n'); fprintf(fid,'%12g %12g\n', [f; E]); fclose(fid); quit; <curve id="f12"> <about><label>Fermi-Dirac Factor</label></about> <xaxis> <label>Fermi-Dirac Factor</label> </xaxis> <yaxis> <label>Energy</label> <units>eV</units> </yaxis> </curve>

Describing the Whole Tool File: tool.xml <?xml version="1.0"?> <run> <tool> <about>Press Simulate to view results.</about> <command>matlab –nodisplay -r infile='@driver‘,path(‘@tool’,path), fermi</command> </tool> <input> <number id="temperature">…</number> <number id="Ef">…</number> </input> <output> <curve id="f12">…</curve> </output> </run> Basic structure from this page:

Half-way there Once you’ve created the tool.xml file, you can test the GUI tool.xml <XML> executable Rappture Fix this next… Rappture GUI % cd tooldir % ls tool.xml % rappture

How does it work? description of tool, including inputs and outputs Only input file needed by your program tool.xml <XML> driver159.xml <XML> description of tool, including inputs and outputs Rappture Library API Rappture executable 300K 300K Rappture GUI run2743.xml <XML> 300K All inputs and outputs—complete record of the run

Updating our original script fermi.m Matlab script disp('Enter the Fermi level (eV):'); Ef = input(' Ef = '); disp('Enter the temperature (K):'); T = input(' T = '); % do fermi calculations (science)... kT = 8.61734e-5 * T; Emin = Ef - 10*kT; Emax = Ef + 10*kT; E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); … Input Physics

Read the fermi level fermi.m Matlab script tool.xml: % open the driver file lib = rpLib(infile); % get the input values and convert to correct units Ef = rpLibGetString(lib,'input.number(Ef).current'); [Ef,err] = rpUnitsConvertDbl(Ef,'eV'); T = rpLibGetString(lib,'input.number(temperature).current'); [T,err] = rpUnitsConvertDbl(T,'K'); % do fermi calculations (science)... kT = 8.61734e-5 * T; Emin = Ef - 10*kT; Emax = Ef + 10*kT; E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); … “240meV” 2.4 tool.xml: <?xml version="1.0"?> <run> … <input> input <number id="Ef"> .number(Ef) <current>2.4eV</current> .current </number> </input> </run>

Read the temperature fermi.m Matlab script % open the driver file lib = rpLib(infile); % get the input values and convert to correct units Ef = rpLibGetString(lib,'input.number(Ef).current'); [Ef,err] = rpUnitsConvertDbl(Ef,'eV'); T = rpLibGetString(lib,'input.number(temperature).current'); [T,err] = rpUnitsConvertDbl(T,'K'); % do fermi calculations (science)... kT = 8.61734e-5 * T; Emin = Ef - 10*kT; Emax = Ef + 10*kT; E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); … “100C” 373.15

Updating our original script fermi.m Matlab script … E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); fid = fopen('out.dat','w'); fprintf(fid,'FERMI-DIRAC FUNCTION F1/2\n\n'); fprintf(fid,‘f1/2 Energy (eV)\n'); fprintf(fid,'------------ ------------\n'); fprintf(fid,'%12g %12g\n', [f; E]); fclose(fid); quit; Physics Output

Save the results fermi.m Matlab script Means “overwrite” (no “append”) … E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); % store output in curve putStr = sprintf('%12g %12g\n', [f; E]); rpLibPutString(lib,'output.curve(f12).component.xy',putStr,0); % save the output rpLibResult(lib); quit; Means “overwrite” (no “append”) run1128018316.xml <XML>

Save the results fermi.m Matlab script … E = linspace(Emin,Emax,200); f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); % store output in curve putStr = sprintf('%12g %12g\n', [f; E]); rpLibPutString(lib,'output.curve(f12).component.xy',putStr,0); % save the output rpLibResult(lib); quit; <?xml version="1.0"?> <run> … <output> <curve id="f12"> <component> <xy> 0.999955 2.33365 0.99995 2.33431 0.999944 2.33498 </output> </run> run1128018316.xml <XML>

How does the program get invoked? Run the program How does the program get invoked? tool.xml <XML> driver159.xml <XML> executable Rappture 300K 300K Rappture GUI run2743.xml <XML> 300K

How does the program get invoked? tool.xml <XML> Replaced with directory containing tool.xml file Ex: /apps/yourtool/current Replaced with name of driver file Ex: driver159.xml <?xml version="1.0"?> <run> <tool> <about>Press Simulate to view results.</about> <command>matlab –nodisplay –r infile='@driver‘,path(‘@tool’,path),fermi </command> </tool> <input> … </input> <output> </output> </run> Set infile to the name of driver file Add tool directory to search path Invoke fermi.m

How does the program get invoked? matlab –nodisplay -r infile='@driver‘,path(‘@tool’,path),fermi matlab –nodisplay -r infile=‘driver159.xml‘,path(‘/apps/yourtool/current’,path),fermi % open the driver file lib = rpLib(infile); % get the input values and convert to correct units Ef = rpLibGetString(lib,'input.number(Ef).current'); [Ef,err] = rpUnitsConvertDbl(Ef,'eV'); … Rappture … % save the output rpLibResult(lib); quit; run2743.xml <XML> 300K

Using Octave 3 Rappture run2743.xml octave --silent --eval infile='@driver‘,path(‘@tool’,path),fermi octave --silent --eval infile=‘driver159.xml‘,path(‘/apps/yourtool/current’,path),fermi % open the driver file lib = rpLib(infile); % get the input values and convert to correct units Ef = rpLibGetString(lib,'input.number(Ef).current'); [Ef,err] = rpUnitsConvertDbl(Ef,'eV'); … Rappture … % save the output rpLibResult(lib); quit; run2743.xml <XML> 300K

Using Octave 2 Rappture Watch out! Use curly braces here octave --silent --eval infile='@driver‘,path(‘@tool’,path),fermi octave --silent @tool/fermi.m @driver octave --silent /apps/yourtool/current/fermi.m driver159.xml % open the driver file lib = rpLib(argv{1}); % get the input values and convert to correct units Ef = rpLibGetString(lib,'input.number(Ef).current'); [Ef,err] = rpUnitsConvertDbl(Ef,'eV'); … Rappture Watch out! Use curly braces here

Debugging If something goes wrong, MATLAB goes into “debug” mode: Waiting for you to type a MATLAB command Click Abort instead Run it by hand: $ ls driver1529.xml fermi.m tool.xml $ use rappture $ matlab –r infile=\’driver1529.xml\’,fermi