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

allow for constant mass loss in Mmams #859

Merged
merged 3 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions src/amuse/community/mmams/interface.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "src/mmas2/src/mmas/mmas.h"
#include "src/mmas2/src/eos/eos.h"
#include "src/mmas2/src/mmas/mass_loss.h"
#include "worker_code.h"
#include <map>
#include <gsl/gsl_errno.h>
Expand All @@ -11,6 +12,7 @@ int dump_mixed = 1;
int target_n_shells_mixing = 200;
int target_n_shells = 10000;
int flag_do_shock_heating = 1;
int mass_loss_do_const_flag = false;


int number_of_particles = 0;
Expand Down Expand Up @@ -40,6 +42,7 @@ int cleanup_code(){
}

int commit_parameters(){
do_const=mass_loss_do_const_flag;
return 0;
}

Expand Down Expand Up @@ -237,6 +240,26 @@ int get_dump_mixed_flag(int *dump_mixed_flag){
return 0;
}

int set_mass_loss_do_const_flag(int flag){
mass_loss_do_const_flag = flag;
return 0;
}
int get_mass_loss_do_const_flag(int *flag){
*flag = mass_loss_do_const_flag;
return 0;
}

int set_const_mass_loss(double x){
const_mass_loss = x;
return 0;
}
int get_const_mass_loss(double *x){
*x = const_mass_loss;
return 0;
}



int set_target_n_shells_mixing(int target_n_shells_mixing_in){
target_n_shells_mixing = target_n_shells_mixing_in;
return 0;
Expand Down
50 changes: 50 additions & 0 deletions src/amuse/community/mmams/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,40 @@ def get_dump_mixed_flag():
function.addParameter('dump_mixed_flag', dtype='int32', direction=function.OUT)
function.result_type = 'i'
return function

@legacy_function
def set_mass_loss_do_const_flag():
"""Set the dump_mixed flag: specifies whether the returned products must be mixed first."""
function = LegacyFunctionSpecification()
function.addParameter('mass_loss_do_const_flag', dtype='int32', direction=function.IN)
function.result_type = 'i'
return function

@legacy_function
def get_mass_loss_do_const_flag():
"""Get the dump_mixed flag: specifies whether the returned products must be mixed first."""
function = LegacyFunctionSpecification()
function.addParameter('mass_loss_do_const_flag', dtype='int32', direction=function.OUT)
function.result_type = 'i'
return function


@legacy_function
def get_const_mass_loss():
"""Get the const_mass_loss"""
function = LegacyFunctionSpecification()
function.addParameter('const_mass_loss', dtype='float64', direction=function.OUT)
function.result_type = 'i'
return function

@legacy_function
def set_const_mass_loss():
"""Set the const_mass_loss"""
function = LegacyFunctionSpecification()
function.addParameter('const_mass_loss', dtype='float64', direction=function.IN)
function.result_type = 'i'
return function

@legacy_function
def set_target_n_shells_mixing():
"""Set the target number of shells for mixed models."""
Expand Down Expand Up @@ -283,6 +316,23 @@ def define_parameters(self, handler):
"dump_mixed flag: specifies whether the returned products must be mixed first",
True
)

handler.add_boolean_parameter(
"get_mass_loss_do_const_flag",
"set_mass_loss_do_const_flag",
"mass_loss_do_const",
"mass_loss_do_const flag: whether to use const mass loss fraction (True) or the original Gaburov 2008 fromulation",
False
)

handler.add_method_parameter(
"get_const_mass_loss",
"set_const_mass_loss",
"constant_mass_loss",
"if do_const=True, specify what the constant mass loss fraction used is",
0.1
)


handler.add_boolean_parameter(
"get_do_shock_heating_flag",
Expand Down
12 changes: 11 additions & 1 deletion src/amuse/community/mmams/src/mmas2/src/mmas/mass_loss.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "mmas.h"
#include "mass_loss.h"

bool do_const=false;
double const_mass_loss=0.1;


/* This routine computes mass loss */
Expand All @@ -12,7 +16,13 @@ real mmas::mass_loss() {
// if (age < 0.75) {

Choose a reason for hiding this comment

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

change back because of misunderstanding: mass_loss over the stellar lifetime not mass loss of merger product

// f_ml = 6.93 * pow(q, -2.11) * pow(2*q/(1+q), 4.16);
// } else {
f_ml = 8.36 * pow(q, -2.58) * pow(2*q/(1+q), 4.28);

if(do_const)
f_ml=100*const_mass_loss; // because const_mass_loss is a fraction, while mass_loss returns percentage
else
{
f_ml = 8.36 * pow(q, -2.58) * pow(2*q/(1+q), 4.28);
}
// }
PRL(f_ml);
return f_ml;
Expand Down
3 changes: 3 additions & 0 deletions src/amuse/community/mmams/src/mmas2/src/mmas/mass_loss.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

extern bool do_const;
extern double const_mass_loss;