pyro-kinetics / pyrokinetics

Python library to run and analyse gyrokinetics simulations
https://pyrokinetics.readthedocs.io/en/latest/#
GNU Lesser General Public License v3.0
25 stars 6 forks source link

Problems with GENE when only ExBrate is specified in external_contr #381

Closed venkiteshayyar closed 2 months ago

venkiteshayyar commented 3 months ago

@bpatel2107 We're facing an issue rendering the input parameter file with pyrokinetics. The data is for a GENE non-linear run

The parameter file has the content

 &external_contr
 ExBrate    =  -0.67461610

Hence, the dictionary gets only the value for 'exbrate' in Line 461 in gene.py

This causes a key not found error in line 494 for omega0_tor

Speaking to GENE experts, I gather that specifying just one of these parameters is often part of the workflow.

I tried a simple, hacky fix like this.

        for key in ['exbrate','omega0_tor','pfsrate']: 
            if key not in external_contr.keys():
                external_contr[key]=0.0

But it's causing further issues later, so I wonder if more changes are required.

bpatel2107 commented 3 months ago

That is roughly what should be done. We can use the .get method here which would be tidier.

We do something earlier in the code checking for external_contr and define defaults if it is not specified. What I suspect is happening here is that external_contr is in the input file but omega0_tor isn't. I can make a quick PR for this tomorrow morning (UK time).

venkiteshayyar commented 3 months ago

Thanks! The above fix seems to work and the code proceeds. Facing some issues rendering outputs, but that might be a different issue.

bpatel2107 commented 3 months ago

Fixed in #382, can you double check this works