view pm_uep_opt.xml @ 6:da177c1ec3b4 draft default tip

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

<tool id="pm_uep_opt" name="PyMuonSuite AIRSS UEP Optimise" version="@PYMUONSUITE_VERSION@+galaxy@WRAPPER_VERSION@" python_template_version="3.5" profile="22.05" license="MIT">
    <description>run UEP optimisation</description>
    <macros>
        <!-- version of this tool wrapper (integer) -->
        <token name="@WRAPPER_VERSION@">2</token>
        <import>muon_macros.xml</import>
    </macros>
    <creator>
        <person givenName="Jyothish" familyName="Thomas" identifier="https://orcid.org/0000-0003-4724-6924"/>
        <person givenName="Eli" familyName="Chadwick" url="https://github.com/elichad" identifier="https://orcid.org/0000-0002-0035-6475"/>
        <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="3.0">zip</requirement>
    </requirements>
    <required_files>
        <include type="literal" path="run.sh"/>
        <include type="literal" path="get_out_folder.py"/>
    </required_files>
    <command detect_errors="exit_code"><![CDATA[
        cat $params_yaml > params.yaml &&
        structure_name_internal='input_structure.$structure.ext' &&
        ln -s '$structure' \$structure_name_internal &&
        pm-muairss -t w \$structure_name_internal params.yaml &&
        #if $generation_params.allpos_ext != "none":
            mv allpos.$generation_params.allpos_ext $allpos_file &&
        #end if
        ln -s '$charge_density' input_structure.den_fmt && 
        ln -s '$castep_log' input_structure.castep &&
        out_folder="`python '${__tool_directory__}/get_out_folder.py'`" &&
        find \$out_folder -type f -name "*.yaml" | xargs sed -i "s#^chden_path: .*#chden_path: .\/#g" &&
        find \$out_folder -type f -name "*.yaml" | xargs sed -i "s#^chden_seed: .*#chden_seed: input_structure#g" &&
        bash '${__tool_directory__}/run.sh' \$out_folder &&
        zip -r out_zip.zip \$out_folder params.yaml \$structure_name_internal &&
        find \$out_folder > tree.txt
    ]]></command>
    <configfiles>
        <configfile name="params_yaml">poisson_r: $generation_params.poisson_r
