Skip to content

Commit

Permalink
Update from tsikes/Frhodo (#3)
Browse files Browse the repository at this point in the history
* Soln2ck Fix

Fixed bug in writing thermo if no note exists (like writing from a 'gri30.cti')

* Heat Release Rate

Added heat release rate as both an observable and in the sim explorer

* Example Directory Changed and FirstTimeUse.docx made.

* Update FirstTimeUse.docx

* removing opt mech files

* Update fit_fcn.py

Replace all for following:
change calculate_residuals  to calculate_objective_function
change calc_resid_output to calc_objective_function_output

* Update fit_fcn.py

* Update fit_fcn.py

changing variable names in fit_fcn and separating the bayesian case into an if statement.

* Update fit_fcn.py

* Update fit_fcn.py

* Update fit_fcn.py

Making single return for verbose versus normal case.

* Made CheKiPEUQ_from_Frhodo  helper module and also put code into fit_fcn

Right now, these codes are not working. It is just the beginning.

* Update fit_fcn.py

* Create ExampleConfig.ini

* add comments to fit_fcn.py about what is fed in by "args_list"

* Update fit_fcn.py

* renaming obs to obs_sim in fit_fcn

* Update fit_fcn.py

* get_varying_rate_vals_and_bnds

* get_varying_rate_vals_and_bnds

* pars_uncertainty_distribution code

* newOptimization field for creating PE_object.

* Added "Force Bayesian"

* minor changes

* Update CheKiPEUQ_from_Frhodo.py

* Update CheKiPEUQ_from_Frhodo.py

* Adjusting observed_data and responses shapes for CheKiPEUQ

* got the weightings multiplication to work after transposing and transposing back

* typo correction

* update get_last_obs_sim_interp

* moved CheKiPEUQ_PE_object creation into time_adjust_func

* Update fit_fcn.py

* working on get_log_posterior_density and getting varying_rate_vals

* Update fit_fcn.py

* forcing 'final' after minimization to be 'residual'

* switch to negative log P for objective_function_value

* Trying to allow Bayesian way to get past the "QQ" error by feeding residual metrics.

* trying 10**neg_logP in lieu of loss_scalar.

* Setting forceBayesian

* adding Bayesian_dict to make code easier to follow

* Separating Bayesian into 5 steps to simplify things for Travis

* Update fit_fcn.py

* Update CheKiPEUQ_integration_notes.txt

* Update fit_fcn.py

* Update CheKiPEUQ_integration_notes.txt

* Create CiteSoftLocal.py

* Update CiteSoft call for CheKiPEUQ

* Disabling CiteSoft exportations for now

* Update CheKiPEUQ_integration_notes.txt

* Variable name changes (#2)

* Variable name changes

Moved image assets and added a GUI screenshot
Replace all for following:
change calculate_residuals  to calculate_objective_function
change calc_resid_output to calc_objective_function_output
changing variable names in fit_fcn and separating the bayesian case into an if statement.
Making single return for verbose versus normal case.

Co-authored-by: Aditya Savara <39929571+AdityaSavara@users.noreply.github.com>

* CheKiPEUQ_integration

Merging from Ashi's branch
Modified GUI to include variables needed for Bayesian optimization

* Merge CheKiPEUQ local (#5)

changing variable names in fit_fcn and separating the bayesian case into an if statement.
Making single return for verbose versus normal case.
Made CheKiPEUQ_from_Frhodo  helper module and also put code into fit_fcn
 - Right now, these codes are not working. It is just the beginning.
Create ExampleConfig.ini
add comments to fit_fcn.py about what is fed in by "args_list"
renaming obs to obs_sim in fit_fcn

* Update fit_fcn.py

* get_varying_rate_vals_and_bnds

* get_varying_rate_vals_and_bnds

* pars_uncertainty_distribution code

* newOptimization field for creating PE_object.

* Added "Force Bayesian"

* minor changes

* Update CheKiPEUQ_from_Frhodo.py

* Update CheKiPEUQ_from_Frhodo.py

* Adjusting observed_data and responses shapes for CheKiPEUQ

* got the weightings multiplication to work after transposing and transposing back

* typo correction

* update get_last_obs_sim_interp

* moved CheKiPEUQ_PE_object creation into time_adjust_func

* Update fit_fcn.py

* working on get_log_posterior_density and getting varying_rate_vals

* Update fit_fcn.py

* forcing 'final' after minimization to be 'residual'

* switch to negative log P for objective_function_value

* Trying to allow Bayesian way to get past the "QQ" error by feeding residual metrics.

* trying 10**neg_logP in lieu of loss_scalar.

* adding Bayesian_dict to make code easier to follow

* Separating Bayesian into 5 steps to simplify things for Travis

* Update fit_fcn.py

* Update CheKiPEUQ_integration_notes.txt

* Update fit_fcn.py

* Update CheKiPEUQ_integration_notes.txt

* Create CiteSoftLocal.py

* Update CiteSoft call for CheKiPEUQ

* Disabling CiteSoft exportations for now

* Update CheKiPEUQ_integration_notes.txt

* adding CheKiPEUQ local

* CheKiPEUQ_local

* removing things not needed from CheKiPEUQ

* try moving CheKiPEUQ_local

* parmaeter_estimation class still not being found for CheKiPEUQ_local

Specifically from inside CheKiPEUQ_from_Frhodo.py

* Update CheKiPEUQ_from_Frhodo.py

* Trying to use only CheKiPEUQ_local

* Merge Fix

Co-authored-by: Aditya Savara <39929571+AdityaSavara@users.noreply.github.com>

* Another Merge Fix

* Forced Bayesian Removed

Distribution type and how many sigma the unc represents is now reachable in var

* update comment in fit_fcn.py

* manually updating fit_fcn.py from Travis's CheKiPEUQ_integration branch

Github was not allowing the merge properly, so doing this change manually before merging.

* Update CheKiPEUQ_from_Frhodo from the CheKiPEUQ_Integration branch

* GUI Update

Bayesian tab now hidden when residuals are checked.
Uncertainty/Weights table shows depending upon selection of Residual/Bayesian

* Bayesian Changes

Changes to Optimization tab GUI
Reverting some changes in fit_fcn now that CheKiPEUQ will be called after simulations.
Prior naming was more correct

* Created CheKiPEUQ Dictionary

* Minor Changes

* Update fit_fcn.py

* Update fit_fcn.py

* creating get_last_obs_sim_interp and also working on Bayesian_dict

* Update fit_fcn.py

* Update fit_fcn.py

* Adding in more Bayesian_dict arguments. (#6)

* Update README.rst

Moved image assets and added a GUI screenshot

* Update README.rst

* Moved to Assets Branch

* Update fit_fcn.py

Replace all for following:
change calculate_residuals  to calculate_objective_function
change calc_resid_output to calc_objective_function_output

* Update fit_fcn.py

* Update fit_fcn.py

changing variable names in fit_fcn and separating the bayesian case into an if statement.

* Update fit_fcn.py

* Update fit_fcn.py

* Update fit_fcn.py

Making single return for verbose versus normal case.

* Made CheKiPEUQ_from_Frhodo  helper module and also put code into fit_fcn

Right now, these codes are not working. It is just the beginning.

* Update fit_fcn.py

* Create ExampleConfig.ini

* add comments to fit_fcn.py about what is fed in by "args_list"

* Update fit_fcn.py

* renaming obs to obs_sim in fit_fcn

* Update fit_fcn.py

* get_varying_rate_vals_and_bnds

* get_varying_rate_vals_and_bnds

* pars_uncertainty_distribution code

* newOptimization field for creating PE_object.

* Added "Force Bayesian"

* minor changes

* Update CheKiPEUQ_from_Frhodo.py

* Update CheKiPEUQ_from_Frhodo.py

* Adjusting observed_data and responses shapes for CheKiPEUQ

* got the weightings multiplication to work after transposing and transposing back

* typo correction

* update get_last_obs_sim_interp

* moved CheKiPEUQ_PE_object creation into time_adjust_func

* Update fit_fcn.py

* working on get_log_posterior_density and getting varying_rate_vals

* Update fit_fcn.py

* forcing 'final' after minimization to be 'residual'

* switch to negative log P for objective_function_value

* Trying to allow Bayesian way to get past the "QQ" error by feeding residual metrics.

* trying 10**neg_logP in lieu of loss_scalar.

* adding Bayesian_dict to make code easier to follow

* Separating Bayesian into 5 steps to simplify things for Travis

* Update fit_fcn.py

* Update CheKiPEUQ_integration_notes.txt

* Update fit_fcn.py

* Update CheKiPEUQ_integration_notes.txt

* Create CiteSoftLocal.py

* Update CiteSoft call for CheKiPEUQ

* Disabling CiteSoft exportations for now

* Update CheKiPEUQ_integration_notes.txt

* update comment in fit_fcn.py

* manually updating fit_fcn.py from Travis's CheKiPEUQ_integration branch

Github was not allowing the merge properly, so doing this change manually before merging.

* Update CheKiPEUQ_from_Frhodo from the CheKiPEUQ_Integration branch

* Update fit_fcn.py

* Update fit_fcn.py

* creating get_last_obs_sim_interp and also working on Bayesian_dict

* Update fit_fcn.py

* Update fit_fcn.py

Co-authored-by: Travis Sikes <50559900+tsikes@users.noreply.github.com>

* Update fit_fcn.py

* Save coefficient x0 and bnds in optimization

Also added Automatic as an option for uncertainty distribution

* Added a couple of missed values

* Update fit_fcn.py

Manually making them match

* making get_consolidated_parameters_arrays

* Bayesian_dict parsing of initial guesses and bounds added

* for params, deepcopy was needed, and added print lines.

* Adding new opt settings

Also spent a long time fixing the scientific spinbox

* Hall of Fame Added

* Che ki peuq integration v3 (#7)

* making get_consolidated_parameters_arrays

* Bayesian_dict parsing of initial guesses and bounds added

* for params, deepcopy was needed, and added print lines.

Co-authored-by: Travis Sikes <50559900+tsikes@users.noreply.github.com>

* Fixed bounds provided to CheKiPEUQ

* CheKiPEUQ Fixes

* Fixing the ligical error for lower bound.

I fixed the logical error, but line 212 is now printing this:
line 212 [True, True, True] [0, 2.4424906541753446e-16, -1.7976931348623155e+288] -1.7976931348623155e+288

That means that the comparison is not working correctly for min_neg_system value. In the next commit, I'm going to use the 1E99 way of doing things.

* Changed to -1E99 and +1E99 check

SOMEWHAT SURPRISINGLY, THE COMPARISON IS STILL FAILING. -1E288 > -1E99 is returning True.

* fixing comparisons: There was actually an "abs" I had not noticed.

* extra space deleted

* Cleaning up

Boxes in uncertainty function now functional

Also have further modified scientificspinbox

* cleanup & working towards inclusion of pars_bnds_exist

* rate_constants_parameters_bnds seem to be parsed and passed correctly to CheKiPEUQ

* Adding in unbounded_indices and return_unbounded_indices code

* minor syntax fixes

* Added remove_unbounded_values calls to code to truncate arrays etc.

* Moved more of the Bayesian_Dict fields population to init

* Cleaning up print statements

* Fixing rate_constants_parameters_bnds_exist for multiple rate constants

* Update CheKiPEUQ_integration_notes.txt

* Che ki peuq integration v3 (#8)

* making get_consolidated_parameters_arrays

* Bayesian_dict parsing of initial guesses and bounds added

* for params, deepcopy was needed, and added print lines.

* Fixing the ligical error for lower bound.

I fixed the logical error, but line 212 is now printing this:
line 212 [True, True, True] [0, 2.4424906541753446e-16, -1.7976931348623155e+288] -1.7976931348623155e+288

That means that the comparison is not working correctly for min_neg_system value. In the next commit, I'm going to use the 1E99 way of doing things.

* Changed to -1E99 and +1E99 check

SOMEWHAT SURPRISINGLY, THE COMPARISON IS STILL FAILING. -1E288 > -1E99 is returning True.

* fixing comparisons: There was actually an "abs" I had not noticed.

* extra space deleted

* cleanup & working towards inclusion of pars_bnds_exist

* rate_constants_parameters_bnds seem to be parsed and passed correctly to CheKiPEUQ

* Adding in unbounded_indices and return_unbounded_indices code

* minor syntax fixes

* Added remove_unbounded_values calls to code to truncate arrays etc.

* Moved more of the Bayesian_Dict fields population to init

* Cleaning up print statements

* Fixing rate_constants_parameters_bnds_exist for multiple rate constants

* Update CheKiPEUQ_integration_notes.txt

Co-authored-by: Travis Sikes <50559900+tsikes@users.noreply.github.com>

* Residual Optimization Update

Needed to account for exp residuals not having a zero average
Changed to using medians instead of means

* More Loss Function Changes

* Oops

* Bayesian Obj Func Change

Changed from -1*posterior to -1/posterior

* Bounds Error Fix

* Update

Update default config parameters and fix bayesian obj_fcn back to -1*

* Trying new fonts for log

* ChekiPEUQ: First attempt to implement variance per response for too long

* Linear scaling working now, but some 'iterations' of Frhodo are freezing during CheKiPEUQ's PE_object init.

I am trying to track down the reason. It is somewhere in the responses_observed_uncertainties manipulation during CheKiPEUQ's init.

* Reduced the slowdown to the extent of not freezing

I found that the slowdown was (surprisingly) caused in the loop that tried to convert non-zero weightings into tiny finite weightings.  Changing the code to use machine epsilon in one of the steps rather than minValue/1E6 made that loop faster (completely sure why).

The shape of the weightings looks odd. In the next commit I will try to print out some array shapes.

* Printing shows that the weighting array shape going into CheKiPEUQ is correct.

* Fixed shape of weighting arrray passed to CheKiPEUQ

Now need to do cleanup of print statements in next commit.

* Removing excess print statements and cleaning up.

* Improving heuristic slightly

* Updating version number and fixing minor error from the recent edits.

* Added automatic copy rates to optimize

* Cleaning up the merge conflict that was dropped

Removing some print statements and adding a .flatten() that is needed when analyzing multiple experiments.

* Remoing print statement from CheKiPUEQ_local

* Weights Work

* Style Changes

* Silly Math Error

* CheKiPEUQ changes

CheKiPEUQ was checking bounds after they had already been enforced. Differing ways of checking bounds was causing CheKiPEUQ to throw -inf. CheKiPEUQ no longer checks bounds

CheKiPEUQ obj_obj function no longer shows raw -1*log_posterior_density, but is instead the relative change from the initial guess. This should not alter convergence or how it runs, but it does make it easier to see how the value is changing.

* Minor fixes

* Update fit_fcn.py

* Nomenclature Change

* Refactoring

Refactoring to clean up fit_fcn
Also changing imports slightly

* Preliminary Signal Plot Changes

* Weight Function Update

Further abstracting weight function for uncertainty implementation
Renamed CheKiPEUQ interface class

* Implemented Uncertainty in Observable Data

Implemented GUI elements and linked to CheKiPEUQ.
Uncertainty is %.
Need to handle uncertainties better in opt. Log bayesian is broken

* Bayesian Opt Uncertainty Working

Bayesian uncertainty now functioning for log scale

* Added Shaded Unc

Shading has a gradient, will likely remove for speed

* Uncertainty Shading

I prefer this version. It's quicker without much loss.
Need to consider adding absolute uncertainties

* Added Abs Uncertainty

* Modifications to absolute uncertainty

Added uncertainty type choice to saved variables
Refactored OoM to convert_units

* Axes update in draggable

x and y axes now are animated objects that update with draggable

* GUI falloff/pressure dependent uncertainty

* Implementing rate coef/bnds on Plogs and falloff eqns

* Troe Optimization

Backend mech structures created

Arrhenius optimization functioning again

Bug fix and mech.reset work

Fixed mechanism double loading from setting use_thermo_file_box programmatically
mech.reset now includes Plog and Falloff properly.

More back end work on falloff/plogs

Backend mech work

Changing arrhenius coeffs/coef_bnds to be an item in a list to better match plog and falloff rates

Arrhenius Optimization working again

Arrhenius working
Work to be done with Falloff

Troe kind of working

Troe kinda works

Troe kinda works but it's very slow to fit the coefficients.
I'm going to switch to SRI and hope for a faster convergence time to fitting the coefficients

Working on SRI Fit

Working on falloff

Need to change mech to SRI
Need to save mech as yaml for reverting back to later

Working on Falloff Fits

SRI fitting progress

SRI fitting

More SRI Fitting

Working on nlopt SRI

Working on SRI

More SRI fun

SRI - not much progress

New SRI fit

Fitting a,b then all

Not going well

Update base_plot.py

Update base_plot.py

SRI progress

Troe Optimization and Full Update

Updated Environment and bugs popped up

Quick fixes to address those

Squashed commit of the following:

commit 7c78008
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Jan 17 14:51:38 2022 -0600

    Update main.py

commit 9aee564
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Nov 8 13:02:15 2021 -0600

    Version check bug fix

commit 703d225
Merge: 0634337 7b12b8e
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Nov 8 12:55:21 2021 -0600

    Merge branch 'Troe_opt' of https://github.com/tsikes/Frhodo into Troe_opt

commit 0634337
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Nov 8 12:55:18 2021 -0600

    Moving Loss Partition Function TCK

commit 7b12b8e
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Nov 8 11:47:03 2021 -0600

    Working on Bug Fix

    New bug with RBFopt when using as executable. Working on fixing. (command window is flashing each iteration)

commit 681051d
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Nov 4 16:20:59 2021 -0500

    Bug Fix

    Fixed CheKiPEUQ interface issues

commit 5664592
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Nov 4 11:01:42 2021 -0500

    Bug Fix

    Fixed bugs with secondary y axis in sim explorer.

commit 7821587
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Nov 3 19:46:04 2021 -0500

    Update fit_fcn.py

commit f9d11e8
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Nov 3 18:09:27 2021 -0500

    Optimization Bug Fixing

    Fixed setting rate parametrization constant uncertainties to zero for residual based method.

commit 7bd4d64
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Nov 2 15:52:28 2021 -0500

    Minor changes

    Consolidated bisymlog scaling factor
    Added new % abs density gradient to options

commit cf6328b
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Nov 1 16:22:59 2021 -0500

    Bug Fixing

    Fixing bugs in explorer widget/base plot with limit setting and widget type not defined

commit 15b2acb
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Oct 4 21:56:17 2021 -0500

    Minor Update

    Fixed Torr
    added bisymlog to opt type
    Fixed plot error where left limit == right limit

commit 943ad8e
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Sep 23 16:36:40 2021 -0500

    Update for New Tranter Exp Format

    New format does not have tOpt/PT spacing but instead gives velocity

commit 0eb48ce
Author: Travis Sikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Sep 19 22:55:06 2021 -0500

    Opt Update

    Moved bisymlog out of multiple locations into convert_units
    Changed calculate residuals log to bisymlog

commit 5268062
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Sep 16 15:35:24 2021 -0500

    Changed Fit Function

    Changed fit function to mean instead of median
    Changed so that Bayesian doesn't include penalty function at end. Need to check

commit 3df584d
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Aug 31 22:15:05 2021 -0500

    Update fit_fcn.py

commit a507f93
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Aug 31 19:30:38 2021 -0500

    Changed adaptive loss function

    Adaptive loss function now optimizes inside of rate optimization loop. It's much more efficient. It also means each individual experiment has it's own loss alpha

commit bc66027
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Aug 31 16:58:18 2021 -0500

    Fixed usage of C in loss function/GUI

commit 42d82ff
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 29 18:26:13 2021 -0500

    Modified loss function

    Removed prior scaling from loss function to bring it back to publication formula

commit d0d43dc
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 29 16:57:00 2021 -0500

    Tinkering with generalized loss func

commit 4702ef3
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 29 15:51:28 2021 -0500

    Changed to adaptive loss function

    The shape value is now broken into an optimized parameter for inside experiments and between experiments

commit 60e782f
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Aug 23 23:54:22 2021 -0500

    Update loss_integral.py

commit d093dda
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Aug 23 22:45:04 2021 -0500

    loss integral fitting

commit 774f70d
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Aug 23 17:41:35 2021 -0500

    loss function changes

commit cba7b9e
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Aug 23 13:30:17 2021 -0500

    Experiment import update

    Updated experimental conditions import to work for old Tranter style experiment files

commit 016ea7c
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Fri Aug 20 16:31:40 2021 -0500

    Create fit_coeffs_pygmo.py

commit b95d5a6
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Fri Aug 20 16:29:08 2021 -0500

    Rollback

    Rolling back to working CRS2 Troe opt

commit 3c577e9
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Aug 19 14:59:26 2021 -0500

    Testing Troe Opt

commit 553887b
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Aug 19 01:36:54 2021 -0500

    Update fit_coeffs.py

commit cbfaa20
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Aug 18 16:28:28 2021 -0500

    Working on implementing Augmented Lagrangian

commit 520f822
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Aug 18 12:44:48 2021 -0500

    Small changes

    bonmin path wasn't working with network path as string
    reduced min_T_range
    changing Troe eqn to be continuous for all Fcent values and other cases

commit ab97a6d
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Aug 16 22:52:25 2021 -0500

    Moving ipopt and bonmin

commit 3accc3b
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Aug 16 22:41:46 2021 -0500

    Including bonmin and ipopt for rbfopt

commit 3289e0d
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Aug 16 21:12:21 2021 -0500

    Working on Pygmo and RBFOpt

commit dc91f30
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 15 21:55:11 2021 -0500

    Troe updates

    Implemented genetic algorithms into GUI
    Sped GA's up through Numba
    Sped GA's up by only using DIRECT_L instead of CRS2. This is less accurate but much faster

commit 91cbd0f
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 15 01:08:16 2021 -0500

    Implementing genetic algorithms

commit 30ad17b
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Aug 12 08:56:46 2021 -0500

    Minimally working Troe

commit 82ee3a1
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 8 23:57:46 2021 -0500

    Update fit_coeffs.py

    Minor bug catch

commit 0d89b68
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 8 23:26:30 2021 -0500

    Maybe working?

commit 5e69b69
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 8 21:44:16 2021 -0500

    Update fit_coeffs.py

    Almost ready to test, but switching to optimizing arrhenius parameters instead of lpl, hpl rates

commit c3a5098
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Fri Aug 6 09:54:08 2021 -0500

    Tinkering with ranges and bounds

commit 44d7ddb
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Aug 3 14:55:30 2021 -0500

    Troe opt changes

    Troe opt changes.
    fixed bug from updating dependencies

commit 3735e38
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Aug 1 20:44:04 2021 -0500

    Redoing Troe Fit

    Redoing fit.

    Need to do more work on constraints of fitting LPL, HPL, Fcent

commit 6407058
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Jul 29 10:20:16 2021 -0500

    Troe Fitting - Nonfunctional

    Redoing Troe Fitting to be similar to PLOG -> Troe.

commit d5731fc
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Jul 6 15:28:43 2021 -0500

    Resample Nonuniform Data

    Resamples nonuniform data for uncertainty shading smoothing

commit 4e113be
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Jul 5 18:52:25 2021 -0500

    Update options_panel_widgets.py

    Enable/Disable wavelet levels input box accordingly

commit cf67025
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Jul 5 18:42:40 2021 -0500

    Implemented unc shading over data

commit 2fa0858
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Fri Jul 2 13:59:59 2021 -0500

    Minor update

    Added error checking for 0D reactors to prevent crashing

commit 5abded1
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Jun 30 20:25:17 2021 -0500

    Bug Fix

    Fixed some convergence issues related to outlier determination

commit 9e268a8
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Jun 29 21:29:42 2021 -0500

    Working Troe Optimization

    Refactored Troe fitting into more legible classes.
    Enabled multiprocessing
    Beginning Testing

commit 951efd3
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sat Jun 26 23:03:43 2021 -0500

    Working

    Basic optimization is working

commit e672ca0
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sat Jun 26 00:12:41 2021 -0500

    Sort of working

    Have nlopt working for fcent

commit 2dbb375
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Jun 24 17:19:18 2021 -0500

    Update fit_coeffs.py

    Added constraints, but not fitting well with nlopt

commit d930224
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Jun 24 10:33:31 2021 -0500

    Semi working

    Troe is working, but need to implement constraints on Fcent fitting.

    Should be working for Plog -> Troe after implementing those constraints

commit afdcdbc
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Jun 22 15:26:13 2021 -0500

    Reproducing Troe Ok

commit 9d08052
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Jun 21 22:49:49 2021 -0500

    Update fit_coeffs.py

commit 50265c6
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Jun 21 14:27:55 2021 -0500

    Tinkering

commit ee6501e
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Jun 20 21:05:57 2021 -0500

    New Plog Fit Method

commit 3f5619e
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Jun 17 13:39:16 2021 -0500

    Nothing works

commit 568ea11
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Jun 8 17:27:22 2021 -0500

    PLOG working?

commit e9d957f
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon May 3 22:26:22 2021 -0500

    Works for PLOG but badly fitting

commit 9fb5d64
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon May 3 22:06:08 2021 -0500

    PLOG Residual Working

commit 292d68f
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Apr 11 22:13:03 2021 -0500

    Troe Progress

commit 6867bf6
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Apr 7 18:22:37 2021 -0500

    Update fit_coeffs.py

commit 36b155d
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Apr 7 15:07:54 2021 -0500

    More Progress

commit e5dec8f
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Apr 6 22:12:52 2021 -0500

    Making Progress

commit 0c50520
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Apr 6 15:01:09 2021 -0500

    Tinkering

commit 47bc21d
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Apr 5 18:34:20 2021 -0500

    Working

commit add6d9d
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Apr 5 13:48:45 2021 -0500

    Big Changes

    Refactored calculation-type functions
    Set mechanism now generates mechanism programmatically rather than from yaml text in memory. This is necessary to be able to switch reaction types

commit 70cab31
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Mar 31 16:56:05 2021 -0500

    set_mechanism changes

    Working on changing reaction types. Side benefit will be faster initialization during optimization

commit f6822d9
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Mar 31 13:34:46 2021 -0500

    Update misc_fcns.py

commit cef069b
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Mar 29 14:49:16 2021 -0500

    Update shock_fcns.py

commit b3e91ea
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Mar 29 00:00:18 2021 -0500

    Update shock_fcns.py

commit b8744a1
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Mar 28 23:43:34 2021 -0500

    Update shock_fcns.py

    Updated shock solver to match paper

commit 198eabf
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Mon Mar 22 00:03:21 2021 -0500

    Troe Falloff functional

    Fitting the falloff parameters is working. Need to think more about initial parameters and see if I can fit LPL and HPL at the same time(this makes PLOGS work)

commit 31fb75f
Author: TSikes <50559900+tsikes@users.noreply.github.com>
Date:   Thu Mar 11 16:29:19 2021 -0600

    Bug Fixes

commit 9bbdb06
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Mar 10 23:24:09 2021 -0600

    Update mech_fcns.py

    Accidentally removed sleep for mech changing. This must remain until incident shock reactor is rewritten

commit 4a6efa5
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Mar 10 23:16:01 2021 -0600

    Update mech_optimize.py

    Automatically set minimum time between plots when optimizing

commit c177ed6
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Wed Mar 10 22:46:13 2021 -0600

    Plotting Improved

    Set plots to only draw if they are being shown
    Set minimum time since last draw for optimization
    End result: Much faster plotting and program does not appear to hang like before

commit 397457d
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Tue Mar 9 00:16:23 2021 -0600

    Calculated Troe Derivatives

commit 43a47e9
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sat Mar 6 13:47:07 2021 -0600

    Bug Fixes

commit f0899df
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Feb 28 20:27:18 2021 -0600

    Fixed Branch Errors

commit 687737f
Author: tsikes <50559900+tsikes@users.noreply.github.com>
Date:   Sun Feb 28 18:28:40 2021 -0600

    Troe Tinkering

Co-authored-by: Aditya Savara <39929571+AdityaSavara@users.noreply.github.com>
  • Loading branch information
tsikes and AdityaSavara authored Jan 17, 2022
1 parent c868eab commit c54f4c1
Show file tree
Hide file tree
Showing 83 changed files with 561,034 additions and 2,781 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ Development/Old Versions
Development/Documentation
Development/Extras
Paths/
.vs/
#*.7z
#*.ini
#*.log
*.sln
.vs/Frhodo_dev/v16/.suo

*.pyproj
*.user
5 changes: 5 additions & 0 deletions Development/Ideas.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
***** clicking arrows on shock increments by 2 sometimes
***** see Engines
***** Address mplcairo for non windows systems
***** see Recast Reaction Rate Eqns
***** bug: Sim Explorer: if old mech species > new mech species/rxn, loading can cause outside vector range
**** bug: changing x axis to reverse reaction rate and selecting reaction causes crash
*** chemked for thermo coordinates, mechanism name, name, source date, source name, comments, chemkin or cantera?

***** fix loading mech with unknown species (mix table doesn't update and plot doesn't show legend)
**** bug: loading Z:\BilBo Models\cycloheptane\2018\Mechanisms as experiment file
Expand All @@ -23,6 +25,9 @@
Engines:
***** sensitivity analysis (Vyaas)
***** for slow simulations: update plot as calculation is performed or somehow update user
**** Use pygmo for more global optimization methods?
**** Use sci-kit optimize for bayesian optimization?
**** Be able to constrain total rate and branching ratios. Schlieren gives total unc, theory gives branching ratio unc
** pytorch for ode solver?
** consider diffeqpy (juliadiffeq) to solve ODE. Should be faster and has more options
** julia alternative: Implement cvode (sundials) for scipy or from cantera: https://pypi.org/project/scikits.odes/
Expand Down
157 changes: 157 additions & 0 deletions Development/Random Testing/loss func integral/loss_integral.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# This file is part of Frhodo. Copyright © 2020, UChicago Argonne, LLC
# and licensed under BSD-3-Clause. See License.txt in the top-level
# directory for license and copyright information.

import pygmo
import numpy as np
from scipy import interpolate, integrate, optimize # used to integrate weights numerically
from scipy.interpolate import CubicSpline
import matplotlib.pyplot as plt
import multiprocessing as mp

min_pos_system_value = (np.finfo(float).tiny*(1E20))**(1/2)
max_pos_system_value = (np.finfo(float).max*(1E-20))**(1/2)

def generalized_loss_fcn(x, mu=0, a=2, c=1): # defaults to L2 loss
x_c_2 = ((x-mu)/c)**2

if a == 1: # generalized function reproduces
loss = (x_c_2 + 1)**(0.5) - 1
if a == 2:
loss = 0.5*x_c_2
elif a == 0:
loss = np.log(0.5*x_c_2+1)
elif a == -2: # generalized function reproduces
loss = 2*x_c_2/(x_c_2 + 4)
elif a <= -1000: # supposed to be negative infinity
loss = 1 - np.exp(-0.5*x_c_2)
else:
loss = np.abs(a-2)/a*((x_c_2/np.abs(a-2) + 1)**(a/2) - 1)

return loss*c**a + mu # multiplying by c^2 is not necessary, but makes order appropriate

def sig(x): # Numerically stable sigmoid function
eval = np.empty_like(x)
pos_val_f = np.exp(-x[x >= 0])
eval[x >= 0] = 1/(1 + pos_val_f)
neg_val_f = np.exp(x[x < 0])
eval[x < 0] = neg_val_f/(1 + neg_val_f)

# clip so they can be multiplied
eval[eval > 0] = np.clip(eval[eval > 0], min_pos_system_value, max_pos_system_value)
eval[eval < 0] = np.clip(eval[eval < 0], -max_pos_system_value, -min_pos_system_value)

return eval

def sig_deriv(sig_val):
return sig_val*(1-sig_val)

def eval_coef(tau, a):
return a[0] + a[1]*np.exp(a[2]*tau)

def Z_fun(tau, alpha, *vars):
x = np.log(-alpha + 2 + 1/1001)

L_x0 = eval_coef(tau, vars[0:3])
k = eval_coef(tau, vars[3:6])
A1 = [eval_coef(tau, vars[6:9]), eval_coef(tau, vars[9:12])]
A2 = [eval_coef(tau, vars[12:15]), eval_coef(tau, vars[15:18])]
p = [eval_coef(tau, vars[18:21]), eval_coef(tau, vars[21:24]), eval_coef(tau, vars[24:27])]
x0 = [eval_coef(tau, vars[27:30]), eval_coef(tau, vars[30:33]), eval_coef(tau, vars[33:36]),
eval_coef(tau, vars[36:39]), eval_coef(tau, vars[39:42])]
h = [eval_coef(tau, vars[42:45]), eval_coef(tau, vars[45:48]), eval_coef(tau, vars[48:51]),
eval_coef(tau, vars[51:54]), eval_coef(tau, vars[54:57])]

p = [p[0], 1-p[0], p[1], p[2], 1-p[1]-p[2]]

L = sig((x - L_x0)/k)
f_1 = A1[0]+(A2[0]-A1[0])*(p[0]/(1+10**((x0[0]-x)*h[0])) + p[1]/(1+10**((x0[1]-x)*h[1]))+ p[2]/(1+10**((x0[2]-x)*h[2])))
f_2 = A1[1]+(A2[1]-A1[1])*(p[3]/(1+10**((x0[3]-x)*h[3])) + p[4]/(1+10**((x0[4]-x)*h[4])))

return np.exp(L*f_2 + (1-L)*f_1)

class pygmo_objective_fcn:
def __init__(self, bnds, tau, alpha, Z):
self.bnds = bnds
self.tau = np.unique(tau)
self.alpha = np.unique(alpha)
self.Z = Z
self.ln_Z = np.log(Z)

def fitness(self, x):
obj = 0
for i in range(len(self.tau)):
# print(self.tau[i], self.alpha[i], Z_fun(self.tau[i], self.alpha[i], *x))
try:
Z_fit = Z_fun(self.tau[i], self.alpha[i], *x)
if np.isnumeric(Z_fit):
obj += 100*(np.log(Z_fit) - self.ln_Z[i])**2
print(obj)
else:
obj += 1
except:
obj += 1

return [obj]

def get_bounds(self):
return self.bnds

def gradient(self, x):
return pygmo.estimate_gradient_h(lambda x: self.fitness(x), x)


'''
alpha_vec = np.linspace(-1000, -10, 991)
alpha_vec = np.concatenate([alpha_vec, np.linspace(-10, 2, 1201)[1:]])
tau = 250
res = []
c = 1
for tau in np.linspace(1, 250, 250):
for alpha in alpha_vec:
int_func = lambda x: np.exp(-generalized_loss_fcn(x, a=alpha, c=1))
Z, err = integrate.quadrature(int_func, -tau, tau, tol=1E-14, maxiter=10000)
res.append([tau, c, alpha, Z])
print(f'{tau:0.3f} {alpha:0.3f} {Z:0.14e}')
res = np.array(res)
np.savetxt('res.csv', res, delimiter=',')
'''

data = np.genfromtxt('res.csv', delimiter=',')

data = data[:, [0,2,3]]
tau = data[:,0].reshape((250,2191))
alpha = data[:,1].reshape((250,2191))
Z = data[:,2].reshape((250,2191))

tau = tau[:,1:]
alpha = alpha[:,1:]
Z = Z[:,1:]

kx = 3
ky = kx

# spline_fit = interpolate.RectBivariateSpline(tau[:,0], alpha[0,:], np.log(Z), kx=kx, ky=ky, s=0.0001)

# with open("spline_save.csv", "ab") as f:
# for i in range(3):
# np.savetxt(f, np.matrix(spline_fit.tck[i]), delimiter=",")
# for val in [kx, ky]:
# np.savetxt(f, np.matrix(val), delimiter=",")

tck = []
with open("spline_save.csv") as f:
for i in range(5):
tck.append(np.array(f.readline().split(','), dtype=float))

spline_fit = interpolate.RectBivariateSpline._from_tck(tck)

idx = np.argwhere(data[:,0] == 1)

# plt.plot(x_deriv, deriv(x_deriv))
# plt.plot(data[idx,1], np.log(data[idx,2]) - spline_fit([2], data[idx,1]).T)
# plt.plot(data[idx,1][1:], np.log(data[idx,2][1:]) - spline_fit([2], data[idx,1][1:]).T)
plt.plot(data[idx,1][1:], np.log(data[idx,2][1:]), data[idx,1][1:], spline_fit([1], data[idx,1][1:]).T)
plt.show()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://arxiv.org/pdf/2004.14938.pdf

Tau = 100
alpha = -60 to 2
c = 1 to 5
Loading

0 comments on commit c54f4c1

Please sign in to comment.