Maud ladybug icon none none none none
none none
Maud - Materials Analysis Using Diffraction - Developer  
none none none none none
none
Maud none News none Maud in action none Tutorial none Download none Developer none Maud forum none Bug Reporter none Maud helper
none
none
none
Diffraction 
none
none
none
   Maud   
none
none
   Download Maud   
none
none
   Maud old version 1.993   
none
none
   Rietquan   
none
none
   UDFtoRef (Reflectivity)   
none
none
Links 
none
none
none
   Maud Rietveld school   
none
none
   Beartex   
none
none
   COD (Crystallography Open Database)   
none
none
The author 
none
none
none
   Home page   
none
none
   Esqui Project   
none
none
   Cont@ct   
none
none
   Materials Engineering Dept.   
none
none
   Engineering Faculty   
none
none
none
none
none
   Hearth and Planetary Science Dept.   
none
none
   University of Cal. at Berkeley   
none
none
none
none

In this page we will show how to develop by yourself new models for Maud and how to compile and integrate them in the program. The needed tools and documentation are available. This section will expand more in the future with some more examples. Before to start be sure to have the latest Maud version installed. The Maud development kit here always refers to the last version.
 

step 1: get  Java Development Kit (to develop new models you need a Java compiler)

Check if you have already a Java Development Kit (it is different from the normal Java Runtime Technology as it permits also to develop and compile Java code). Open a console or a DOS window and type javac ; if you get the usage message than you are already set. The latest version of the JDK (Java Development Kit) can be found on the website of Sun Microsystems at (not needed for Mac OS X users and most of Linux users):

none J2SE JDK Download

on the Java Technology page at sun that will be open do the following:

  • Click on "Download JDK 5.0 update X" (X stand for the subversion number that change time by time). Do not download the "JRE 5.0......" as it does not contain the java compiler
  • In the new appearing page I would advice to choose the installer for your platform, for the Windows one there is one for offline download (bigger) where you download the complete installer and copy it to the computer where you need to install the jdk or a online installer (smaller) for installing directly from the internet.
Note for Mac OS X users: it may be helpful to have installed the developer tools you got with your Mac OS X installation DVD or CDs; they are not installed by default, so it is a good time to install them if you haven't already done; they provide a lot of additional bonus.

step 2: Download

Download the following:

none Download developer kit.

none Download ant tool (optional).

Notes: the ant tool is not stricly necessary but it will save a lot of time by automatically compile what you develop and will put everything in the correct place (one step for compiling and deploying). For Mac OS X the ant tool is already included if you have installed the Apple Developers Tools, so you can skip this step. The ant tool need to be installed and it is a general version for Linux/Unix/Windows/Mac OS X systems. You may wish to go on the internet and search for the latest version. When writing these notes the 1.6.5 was the last version.

step 3: Installation

To install the developer kit, you have to uncompress the dev_kit.zip into your Maud installation directory/folder, keeping the same directory structure as in the zip file (this is important if you use the ant build file to automatize the development work). In Mac OS X, the dev_kit folder must be in the same folder as the Maud.app application. In Linux and Windows the dev_kit directory must be in the directory where the maud.sh or maud.bat is. In the same folder or directory where you put the dev_kit create also a folder/directory with the name plugins . Be careful to lower/upper case. The reason for this directory structure is that the build.xml ant build file compile the java code files you create using the Maud.jar library in your Maud installation folder (see for example in the build file where the Maud.jar is supposed to be; for Mac OS X it looks in the Maud.app). Also, at the end, it creates a jar file and it copies it in the plugins folder/directory in the Maud program folder were Maud will look for it. You may aso modify this structure, but remember to specify to the compiler the Maud.jar and to put at the end the jar archive with your classes in the plugins folder in the starting Maud directory otherwise Maud will not use them.
In the dev_kit folder you will find also the Maud api in the java-docs directory. At the moment only few method and classes are documented (see for example the Atom class), more in the future, but at least you will find all the public and protected methods listed.
Two additional folder are presents. The src folder to be used for the java code under development; as an example a couple of different residual stress models are present, ready to be compiled. The second one, selected_Maud_Sources contains the Maud strain.java source code (the superclass for all residual strain models in Maud). So you can see which methods are overwrited and which one not in the two different models depending on the needs.
At the present only an example for residual strain models is available, more in the future (one for data/spectra loading and format is nearly ready).
Install the ant tool if you don't have it. Refer to the manual for the installation. Basically it just need to be extracted from the zip. Move the extracted ant-1.6.5 directory where you wish to keep it and add to the system path the location of the ant command line tool.

step 4: Compile/deploy the example and test it with Maud

To complete this step you should have already completed the installation step, ant included. If you do not want to use ant, you can figure out the step to do by looking at the build.xml file.

Open a terminal or a DOS window and navigate up to the dev_kit directory, go inside it.

Type ant on the command line and press enter. The ant tool will start (if properly installed) and use the build.xml file to compile all the java source files inside the src directory, it will archive them in a jar file with the name my_plugin.jar and copy the archive in the plugins directory in the Maud program directory.

Now start up Maud, open one example, select one phase or create one if no one is present in the phase list tab panel. Edit the phase and go to the Advanced models tab panel. For the Strain click on the combo box and scroll at the end, you will find two new models (Example Triaxial Stress Isotropic E and WSODF Popa-Balzar unfinished). Select one and try the options button, the model is ready to be used. You can have a look at the code for the triaxial stress model (a simple one). The Popa-Balzar model is included just to show how complex a model could be and how to use a list of parameters that can shrink or grow depending on crystal symmetries and user choice; it has also some options. The triaxial stress model instead has a fixed number of parameters and one option (not used). The triaxial stress model only overwrite one method for computation (the computeStrain method). The rest of the code is needed just to define names and parameters, initialize the object and provide a simple dialog that actually is the one opened when the user press the options button. All the rest (saving, changing, managing, listing etc.) is done automatically by the superclasses. You may see how to get a full working model you don't need to write to much, basically cut and paste the initialization methods, change the class name and parameter identifiers and write the method doing the real computation.