vdw_scale: $generation_params.vdw_scale
#if $generation_params.random_seed:
random_seed: $generation_params.random_seed
#end if
#if $generation_params.allpos_ext!="none":
allpos_filename: allpos.$generation_params.allpos_ext
#end if
calculator: uep
charged: true
geom_steps: $optimisation_params.geom_steps
geom_force_tol: $optimisation_params.geom_force_tol
uep_gw_factor: $optimisation_params.uep_gw_factor</configfile>
    </configfiles>
    <inputs>
        <param type="data" name="structure" label="Structure file" format="cell, cif, extxyz" help="The structure to add muons to. The original file will be preserved. Accepted file types: CELL, CIF, XYZ (extended only)."/>
        <param type="data" name="charge_density" label="Charge density file (.den_fmt)" format="den_fmt" help="The charge density file created by CASTEP during your initial DFT simulation for the structure."/>
        <param type="data" name="castep_log" label="CASTEP log (.castep)" format="castep" help="The CASTEP log for your initial DFT simulation for the structure."/>
        <section name="generation_params" expanded="true" title="Generation Parameters">
            <param type="float" argument="poisson_r" value="0.8" min="0.0" label="Poisson radius" help=" Poisson sphere radius to use for random generation. No two starting muon positions will be closer than this distance. Smaller values make for bigger structure sets."/>
            <param type="float" argument="vdw_scale" value="0.5" min="0.0" label="Van der Waals scale" help="Van der Waals scaling factor to use when generating muon sites to avoid existing atoms. Smaller values will allow muons to get closer to the other ions."/>
            <param type="integer" argument="random_seed" label="Random Seed" optional="true" help="Seed used to randomise the positions of the muons in the generated structures."/>
            <param type="select" name="allpos_ext" value="none" label="Format for file containing all muon positions (optional)" help="If set, generates an extra output file containing all the muon positions using the specified file type.">
                <option value="none">Do not generate</option>
                <option value="cell">CELL</option>
                <option value="cif">CIF</option>
                <option value="xyz">XYZ</option>
            </param>
        </section>
        <section name="optimisation_params" expanded="true" title="Optimisation Parameters">
            <param type="integer" argument="geom_steps" value="30" min="0" label="Geometry optimization steps" help="Maximum number of geometry optimisation steps."/>
            <param type="float" argument="geom_force_tol" value="0.05" min="0.0" label="Geometry optimization tolerance" help="Tolerance on geometry optimisation in units of eV/Å."/>
            <param type="float" argument="uep_gw_factor" optional="true" value="5.0" min="0.0" label="Gaussian width factor" help="Gaussian width factor for UEP calculation. Higher values will make the potential of atomic nuclei closer to the point-like approximation but may introduce artifacts."/>
        </section>
        <param type="hidden" name="testing" label="Test mode" value="false"/>
    </inputs>
    <outputs>
        <data name="uep_results" format="zip" from_work_dir="out_zip.zip"/>
        <data label="Muon site positions on ${on_string}" name="allpos_file" auto_format="true">
            <filter>(generation_params["allpos_ext"] != "none")</filter>
        </data>
        <data label="File tree (testing only)" name="file_tree" format="txt" from_work_dir="tree.txt" hidden="true">
            <filter>(testing == "true")</filter>
        </data>
    </outputs>
    <tests>
        <!-- UEP with CELL -->
        <test expect_num_outputs="3">
            <param name="testing" value="true"/>
            <param name="structure" value="Si.cell" ftype="cell"/>
            <param name="charge_density" value="Si.den_fmt" ftype="den_fmt"/>
            <param name="castep_log" value="Si.castep" ftype="castep"/>
            <section name="generation_params">
                <param name="poisson_r" value="1.18"/>
                <param name="vdw_scale" value="0.25"/>
                <param name="random_seed" value="7357"/>
                <param name="allpos_ext" value="cell"/>
            </section>
            <section name="optimisation_params">
                <param name="geom_steps" value="300"/>
                <param name="uep_gw_factor" value="4.0"/>
            </section>
            <output name="allpos_file" file="allpos.cell"/>
            <output name="file_tree" file="tree.txt" ftype="txt" sort="true">
                <assert_contents>
                    <has_size value="3280"/>
                </assert_contents>
            </output>
        </test>
        <!-- UEP with XYZ -->
        <test expect_failure="true">
            <param name="testing" value="true"/>
            <param name="structure" value="Si.xyz" ftype="xyz"/>
            <param name="charge_density" value="Si.den_fmt" ftype="den_fmt"/>
            <param name="castep_log" value="Si.castep" ftype="castep"/>
            <section name="generation_params">
                <param name="poisson_r" value="1.18"/>
                <param name="vdw_scale" value="0.25"/>
                <param name="random_seed" value="7357"/>
            </section>
            <section name="optimisation_params">
                <param name="geom_steps" value="300"/>
                <param name="uep_gw_factor" value="4.0"/>
            </section>
            <assert_stderr>
                <has_text text="TypeError: cannot unpack non-iterable NoneType object"/>
            </assert_stderr>
        </test>
        <!-- UEP with extended XYZ -->
        <test expect_num_outputs="3">
            <param name="testing" value="true"/>
            <param name="structure" value="Si.extxyz" ftype="extxyz"/>
            <param name="charge_density" value="Si.den_fmt" ftype="den_fmt"/>
            <param name="castep_log" value="Si.castep" ftype="castep"/>
            <section name="generation_params">
                <param name="poisson_r" value="1.18"/>
                <param name="vdw_scale" value="0.25"/>
                <param name="random_seed" value="7357"/>
                <param name="allpos_ext" value="xyz"/>
            </section>
            <section name="optimisation_params">
                <param name="geom_steps" value="300"/>
                <param name="uep_gw_factor" value="4.0"/>
            </section>
            <output name="allpos_file" file="allpos.xyz"/>
            <output name="file_tree" file="tree.txt" ftype="txt" sort="true">
                <assert_contents>
                    <has_size value="3280"/>
                </assert_contents>
            </output>
        </test>
        <!-- UEP with CIF -->
        <test expect_num_outputs="3">
            <param name="testing" value="true"/>
            <param name="structure" value="Si.cif" ftype="cif"/>
            <param name="charge_density" value="Si.den_fmt" ftype="den_fmt"/>
            <param name="castep_log" value="Si.castep" ftype="castep"/>
            <section name="generation_params">
                <param name="poisson_r" value="1.18"/>
                <param name="vdw_scale" value="0.25"/>
                <param name="random_seed" value="7357"/>
                <param name="allpos_ext" value="cif"/>
            </section>
            <section name="optimisation_params">
                <param name="geom_steps" value="300"/>
                <param name="uep_gw_factor" value="4.0"/>
            </section>
            <output name="allpos_file" file="allpos.cif"/>
            <output name="file_tree" file="tree.txt" ftype="txt" sort="true">
                <assert_contents>
                    <has_size value="3280"/>
                </assert_contents>
            </output>
        </test>
        <!-- Expect failure for badly formatted den_fmt -->
        <test expect_failure="true">
            <param name="testing" value="true"/>
            <param name="structure" value="Si.cell" ftype="cell"/>
            <param name="castep_log" value="Si.castep" ftype="castep"/>
            <param name="charge_density" value="Sifail.den_fmt" ftype="den_fmt"/>
            <assert_stderr>
                <has_text text="Error:  FMT file has no header"/>
            </assert_stderr>
        </test>
        <!-- check that file_tree filter works -->
        <test expect_num_outputs="1">
            <param name="testing" value="false"/>
            <param name="structure" value="Si.cell" ftype="cell"/>
            <param name="charge_density" value="Si.den_fmt" ftype="den_fmt"/>
            <param name="castep_log" value="Si.castep" ftype="castep"/>
            <section name="generation_params">
                <param name="poisson_r" value="1.18"/>
                <param name="vdw_scale" value="0.25"/>
                <param name="random_seed" value="7357"/>
            </section>
            <section name="optimisation_params">
                <param name="geom_steps" value="300"/>
                <param name="uep_gw_factor" value="4.0"/>
            </section>
        </test>
        <!-- Check that the chden parameters are set correctly when $charge_density.name does not have the .den_fmt extension -->
        <test expect_num_outputs="2">
            <param name="testing" value="true"/>
            <param name="structure" value="Si.cell" ftype="cell"/>
            <param name="charge_density" value="Si_den_fmt" ftype="den_fmt"/>
            <param name="castep_log" value="Si.castep" ftype="castep"/>
            <section name="generation_params">
                <param name="poisson_r" value="1.18"/>
                <param name="vdw_scale" value="0.25"/>
                <param name="random_seed" value="7357"/>
            </section>
            <section name="optimisation_params">
                <param name="geom_steps" value="300"/>
                <param name="uep_gw_factor" value="4.0"/>
            </section>
            <output name="file_tree" file="tree.txt" ftype="txt" sort="true">
                <assert_contents>
                    <has_size value="3280"/>
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[
        Given an input structure, this tool generates a set of duplicate structures,
        each with a single muon added in a random location.
        These are known as "muonated" structures.
        Following this, UEP optimisation is used to refine the positions of the muons.

        This tool requires CASTEP inputs in order to perform the UEP method,
        meaning your initial DFT simulation must have been done with CASTEP.
        This simulation should have used the same structure as is used here.

        Following this, the individual refined positions can be clustered to
        represent potential stopping sites by using '`PyMuonSuite AIRSS Cluster`_'.

        Command-line usage (generation): pm-muairss [-h] -t w structures parameter_file
        
        Command-line usage (optimisation): pm-uep-opt [-h] parameter_file

        .. _PyMuonSuite AIRSS Cluster: /tool_runner?tool_id=pm_muairss_read

        PyMuonSuite is distributed under the GPLv3 license.
        This tool wrapper is distributed under the MIT license.
    ]]></help>
    <citations>
        <citation type="doi">@PYMUONSUITE_CITATION@</citation>
        <citation type="doi">10.1063/1.5024450</citation>
        <citation type="doi">10.1063/1.5085197</citation>
        <citation type="doi">10.1063/5.0012381</citation>
        <citation type="bibtex">
            @article {castep,
                author = {Clark, S. J. and Segall, M. D. and Pickard, C. J. and Hasnip, P. J. and Probert, M. I. J. and Refson, K. and Payne, M. C.},
                title = {First principles methods using CASTEP},
                journal = {Zeitschrift fuer Kristallographie},
                volume = {220},
                pages = {567},
                year = {2005}
            }
        </citation>
    </citations>
</tool>