view pm_nq.xml @ 2:37a2a5686710 draft default tip

planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/pm_nq commit 389608650050596b28bc0c055de9f98c513a6f65
author muon-spectroscopy-computational-project
date Fri, 26 Jul 2024 12:57:47 +0000
parents f08b8c705e74
children
line wrap: on
line source

<tool id="pm_nq" name="PyMuonSuite Quantum Averaging" version="@PYMUONSUITE_VERSION@+galaxy@WRAPPER_VERSION@" python_template_version="3.5" profile="22.05">
    <description>generate and average displaced structures</description>
    <macros>
        <!-- version of this tool wrapper (integer) -->
        <token name="@WRAPPER_VERSION@">1</token>
        <import>muon_macros.xml</import>
    </macros>
    <creator>
        <person givenName="Patrick" familyName="Austin" url="https://github.com/patrick-austin" identifier="https://orcid.org/0000-0002-6279-7823"/>
        <organization url="https://muon-spectroscopy-computational-project.github.io/index.html" name="The Muon Spectroscopy Computational Project"/>
    </creator>
    <requirements>
        <requirement type="package" version="@PYMUONSUITE_VERSION@">pymuonsuite</requirement>
        <requirement type="package" version="1.0.0">euphonic</requirement>
        <requirement type="package" version="3.0">zip</requirement>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
        structure_name=\$(sed 's/ //g' <<< '$structure.name') &&
        #if $task.task == 'write':
            out_folder=\$(sed 's/.$structure.extension/_displaced/g' <<< '$structure.name') &&
            ln -s '$structure' \$structure_name &&
            #if $task.phonon.phonon.phonon_source_type == "castep":
                phonon_source_file_name=\$(sed 's/ //g' <<< '$task.phonon.phonon.phonon_source_castep.name') &&
                ln -s '$task.phonon.phonon.phonon_source_castep' \$phonon_source_file_name &&
                castep_file_name=\$(sed 's/ //g' <<< '$task.phonon.phonon.castep_file.name') &&
                ln -s '$task.phonon.phonon.castep_file' \$castep_file_name &&
            #else if $task.phonon.phonon.phonon_source_type == "dftb+":
                phonon_source_file_name=\$(sed 's/ //g' <<< '$task.phonon.phonon.phonon_source_dftb.name') &&
                ln -s '$task.phonon.phonon.phonon_source_dftb' \$phonon_source_file_name &&
                gen_file_name=\$(sed 's/ //g' <<< '$task.phonon.phonon.gen_file.name') &&
                ln -s '$task.phonon.phonon.gen_file' \$gen_file_name &&
            #end if
            #if $task.calculator.script_file:
                script_file_name=\$(sed 's/ //g' <<< '$task.calculator.script_file.name') &&
                ln -s '$task.calculator.script_file' \$script_file_name &&
            #end if
            #if $task.calculator.calculator.calculator == 'castep' and $task.calculator.calculator.castep_param:
                castep_param_name=\$(sed 's/ //g' <<< '$task.calculator.calculator.castep_param.name') &&
                ln -s '$task.calculator.calculator.castep_param' \$castep_param_name &&
            #end if
            ln -s '$params_yaml' params.yaml &&
            pm-nq -t w \$structure_name params.yaml &&
            find * > tree.txt &&
            zip -r out_zip.zip *
        #else if $task.task == 'read':
            unzip '$task.zipped_input' &&
            pm-nq -t r \$structure_name params.yaml &&
            cat averages.dat
        #end if
    ]]></command>
    <configfiles>
        <configfile name="params_yaml">#if $task.task == 'write':
