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

Revive contact smoothing #989

Open
wants to merge 28 commits into
base: feature-contacts
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b4786d5
hacky support for contact temperature smoothing
kecnry Oct 4, 2024
f0fe605
added .save_as_standard_mesh after smoothing
gecheline Nov 12, 2020
4720723
cache "smoothed_teffs"
kecnry Nov 13, 2020
a9c363f
update weighing to use highest teff2 instead of teff1_neck
gecheline Nov 13, 2020
7e429c7
added lateral, isotropic and spotty mixing
kecnry Oct 4, 2024
0bc0a0c
parameterization of mixing methods with user-provided power and fixed…
gecheline Nov 14, 2020
37a007d
updated limits for mixing power to None
gecheline Nov 14, 2020
1530d58
Added "spotted" option to mixing_method.
aprsa Nov 15, 2020
9b7116d
Commented out a print statement.
aprsa Nov 16, 2020
29c7a63
updates to distl and stuff to allow plotting
kecnry Oct 4, 2024
670df11
reinstate mixing code in backend
Nov 4, 2024
119a3ef
make function of two occurances of mixing in backends.py
Nov 6, 2024
3362d9a
rebuild default bundles
Nov 6, 2024
8ea7a0f
set default mix to false in component.py
Nov 6, 2024
7f2d846
implement perfect mixing
Nov 6, 2024
e8c4ff2
some documentation/description of the mixing methods
Nov 7, 2024
2b71ab1
update default bundles with new choice
Nov 7, 2024
aad340b
add simple test of perfect mixing
Nov 7, 2024
b97a6ea
Merge remote-tracking branch 'origin/feature-contacts' into revive-co…
matthiasfabry Dec 4, 2024
ae834bf
add documentation
matthiasfabry Dec 18, 2024
2b72d1b
pep8 formatting
matthiasfabry Dec 18, 2024
9a21b37
use logger; descriptive ValueErrors
matthiasfabry Dec 18, 2024
f321360
remove spotty transfer cause too parametric
matthiasfabry Dec 18, 2024
bfee696
gate energy transfer behind envelope requirement; rename to `energy_t…
matthiasfabry Dec 19, 2024
41c536c
add forbidden labels
matthiasfabry Dec 20, 2024
d227197
recompute def bundles
matthiasfabry Dec 20, 2024
75c2b5a
remove old implementation in universe.py
matthiasfabry Dec 20, 2024
d6a8d03
Revert "updates to distl and stuff to allow plotting"
matthiasfabry Dec 20, 2024
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
42 changes: 41 additions & 1 deletion phoebe/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from phoebe.parameters import StringParameter, DictParameter, ArrayParameter, ParameterSet
from phoebe.parameters.parameters import _extract_index_from_string
from phoebe import dynamics
from phoebe.backend import universe, horizon_analytic
from phoebe.backend import universe, horizon_analytic, contacts_energy_transfer
from phoebe.atmospheres import passbands
from phoebe.distortions import roche
from phoebe.frontend import io
Expand Down Expand Up @@ -976,6 +976,13 @@ def _compute_intrinsic_system_at_t0(self, b, compute,
# kinds = [b.get_dataset(dataset=ds).kind for ds in datasets]

system.update_positions(t0, x0, y0, z0, vx0, vy0, vz0, etheta0, elongan0, eincl0, ignore_effects=True)

#ENERGY TRANSFER FOR CONTACTS
if 'envelope' in b.filter(context='component'): # only makes sense when an envelope is present
mixing_enabled = b.get_value(qualifier='mixing_enabled', context='component', **_skip_filter_checks)
if mixing_enabled:
self._do_mixing(b, system)

system.populate_observables(t0, ['lc' for dataset in datasets], datasets, ignore_effects=True)


Expand All @@ -985,6 +992,33 @@ def _compute_intrinsic_system_at_t0(self, b, compute,

return system

@staticmethod
def _do_mixing(b, system):
mixing_method = b.get_value(qualifier='mixing_method', context='component', **_skip_filter_checks)
mixing_power = b.get_value(qualifier='mixing_power', context='component', **_skip_filter_checks)
secondary_teff = b.get_value(qualifier='teff', context='component', component='secondary',
**_skip_filter_checks)
primary_teff = b.get_value(qualifier='teff', context='component', component='primary', **_skip_filter_checks)
teff_ratio = secondary_teff / primary_teff

primary_mesh, secondary_mesh = system.bodies[0].meshes.values()
coords1 = primary_mesh.roche_coords_for_computations
teffs1 = primary_mesh.teffs
coords2 = secondary_mesh.roche_coords_for_computations
teffs2 = secondary_mesh.teffs

new_teffs1, new_teffs2 = contacts_energy_transfer.mix_teffs(np.array(coords1), np.array(teffs1),
np.array(coords2), np.array(teffs2),
mixing_method=mixing_method,
mixing_power=mixing_power, teff_ratio=teff_ratio)
# w=smoothing_factor, cutoff=0.)
primary_mesh.update_columns(teffs=new_teffs1)
secondary_mesh.update_columns(teffs=new_teffs2)

# print("new_teffs1.median", np.median(new_teffs1))
# print("new_teffs2.median", np.median(new_teffs2))
system.bodies[0]._halves[0].smoothed_teffs = new_teffs1
system.bodies[0]._halves[1].smoothed_teffs = new_teffs2

def _worker_setup(self, b, compute, times, infolists, **kwargs):
logger.debug("rank:{}/{} PhoebeBackend._worker_setup: extracting parameters".format(mpi.myrank, mpi.nprocs))
Expand Down Expand Up @@ -1072,6 +1106,12 @@ def _run_single_time(self, b, i, time, infolist, **kwargs):
logger.debug("rank:{}/{} PhoebeBackend._run_single_time: calling system.update_positions at time={}".format(mpi.myrank, mpi.nprocs, time))
system.update_positions(time, xi, yi, zi, vxi, vyi, vzi, ethetai, elongani, eincli, ds=di, Fs=Fi)

#ENERGY TRANSFER FOR CONTACTS
if 'envelope' in b.filter(context='component'): # only makes sense when an envelope is present
mixing_enabled = b.get_value(qualifier='mixing_enabled', context='component', **_skip_filter_checks)
if mixing_enabled and i==0:
self._do_mixing(b, system)

# Now we need to determine which triangles are visible and handle subdivision
# NOTE: this should come after populate_observables so that each subdivided triangle
# will have identical local quantities. The only downside to this is that we can't
Expand Down
Loading
Loading