step 5: Develop your residual stress model

ATTENTION: make a copy of the dev_kit directory (mainly the src directory and build.xml file, the rest is only for documentation). So if you mess up something you can check as it was originally.

Delete (or move out) from the src directory the examples files with the entire directory structure (dot/bar/foo). Create your package with a unique directory structure (I personally use my internet address inverted as most of the Java developers: it.unitn.ing, and then I add other substructures to divide the different object/classes based on what they do; just have a look at the Maud api documents). Create the java file for your model with a proper name (same name as the class). My advice is to use the ExampleTriaxialStress.java file as a template; modify the name and inside the package and what you need.
What you need to modify or rewrite from the ExampleTriaxialStress.java file is the following:
- package dot.bar.foo; change the package name to reflect your directory structure.
- public class ExampleTriaxialStress ...... change the name of the class; use the same name for the file.
- public static String[] diclistc = ...... change CIF name for the options and parameter you need; in the diclistcrm Strings put the corresponding labels you want to appear in the interface.
- final static String id = ...... change the identifier here; it is the one appearing in the combo box. It is extremely important that the identifier here is unique as it is used wide in the program to identify the model. Change also the subsequent desc (for description) string.
- Do not modify nothing apart the Constructor names in the subsequent methods (between the two rows of stars). For example change ExampleTriaxialStress with myPersonalModelName.
- In the initConstant() method change the number of Nstring etc. to reflect your options and parameters number.
- In the initParameters() method initialize the options and parameters that need to initialized (for parameters it is necessary if their default value should be different than zero; otherwise by default they will initialize to zero).
- Change the computeStrain() method that it the one called by the program to compute the strain for each reflection at a different tilting angles (see the Strain.java file how the partly it works). For example in the triaxial method provided in the example, the strain in the 33 direction is computed from the parameters for provided angles.
- Finally change the JTSStrainOptionsD inner class to reflect your own parameters and options editing. Be careful that the addComponenttolist is a special method to add parameters that automatically take care of creating the magenta text field where if you click the right mouse button it permits to change the parameter status. Also this special textfield are automatically updated if the parameter value is changed elsewhere.
As you see the parameters are managed as Strings, but when a computation is under way you can use the parameterValues[] values that contain the double value obtained from each parameter String. This is done by a special routine once for all before computation start to avoid to convert Strings in double everytime athe computeStrain method (and all computation method for other calsses) is called. So durig a computation use the parameterValues[], in the dialog box for editing use the parameterField variable instead. Options (stringField) are always managed as String instead. See in case the Popa-Balzar example for more complex managing of options and parameters if needed.
When the editing is finished, go to the dev_kit root folder and edit the build.xml file to change the name to your jar archive before compiling. In the example the jar archive is called my_plugin. You may call it as you like. Just change the value for the package.name in the 7th line of the file. From the terminal or DOS window in the dev_kit directory type ant to build and deploy your classes to the Maud plugins directory. Then you are ready to run Maud and test your model.

When you have finish .....

If you wish to share your models with other you may consider sending the jar archive (and source code if you wish) to the Maud author for inclusion in the Maud program. We may think to prepare a special page for Maud extensions where the plugins developed may be stored or a link to a web page where the plugins is developed and distribuited.

New additions

Some new models from the Maud source code has been added to show how to develop other parts of the program. You can find them in the selected_Maud_Sources directory. In particular:
- Few examples for datafiles format. If your datafile format is not included in Maud you can add your own. Start to look first at the VeneziaDataFile.java , it contains also some instructions. If you need to load multiple spectra from a single datafile, then check also the others, for example the D1BIIDataFile load multiple spectra (when you need to load multiple spectra, you need to subclass MultDiffrDataFile instead of DiffrDataFile; check the difference with the VeneziaDataFile that load only one spectrum). The FdtDataFile.java is an example to load binary data. Instead the XRDMLDataFile shows how to load xml files. ATTENTION: Maud recognize the file format from the extension, so you should choose an extension for your format that it is not used already by the program. Look at the help on datafile format supported by Maud in the dataset edit window.
- GeometryDebyeScherrer.java shows how to write a model for different Lorentz-polarization corrections
- in the sizestrain folder you will find two models for size-strain modeling and one example for isotropic size-strains as well as the Popa model for anisotropic broadening. Some additional classes for spherical harmonics are included in util.
- under the cal folder some examples (only the polynomial) are reported on how to add a model for calibrating intensities and angular/d-space coordinates for the data.

Problems and errors

In case something does not seem to work you may refer to the author. I hope in the future the Forum can be used for development suggestion/exchange (at the present is down as it got an attack last year, no time to put it back online). Bugs or requests should be addressed to the Maud Bug Reporter. This will help to improve the program and enhance its features. If accessing that sections is not practical or you wish to deal directly with the author use the contact e-mail on the left column.

none
none none
none
none

Copyright (c) 1997-2012 Luca Lutterotti All Rights Reserved.

This software is the research result of Luca Lutterotti and it is
provided as it is as confidential and proprietary information.
You shall not disclose such Confidential Information and shall use
it only in accordance with the terms of the license agreement you
entered into with Luca Lutterotti.

Maud license

none