BSM model mg5 scripting for updating parameter changes

Asked by Saif Mustafa

I'm writing a bash script to automate all the commands in a program I run but automatically editing a .dat file with all the values for standard model Lagrangian parameters

But, I am essentially wanting to run multiple interactive sessions at once, rather than one by one which is what it's doing atm, but it also has to update a parameter before every new session is opened which it's doing fine, but one by one atm.

It's doing :

Update parameter

Open interactive session

Execute other commands

Finish

Open new session

... Repeat

Rather than:

Update parameter

Open interactive session

Execute other commands in that session and run in that directory ...

move into new directory whilst previous interactive session is running

Update parameter

Open 2nd interactive session of mg5

Execute other commands in that session and run in that directory .. etc

Attached is my code:

how can I fix this?

thanks.

--------------------------------------

#! /bin/bash

#Example loop for SMEFT cW EFT parameter values

mkdir "cW"
cd cW

 for i in -1.0 -0.75 -0.50 -0.25 1.00000e-99 0.25 0.50 0.75 1.0

do

 mkdir "parameter_modification_${i}"

cp /home/smustafa/SFNP/MG5_aMC_v2_7_2/models/restrict_SMlimit_massless.dat parameter_modification_${i}

find parameter_modification_${i}/restrict_SMlimit_massless.dat -type f -exec sed -i "s/21 1.000000e-99 # cW /21 $i # cW /g" {} \;

mv -f parameter_modification_${i}/restrict_SMlimit_massless.dat /home/smustafa/SFNP/MG5_aMC_v2_7_2/models/SMEFTsim_A_U35_MwScheme_UFO_v2_1/

rm -r parameter_modification_${i}

################################################# Run MG5

echo “Loading MG5 …”
~/SFNP/MG5_aMC_v2_7_2/bin/mg5_aMC << EOF
import model SMEFTsim_A_U35_MwScheme_UFO_v2_1-SMlimit_massless
generate p p > Z Z j j QCD==0
add process generate p p > Z Z j j QCD==2
output EWK_QCD_total_parameter_modification${i}
launch
shower = pythia8
0
set nevents 10
set ebeam1 7000
set ebeam2 7000
0
EOF

done

Question information

Language:
English Edit question
Status:
Expired
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#3

we do not have any API trick for parralel run of MG5.
But we offer simply way to run in serial:

import model SMEFTsim_A_U35_MwScheme_UFO_v2_1-SMlimit_massless
generate p p > Z Z j j QCD==0
add process generate p p > Z Z j j QCD==2
output EWK_QCD_total_parameter_modification${i}
launch
shower = pythia8
0
set nevents 10
set ebeam1 7000
set ebeam2 7000
set cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50, 0.75, 1.0]
0

Revision history for this message
Saif Mustafa (ucapmus) said :
#4

Hi, Olivier. Thank you for the prompt reply.

What does set cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50, 0.75, 1.0] do here? What do you mean by running in serial? I am making this script to run on a batch farm on a cluster but I am not familiar with how to update the parameter in the .dat file for every new run automatically.

cheers,

Saif.

Revision history for this message
Saif Mustafa (ucapmus) said :
#5

My intention is to create a do loop which updates the .dat file using a sed command and then overwrites this file in the model folder where the file is located, run mg5 and import this updated model file and repeat for the next. I would usually do this in multiple terminals where different mg5 can run, where I edit the .dat file whilst the previous is running and get a different run. I am needing to do this for many parameters so the loop is necessary and I do not want to run them sequentially. This can be done on multiple terminals like I said, but I am now needing to do this on a cluster so need to automate it :-)

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#6

and what kind of help do you expect/want from us?

Cheers,

Olivier

> On 18 Jul 2020, at 23:56, Saif Mustafa <email address hidden> wrote:
>
> Question #691950 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/691950
>
> Saif Mustafa posted a new comment:
> My intention is to create a do loop which updates the .dat file using a
> sed command and then overwrites this file in the model folder where the
> file is located, run mg5 and import this updated model file and repeat
> for the next. I would usually do this in multiple terminals where
> different mg5 can run, where I edit the .dat file whilst the previous is
> running and get a different run. I am needing to do this for many
> parameters so the loop is necessary and I do not want to run them
> sequentially. This can be done on multiple terminals like I said, but I
> am now needing to do this on a cluster so need to automate it :-)
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Saif Mustafa (ucapmus) said :
#7

Simply my above questions:

1. What does set cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50, 0.75, 1.0] do here - is it finding the appropriate parameter from the imported model e.g. cW in this case, and then producing multiple different output runs appropriately named with the value of cW used?

2. If they can indeed be run in parallel like I have done so on multiple terminals, would you have any suggestions on how to edit the bash script to simply automate the commands within mg5 in a loop, rather than sequentially?

cheers,

Saif :-)

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#8

> 1. What does set cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50,
> 0.75, 1.0]

This modifies the param_card and modifies the associate entry of "cw" to that list of values.
generating one events file for each of them (this is done in the same directory sequentially.

> 2. If they can indeed be run in parallel like I have done so on multiple
> terminals,

As long as they run in their own directory, I do not see problem.

> would you have any suggestions on how to edit the bash script
> to simply automate the commands within mg5 in a loop, rather than
> sequentially?

No

This being said, I do not like that you overwritte the file restrict_SMlimit_massless.dat
you should better want to create many
 restrict_SMlimit_$i.dat
this will be better for reproductibility.
Note that in this case it is likely useless to modify that file (but maybe if you set some value to exactly 0)
It would be better to modify the param_card.dat instead
(for which you can use the "set" command to edit the file.)

> On 19 Jul 2020, at 00:11, Saif Mustafa <email address hidden> wrote:
>
> Question #691950 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/691950
>
> Saif Mustafa posted a new comment:
> Simply my above questions:
>
> 1. What does set cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50,
> 0.75, 1.0] do here - is it finding the appropriate parameter from the
> imported model e.g. cW in this case, and then producing multiple
> different output runs appropriately named with the value of cW used?
>
> 2. If they can indeed be run in parallel like I have done so on multiple
> terminals, would you have any suggestions on how to edit the bash script
> to simply automate the commands within mg5 in a loop, rather than
> sequentially?
>
> cheers,
>
>
> Saif :-)
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Saif Mustafa (ucapmus) said :
#9

Thanks Olivier Mattelaer, that solved my question.

Revision history for this message
Saif Mustafa (ucapmus) said :
#10

Hi,

I am getting:

Not valid command: set cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50, 0.75, 1.0]. Did you mean "cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50, 0.75, 1.0]"

when I try what you suggested.

- I am importing the correct model.

Why is this?

Saif.

Revision history for this message
Saif Mustafa (ucapmus) said :
#11

And also tried the recommended: "cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50, 0.75, 1.0]"

which gave me: Not valid command: cW scan:[-1.0, -0.75, -0.50, -0.25, 0, 0.25, 0.50, 0.75, 1.0]

thank you,

Saif

Revision history for this message
Launchpad Janitor (janitor) said :
#12

This question was expired because it remained in the 'Open' state without activity for the last 15 days.