Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt the IsothermAccurateWorkChain #111

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions aiida_lsmo/workchains/isotherm_accurate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import functools
import ruamel.yaml as yaml
import scipy.stats

from aiida.plugins import CalculationFactory, DataFactory, WorkflowFactory
from aiida.orm import Dict, Str, SinglefileData
Expand Down Expand Up @@ -540,8 +541,25 @@ def should_run_another_gcmc_highp(self):
self.ctx.pressure_old = self.ctx.pressure
self.ctx.pressure = self.ctx.pressure_old + min(self.ctx.dpmax, dp_computed)

if self.ctx.pressure > self.ctx.psat:
return False # Converged
if self.ctx.gcmc_loading_average > 0.5 * self.ctx.geom['Estimated_saturation_loading']:
# Compute slope of straight line
preg1 = list(self.ctx.raspa_gcmc[-3].outputs.output_parameters['framework_1']['components'].values())[0]['partial_pressure']/100000
preg2 = list(self.ctx.raspa_gcmc[-2].outputs.output_parameters['framework_1']['components'].values())[0]['partial_pressure']/100000
preg3 = list(self.ctx.raspa_gcmc[-1].outputs.output_parameters['framework_1']['components'].values())[0]['partial_pressure']/100000
conv1 = list(self.ctx.raspa_gcmc[-3].outputs.output_parameters['framework_1']['components'].values())[0]['conversion_factor_molec_uc_to_mol_kg']
conv2 = list(self.ctx.raspa_gcmc[-2].outputs.output_parameters['framework_1']['components'].values())[0]['conversion_factor_molec_uc_to_mol_kg']
conv3 = list(self.ctx.raspa_gcmc[-1].outputs.output_parameters['framework_1']['components'].values())[0]['conversion_factor_molec_uc_to_mol_kg']
load1 = list(self.ctx.raspa_gcmc[-3].outputs.output_parameters['framework_1']['components'].values())[0]['loading_absolute_average']
load2 = list(self.ctx.raspa_gcmc[-2].outputs.output_parameters['framework_1']['components'].values())[0]['loading_absolute_average']
load3 = list(self.ctx.raspa_gcmc[-1].outputs.output_parameters['framework_1']['components'].values())[0]['loading_absolute_average']

slope = scipy.stats.linregress([preg1, preg2, preg3], [conv1*load1, conv2*load2, conv3*load3])[0]
inter = scipy.stats.linregress([preg1, preg2, preg3], [conv1*load1, conv2*load2, conv3*load3])[1]

self.ctx.pressure = (self.ctx.geom['Estimated_saturation_loading'] - inter)/slope
self.ctx.gcmc_1 += 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be

Suggested change
self.ctx.gcmc_1 += 1
self.ctx.gcmc_i += 1

?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, it was a typo but it changes nothing !!
I am trying something now and will let you know if it works.
In the outline of the workchain, a new gcmc calculation is called only if the While loop returns True.
The fact that we have return False there then it converges and exits.
I switched it to True and added a dummy condition as False afterwards.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not working :(

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the gcmc at least running now?

Could you commit & push your changes?

self.ctx.gcmc_loading_average = self._get_last_loading_molkg()
return False # Converged

self.ctx.gcmc_i += 1
return True # Didn't converge yet
Expand Down