GitHub PullRequestReviewCommentEvent at 2014-04-21 19:30:29
Repository: sailfish
Actor: mjanusz
Payload: {"comment":{"url":"https://api.github.com/repos/sailfish-team/sailfish/pulls/comments/11822168","id":11822168,"diff_hunk":"@@ -375,67 +377,69 @@ def get_compute_kernels(self, runner, full_output, bulk):\n         return zip(macro_pair, sim_pair)\n \n \n-class LBBinaryFluidShanChen(LBBinaryFluidBase, LBForcedSim):\n-    \"\"\"Binary fluid mixture using the Shan-Chen model.\"\"\"\n+class LBMultiFluidShanChen(LBMultiFluidBase, LBForcedSim):\n+    \"\"\"Multiple fluid mixture using the Shan-Chen model.\"\"\"\n \n-    equilibria = (sym_equilibrium.bgk_equilibrium,\n-                  partial(sym_equilibrium.bgk_equilibrium, rho=sym.S.phi,\n-                          rho0=sym.S.phi))\n+    equilibria = tuple(partial(sym_equilibrium.bgk_equilibrium,\n+                                rho=eval('sym.S.g{}m0'.format(c)),\n+                                rho_0=eval('sym.S.g{}m0'.format(c))) for c in range(0, 9))\n \n     def __init__(self, config):\n-        super(LBBinaryFluidShanChen, self).__init__(config)\n-        self.add_force_coupling(0, 0, 'G11')\n-        self.add_force_coupling(0, 1, 'G12')\n-        self.add_force_coupling(1, 0, 'G21')\n-        self.add_force_coupling(1, 1, 'G22')\n+        super(LBMultiFluidShanChen, self).__init__(config)\n+        for c1, c2 in product(range(0, config.lat_nc), repeat=2):\n+            self.add_force_coupling(c1,c2,'G{}{}'.format(c1,c2))\n \n     def constants(self):\n-        ret = super(LBBinaryFluidShanChen, self).constants()\n-        ret['G11'] = self.config.G11\n-        ret['G12'] = self.config.G12\n-        ret['G21'] = self.config.G12\n-        ret['G22'] = self.config.G22\n+        ret = super(LBMultiFluidShanChen, self).constants()\n+        for c1, c2 in product(range(0, self.config.lat_nc), repeat=2):\n+            ret['G{}{}'.format(c1,c2)] = eval(('self.config.G{0}{1}' if c1 <= c2 \n+                                          else 'self.config.G{1}{0}').format(c1,c2))\n         return ret\n \n     @classmethod\n-    def fields(cls):\n-        return [ScalarField('rho', need_nn=True),\n-                ScalarField('phi', need_nn=True),\n-                VectorField('v')]\n+    def fields(cls, grids):\n+        return [ScalarField('g{}m0'.format(grid_num), need_nn=True) \n+                for grid_num in range(0, len(grids))] + [VectorField('v')]\n \n     @classmethod\n     def add_options(cls, group, dim):\n         LBForcedSim.add_options(group, dim)\n-        LBBinaryFluidBase.add_options(group, dim)\n-\n-        group.add_argument('--visc', type=float, default=1.0, help='numerical viscosity')\n-        group.add_argument('--G11', type=float, default=0.0,\n-                help='Shan-Chen component 1 self-interaction strength constant')\n-        group.add_argument('--G12', type=float, default=0.0,\n-                help='Shan-Chen component 1<->2 interaction strength constant')\n-        group.add_argument('--G22', type=float, default=0.0,\n-                help='Shan-Chen component 2 self-interaction strength constant')\n+        LBMultiFluidBase.add_options(group, dim)\n+\n+        for c1 in range(0, 9):\n+            group.add_argument('--visc{}'.format(c1), type=float, default=1.0/6.0, \n+                    help='numerical viscosity for component {}'.format(c1))\n+            group.add_argument('--tau{}'.format(c1), type=float, default=1.0,\n+                    help='relaxation time for component {}'.format(c1))\n+            for c2 in range(0, 9):\n+                helpname = ('{} self-interaction'.format(c1) if c1 == c2 \n+                                else '{}<->{} interaction'.format(c1,c2))\n+                group.add_argument('--G{}{}'.format(c1,c2), type=float, default=0.0, \n+                        help='Shan-Chen component {} strength constant'.format(helpname))\n         group.add_argument('--sc_potential', type=str,\n                 choices=sym.SHAN_CHEN_POTENTIALS, default='linear',\n                 help='Shan-Chen pseudopotential function to use')\n \n     def update_context(self, ctx):\n-        super(LBBinaryFluidShanChen, self).update_context(ctx)\n+        super(LBMultiFluidShanChen, self).update_context(ctx)\n         ctx['simtype'] = 'shan-chen'\n+        for c in range(0, self.config.lat_nc):\n+            ctx['tau{}'.format(c)] =  sym.relaxation_time(eval('self.config.visc{}'.format(c)))","path":"sailfish/lb_multi.py","position":269,"original_position":269,"commit_id":"859ed04b720bfbe88f0ceccbe65d3bc2d2fac4f8","original_commit_id":"859ed04b720bfbe88f0ceccbe65d3bc2d2fac4f8","user":{"login":"mjanusz","id":328443,"avatar_url":"https://avatars.githubusercontent.com/u/328443?","gravatar_id":"b30f26a2f784d6223e4c8c8296ee6b9f","url":"https://api.github.com/users/mjanusz","html_url":"https://github.com/mjanusz","followers_url":"https://api.github.com/users/mjanusz/followers","following_url":"https://api.github.com/users/mjanusz/following{/other_user}","gists_url":"https://api.github.com/users/mjanusz/gists{/gist_id}","starred_url":"https://api.github.com/users/mjanusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjanusz/subscriptions","organizations_url":"https://api.github.com/users/mjanusz/orgs","repos_url":"https://api.github.com/users/mjanusz/repos","events_url":"https://api.github.com/users/mjanusz/events{/privacy}","received_events_url":"https://api.github.com/users/mjanusz/received_events","type":"User","site_admin":false},"body":"nit: single space after = ","created_at":"2014-04-21T19:30:29Z","updated_at":"2014-04-21T19:30:29Z","html_url":"https://github.com/sailfish-team/sailfish/pull/29#discussion_r11822168","pull_request_url":"https://api.github.com/repos/sailfish-team/sailfish/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/sailfish-team/sailfish/pulls/comments/11822168"},"html":{"href":"https://github.com/sailfish-team/sailfish/pull/29#discussion_r11822168"},"pull_request":{"href":"https://api.github.com/repos/sailfish-team/sailfish/pulls/29"}}}}