method: $task.sampling.method.method
mu_symbol: $task.mu_symbol
mu_index: $task.mu_index
grid_n: $task.sampling.grid_n
sigma_n: $task.sampling.sigma_n
#set $k_points_grid_formatted = $task.calculator.k_points_grid.replace('__ob__', '[').replace('__cb__', ']')
k_points_grid: $k_points_grid_formatted
avgprop: $task.sampling.avgprop
calculator: $task.calculator.calculator.calculator
write_allconf: $task.write_allconf
displace_T: $task.sampling.displace_T
#if $task.sampling.average_T:
average_T: $task.sampling.average_T
#end if
#if $task.sampling.method.method == 'montecarlo' and $task.sampling.method.random_seed:
random_seed: $task.sampling.random_seed
#end if
#if $task.calculator.calculator.calculator == 'dftb+':
dftb_set: $task.calculator.calculator.dftb_set
dftb_pbc: $task.calculator.calculator.dftb_pbc
#end if
phonon_source_type: $task.phonon.phonon.phonon_source_type
#if $task.phonon.phonon.phonon_source_type == 'castep':
#set $phonon_source_file_name = $task.phonon.phonon.phonon_source_castep.name.replace(' ', '')
#else if $task.phonon.phonon.phonon_source_type == 'dftb+':
#set $phonon_source_file_name = $task.phonon.phonon.phonon_source_dftb.name.replace(' ', '')
#end if
phonon_source_file: $phonon_source_file_name
#if $task.calculator.script_file:
#set $script_file_name = $task.calculator.script_file.name.replace(' ', '')
script_file: $script_file_name
#end if
#if $task.calculator.calculator.calculator == 'castep' and $task.calculator.calculator.castep_param:
#set $castep_param_name = $task.calculator.calculator.castep_param.name.replace(' ', '')
castep_param: $castep_param_name
#end if
#end if</configfile>
    </configfiles>
    <inputs>
        <param argument="structure" type="data" format="cell, cif, xyz, extxyz" label="Structure File" help="The muonated structure to make displacements to. The original file will be preserved. Accepted file types: CELL, CIF, XYZ (standard or extended)."/>
        <conditional name="task">
            <param argument="task" type="select" display="radio" label="Task" help="Task to perform with pm-nq. Either generate (write) displaced structures, or average (read) those structures.">
                <option value="write">Generate</option>
                <option value="read">Average</option>
            </param>
            <when value="write">
                <param argument="mu_symbol" type="text" value="H:mu" label="Muon Symbol" help="Custom label that will be used to identify muon in the structure file."/>
                <param argument="mu_index" type="integer" value="-1" label="Muon Index" help="If the Muon Symbol is not present in the cell, then the atom in the cell with this index will be treated as the muon instead. Not used if the Muon Symbol is present. Defaults to the last atom in the structure."/>
                <section name="phonon" expanded="true" title="Phonon Source">
                    <conditional name="phonon">
                        <param argument="phonon_source_type" type="select" display="radio" label="Phonon Type" help="The format of the phonon file.">
                            <option value="castep">CASTEP</option>
                            <option value="dftb+">DFTB+</option>
                        </param>
                        <when value="castep">
                            <param name="phonon_source_castep" type="data" format="txt" label="Phonon File" help="Source file for phonon modes of the muonated structure."/>
                            <param name="castep_file" type="data" format="castep" label="CASTEP Log (.castep)" help="The CASTEP log produced when generating the Phonon File."/>
                        </when>
                        <when value="dftb+">
                            <param name="phonon_source_dftb" type="data" format="binary" label="Phonon File" help="Source file for phonon modes of the muonated structure."/>
                            <param name="gen_file" type="data" format="txt" label="Gen File" help="GEN formatted geometry file for DFTB+."/>
                        </when>
                    </conditional>
                </section>
                <section name="calculator" expanded="true" title="Calculator Settings">
                    <conditional name="calculator">
                        <param argument="calculator" type="select" display="radio" label="Calculator Type" help="Which software to use to calculate the property.">
                            <option value="castep">CASTEP</option>
                            <option value="dftb+">DFTB+</option>
                        </param>
                        <when value="castep">
                            <param argument="castep_param" type="data" format="txt" optional="true" label="Castep Parameters File" help="For convenience, this file is copied to all output directories (optional)."/>
                        </when>
                        <when value="dftb+">
                            <expand macro="dftb+"/>
                        </when>
                    </conditional>
                    <expand macro="k_points_grid"/>
                    <param argument="script_file" type="data" format="txt" optional="true" label="Script File" help="For convenience when running CASTEP or DFTB+, this script file is copied to all output directories. Occurences of {seedname} will be replaced according to the directory name for each job. (optional) "/>
                </section>
                <section name="sampling" expanded="true" title="Sampling Settings">
                    <param argument="avgprop" type="select" display="radio" label="Averaged Property" help="Property to be calculated.">
                        <option value="hyperfine">Hyperfine</option>
                        <option value="charge">Charge</option>
                    </param>
                    <param argument="displace_T" type="float" value="0" min="0" label="Displacement Temperature" help="Temperature used to generate displacements."/>
                    <param argument="average_T" type="float" optional="true" min="0" label="Averaging Temperature" help="Temperature used when averaging property (optional). If unset, will use the same value as Displacement Temperature."/>
                    
                    <conditional name="method">
                        <param argument="method" type="select" display="radio" label="Method" help="Method used to calculate thermal average. Either displaces independently along the three most significant phonon modes (sampling a 3D grid of values) or uses Monte Carlo to randomly sample a fixed number of points from multiple modes at the same time.">
                            <option value="independent">Independent</option>
                            <option value="montecarlo">Monte Carlo</option>
                        </param>
                        <when value="independent"/>
                        <when value="montecarlo">
                            <param argument="random_seed" type="integer" optional="true" label="Random Seed" help="Seed to use for sampling Monte Carlo distribution."/>
                        </when>
                    </conditional>

                    <param argument="grid_n" type="integer" value="20" min="1" label="Grid Points" help="Number of points to sample along each phonon mode or thermal line."/>
                    <param argument="sigma_n" type="float" value="3" min="0" label="Sigma Number" help="Number of sigmas to sample in the harmonic approximation."/>
                </section>
                <param argument="write_allconf" type="boolean" label="Write All Configurations" help="Whether to write a 'collective' file containing all the displaced positions."/>
            </when>
            <when value="read">
                <param name="zipped_input" type="data" format="zip" label="Zipped Input" help="A zipped directory structure containing the output of the generate mode, and the results of running CASTEP or DFTB+ to generate the desired property."/>
            </when>
        </conditional>
        <param type="hidden" name="testing" label="Test mode" value="false"/>
    </inputs>
    <outputs>
        <data label="Displaced Structures on ${on_string}" name="displaced_structures" format="zip" from_work_dir="out_zip.zip">
            <filter>(task['task'] == 'write')</filter>
        </data>
        <data label="File tree (testing only)" name="file_tree" format="txt" from_work_dir="tree.txt" hidden="true">
            <filter>(task['task'] == 'write' and testing == 'true')</filter>
        </data>
        <data label="Averaged Property on ${on_string}" name="averaged_property" format="txt" from_work_dir="averages.dat">
            <filter>(task['task'] == 'read')</filter>
        </data>
    </outputs>
    <tests>
        <!-- Test CASTEP without default values -->
        <test expect_num_outputs="2">
            <param name="testing" value="true"/>
            <param name="structure" value="Si.cell" ftype="cell"/>
            <conditional name="task">
                <param name="task" value="write"/>
                <section name="phonon">
                    <conditional name="phonon">
                        <param name="phonon_source_castep" value="Si.phonon" ftype="txt"/>
                        <param name="castep_file" value="Si.castep"/>
                    </conditional>
                </section>
                <section name="calculator">
                </section>
                <section name="sampling">
                </section>
            </conditional>
            <output name="file_tree" file="tree.txt" ftype="txt" sort="true"/>
        </test>
        <!-- Test CASTEP with optional extra files -->
        <test expect_num_outputs="2">
            <param name="testing" value="true"/>
            <param name="structure" value="Si.cell" ftype="cell"/>
            <conditional name="task">
                <param name="task" value="write"/>
                <section name="phonon">
                    <conditional name="phonon">
                        <param name="phonon_source_castep" value="Si.phonon" ftype="txt"/>
                        <param name="castep_file" value="Si.castep"/>
                    </conditional>
                </section>
                <section name="calculator">
                    <param name="script_file" value="submit.sh" ftype="txt"/>
                    <conditional name="calculator">
                        <param name="castep_param" value="Si.param"/>
                    </conditional>
                </section>
                <section name="sampling">
                </section>
            </conditional>
            <output name="file_tree" file="tree_extra_files.txt" ftype="txt" sort="true"/>
        </test>
        <!-- Test DFTB+ -->
        <test expect_num_outputs="2">
            <param name="testing" value="true"/>
            <param name="structure" value="ethyleneMu_opt.xyz" ftype="xyz"/>
            <conditional name="task">
                <param name="task" value="write"/>
                <section name="phonon">
                    <conditional name="phonon">
                        <param name="phonon_source_type" value="dftb+"/>
                        <param name="phonon_source_dftb" value="ethyleneMu_opt.phonons.pkl" ftype="auto"/>
                        <param name="gen_file" value="geo_end.gen" ftype="txt"/>
                    </conditional>
                </section>
                <section name="calculator">
                    <conditional name="calculator">
                        <param name="calculator" value="dftb+"/>
                    </conditional>
                </section>
                <section name="sampling">
                    <conditional name="method">
                        <param name="method" value="montecarlo"/>
                    </conditional>
                </section>
            </conditional>
            <output name="file_tree" file="tree_dftb.txt" ftype="txt" sort="true"/>
        </test>
        <!-- Test Read Task -->
        <test expect_num_outputs="1">
            <param name="structure" value="Si.cell" ftype="cell"/>
            <conditional name="task">
                <param name="task" value="read"/>
                <param name="zipped_input" value="zipped_input.zip" ftype="zip"/>
            </conditional>
            <output name="averaged_property" file="averages.dat" ftype="txt"/>
        </test>
    </tests>
    <help><![CDATA[
        Given an input muonated structure (containing a muon), displaces the muon along its normal modes and performs vibrational averaging. There are three steps to using this tool:
          1. Generate displaced structures with `-t w` (write) flag
          2. Calculate the property for all displaced structures using CASTEP or DFTB+
          3. Average the proprty across all displaced structures with `-t r` (read) flag

        Note that currently only steps 1 and 3 are possible in Galaxy. In order to perform step 2, download the zipped output of step 1, run CASTEP/DFTB+ elsewhere, re-zip the directories including the output properties, and finally run step 3 using this zip file as the input.

        Command-line usage: pm-nq [-h] [-t {r,w}] structure parameter_file

        All data is licensed under the Creative Commons Attribution-ShareAlike 4.0
        International License. The full text of the license can be found at:

        https://creativecommons.org/licenses/by-sa/4.0/legalcode

        For specific data sets remember to cite the following papers, by element :

        | **3-ob-1**

        +--------------+------------------------------------------------+-----------------------------------+------------------------------------+
        | [JCTC2013]   | \ J. Chem. Theory Comput., 2013, 9, 338-354.   | (O, N, C, H)                      | https://doi.org/10.1021/ct300849w  |
        +--------------+------------------------------------------------+-----------------------------------+------------------------------------+
        | [JCTC2014]   | \ J. Chem. Theory Comput., 2014, 10, 1518-1537.| (P,S-\*)                          | https://doi.org/10.1021/ct401002w  |
        +--------------+------------------------------------------------+-----------------------------------+------------------------------------+
        | [JCTC2015-1] | \ J. Phys. Chem. B, 2015, 119, 1062-1082.      | (Mg,Zn-\*)                        | https://doi.org/10.1021/jp506557r  |
        +--------------+------------------------------------------------+-----------------------------------+------------------------------------+
        | [JCTC2015-2] | \ J. Chem. Theory Comput., 2015, 11, 332-342.  | (Na,F,K,Ca,Cl,Br,I-\*)            | https://doi.org/10.1021/ct5009137  |
        +--------------+------------------------------------------------+-----------------------------------+------------------------------------+

        |
        | **pbc-0-3**

        +------------+--------------------------------------------------------------------------------------------+---------+------------------------------------------------+
        |   [SiC]    | \ E. Rauls, R. Gutierrez, J. Elsner, and Th. Frauenheim, Sol. State Comm. 111, 459 (1999)  | (Si-C)  | https://doi.org/10.1016/S0038-1098(99)00137-4  |
        +------------+--------------------------------------------------------------------------------------------+---------+------------------------------------------------+
        |   [SiO]    | \ C. Koehler, Z. Hajnal, P. Deak, Th. Frauenheim, S. Suhai, Phys. Rev. B 64, 085333 (2001) |  (Si-O) | https://doi.org/10.1103/PhysRevB.64.085333     |
        +------------+--------------------------------------------------------------------------------------------+---------+------------------------------------------------+
        | [Silicon]  | \ A. Sieck, Th. Frauenheim, and K. A. Jackson, phys. stat. sol. (b) 240, 537 (2003).       |  (Si)   | https://doi.org/10.1002/pssb.200301886         |
        +------------+--------------------------------------------------------------------------------------------+---------+------------------------------------------------+
        | [Fluorine] | \ C. Koehler and Th. Frauenheim, Surf. Sci. 600, 453 (2006).                               | \ (F)   | https://doi.org/10.1016/j.susc.2005.10.044     |
        +------------+--------------------------------------------------------------------------------------------+---------+------------------------------------------------+
        |   [Iron]   | \ C. Koehler, G. Seifert and Th. Frauenheim, Chem. Phys. 309, 23 (2005).                   |   (Fe)  | https://doi.org/10.1016/j.chemphys.2004.03.034 |
        +------------+--------------------------------------------------------------------------------------------+---------+------------------------------------------------+
        |   [SiSi]   | \ A. Sieck, PhD. Thesis, University of Paderborn, 2000.                                    | (Si-Si) | https://www.osti.gov/etdeweb/biblio/20249635   |
        +------------+--------------------------------------------------------------------------------------------+---------+------------------------------------------------+

        |
        | The full sets and all other data can be found at the following URLs:

        +----------+------------------------------------------------------------+
        |  3-ob-1  |   https://www.dftb.org/parameters/download/3ob/3ob-3-1-cc/ |
        +----------+------------------------------------------------------------+
        | pbc-0-3  |  https://www.dftb.org/parameters/download/pbc/pbc-0-3-cc/  |
        +----------+------------------------------------------------------------+

        |

        .. _Generate muonated structures: /tool_runner?tool_id=pm_muairss_write
    ]]></help>
    <citations>
        <citation type="doi">@PYMUONSUITE_CITATION@</citation>
    </citations>
</tool>