![]() |
ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
|
00001 /* 00002 Copyright (C) 2010,2011,2012,2013 The ESPResSo project 00003 Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 00004 Max-Planck-Institute for Polymer Research, Theory Group 00005 00006 This file is part of ESPResSo. 00007 00008 ESPResSo is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 ESPResSo is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 /** \file dpd.c 00022 Implementation of \ref dpd.h "dpd.h" 00023 */ 00024 #include "dpd.h" 00025 00026 /* DPD THERMOSTAT */ 00027 /* DPD longitudinal friction coefficient gamma. */ 00028 double dpd_gamma = 0.0; 00029 /* DPD thermostat cutoff */ 00030 double dpd_r_cut = 0.0; 00031 /* DPD weightfunction */ 00032 int dpd_wf = 0; 00033 00034 /* DPD transversal friction coefficient gamma. */ 00035 double dpd_tgamma = 0.0; 00036 /* DPD thermostat trans cutoff */ 00037 double dpd_tr_cut = 0.0; 00038 /* trans DPD weightfunction */ 00039 int dpd_twf = 0; 00040 00041 #ifdef DPD 00042 /* inverse off DPD thermostat cutoff */ 00043 double dpd_r_cut_inv = 0.0; 00044 double dpd_pref1; 00045 double dpd_pref2; 00046 static double dpd_pref2_buffer; 00047 00048 #ifdef TRANS_DPD 00049 /* inverse off trans DPD thermostat cutoff */ 00050 double dpd_tr_cut_inv = 0.0; 00051 double dpd_pref3; 00052 double dpd_pref4; 00053 static double dpd_pref4_buffer; 00054 #endif 00055 00056 void dpd_switch_off() 00057 { 00058 extern double dpd_gamma,dpd_r_cut; 00059 extern int dpd_wf; 00060 #ifdef TRANS_DPD 00061 extern double dpd_tgamma,dpd_tr_cut; 00062 extern int dpd_twf; 00063 #endif 00064 dpd_gamma = 0; 00065 mpi_bcast_parameter(FIELD_DPD_GAMMA); 00066 dpd_r_cut = 0; 00067 mpi_bcast_parameter(FIELD_DPD_RCUT); 00068 dpd_wf=0; 00069 mpi_bcast_parameter(FIELD_DPD_WF); 00070 #ifdef TRANS_DPD 00071 dpd_tgamma = 0; 00072 mpi_bcast_parameter(FIELD_DPD_TGAMMA); 00073 dpd_tr_cut=0; 00074 mpi_bcast_parameter(FIELD_DPD_TRCUT); 00075 dpd_twf=0; 00076 mpi_bcast_parameter(FIELD_DPD_TWF); 00077 #endif 00078 } 00079 00080 00081 void thermo_init_dpd() 00082 { 00083 extern double dpd_gamma,dpd_r_cut,dpd_pref1,dpd_pref2; 00084 /*extern int dpd_wf;*/ 00085 #ifdef TRANS_DPD 00086 extern double dpd_tgamma,dpd_tr_cut,dpd_pref3,dpd_pref4; 00087 /*extern int dpd_twf;*/ 00088 #endif 00089 /* prefactor friction force */ 00090 /* NOTE: velocities are scaled with time_step, so divide by time_step here*/ 00091 dpd_pref1 = dpd_gamma/time_step; 00092 /* prefactor random force */ 00093 /*NOTE random force is propto sqrt(time_step)*/ 00094 dpd_pref2 = sqrt(24.0*temperature*dpd_gamma/time_step); 00095 dpd_r_cut_inv = 1.0/dpd_r_cut; 00096 #ifdef TRANS_DPD 00097 /* NOTE: velocities are scaled with time_step, so divide by time_step here*/ 00098 dpd_pref3 = dpd_tgamma/time_step; 00099 /*NOTE random force is propto sqrt(time_step)*/ 00100 dpd_pref4 = sqrt(24.0*temperature*dpd_tgamma/time_step); 00101 dpd_tr_cut_inv = 1.0/dpd_tr_cut; 00102 #endif 00103 THERMO_TRACE(fprintf(stderr,"%d: thermo_init_dpd: dpd_pref1=%f, dpd_pref2=%f", 00104 this_node,dpd_pref1,dpd_pref2)); 00105 #ifdef TRANS_DPD 00106 THERMO_TRACE(fprintf(stderr,",dpd_pref3=%f, dpd_pref4=%f\n",dpd_pref3,dpd_pref4)); 00107 #endif 00108 THERMO_TRACE(fprintf(stderr,"\n")); 00109 } 00110 00111 void dpd_heat_up() 00112 { 00113 extern double dpd_pref2; 00114 extern double dpd_pref2_buffer; 00115 #ifdef TRANS_DPD 00116 extern double dpd_pref4; 00117 extern double dpd_pref4_buffer; 00118 #endif 00119 dpd_pref2_buffer = dpd_pref2; 00120 dpd_pref2 *= sqrt(3); 00121 #ifdef TRANS_DPD 00122 dpd_pref4_buffer = dpd_pref4; 00123 dpd_pref4 *= sqrt(3); 00124 #endif 00125 } 00126 00127 00128 void dpd_cool_down() 00129 { 00130 extern double dpd_pref2; 00131 extern double dpd_pref2_buffer; 00132 #ifdef TRNAS_DPD 00133 extern double dpd_pref4; 00134 extern double dpd_pref4_buffer; 00135 #endif 00136 dpd_pref2 = dpd_pref2_buffer; 00137 #ifdef TRANS_DPD 00138 dpd_pref4 = dpd_pref4_buffer; 00139 #endif 00140 } 00141 #endif 00142 00143 #ifdef INTER_DPD 00144 void inter_dpd_heat_up() 00145 { 00146 double pref_scale=sqrt(3); 00147 inter_dpd_update_params(pref_scale); 00148 } 00149 00150 00151 void inter_dpd_cool_down() 00152 { 00153 double pref_scale=1.0/sqrt(3); 00154 inter_dpd_update_params(pref_scale); 00155 } 00156 00157 int inter_dpd_set_params(int part_type_a, int part_type_b, 00158 double gamma, double r_c, int wf, 00159 double tgamma, double tr_c, 00160 int twf) 00161 { 00162 extern double temperature; 00163 IA_parameters *data = get_ia_param_safe(part_type_a, part_type_b); 00164 00165 if (!data) return ES_ERROR; 00166 00167 data->dpd_gamma = gamma; 00168 data->dpd_r_cut = r_c; 00169 data->dpd_wf = wf; 00170 data->dpd_pref1 = gamma/time_step; 00171 data->dpd_pref2 = sqrt(24.0*temperature*gamma/time_step); 00172 data->dpd_tgamma = tgamma; 00173 data->dpd_tr_cut = tr_c; 00174 data->dpd_twf = twf; 00175 data->dpd_pref3 = tgamma/time_step; 00176 data->dpd_pref4 = sqrt(24.0*temperature*tgamma/time_step); 00177 00178 /* broadcast interaction parameters */ 00179 mpi_bcast_ia_params(part_type_a, part_type_b); 00180 00181 return ES_OK; 00182 } 00183 00184 void inter_dpd_init(){ 00185 extern double temperature; 00186 int type_a,type_b; 00187 IA_parameters *data; 00188 00189 for (type_a=0;type_a<n_particle_types;type_a++){ 00190 for (type_b=0;type_b<n_particle_types;type_b++){ 00191 data=get_ia_param(type_a,type_b); 00192 if ( (data->dpd_r_cut != 0) || (data->dpd_tr_cut != 0) ) { 00193 data->dpd_pref1=data->dpd_gamma/time_step; 00194 data->dpd_pref2=sqrt(24.0*temperature*data->dpd_gamma/time_step); 00195 data->dpd_pref3=data->dpd_tgamma/time_step; 00196 data->dpd_pref4=sqrt(24.0*temperature*data->dpd_tgamma/time_step); 00197 } 00198 } 00199 } 00200 } 00201 00202 void inter_dpd_switch_off(void){ 00203 int type_a,type_b; 00204 IA_parameters *data; 00205 for (type_a=0;type_a<n_particle_types;type_a++){ 00206 for (type_b=0;type_b<n_particle_types;type_b++){ 00207 data=get_ia_param(type_a,type_b); 00208 data->dpd_gamma = data->dpd_r_cut = data->dpd_wf = 00209 data->dpd_pref1 = data->dpd_pref2 = data->dpd_tgamma = 00210 data->dpd_tr_cut = data->dpd_twf = data->dpd_pref3 = 00211 data->dpd_pref4 = 0.0; 00212 } 00213 } 00214 } 00215 00216 void inter_dpd_update_params(double pref_scale) 00217 { 00218 int type_a,type_b; 00219 IA_parameters *data; 00220 00221 for (type_a=0;type_a<n_particle_types;type_a++){ 00222 for (type_b=0;type_b<n_particle_types;type_b++){ 00223 data=get_ia_param(type_a,type_b); 00224 if ( (data->dpd_r_cut != 0) || (data->dpd_tr_cut != 0) ) { 00225 data->dpd_pref2*=pref_scale; 00226 data->dpd_pref4*=pref_scale; 00227 } 00228 } 00229 } 00230 } 00231 #endif
1.7.5.1