def add_variables(self, v, name, solr, soli=None): from petram.helper.variables import add_coordinates from petram.helper.variables import add_scalar from petram.helper.variables import add_components from petram.helper.variables import add_expression from petram.helper.variables import add_surf_normals from petram.helper.variables import add_constant from petram.helper.variables import GFScalarVariable ind_vars = [x.strip() for x in self.ind_vars.split(',')] suffix = self.dep_vars_suffix #from petram.helper.variables import TestVariable #v['debug_test'] = TestVariable() add_coordinates(v, ind_vars) add_surf_normals(v, ind_vars) dep_vars = self.dep_vars sdim = self.geom_dim if name == dep_vars[0]: add_scalar(v, name, "", ind_vars, solr, soli) elif name == dep_vars[1]: for k, suffix in enumerate(ind_vars): nn = name + suffix v[nn] = GFScalarVariable(solr, soli, comp=k + 1) else: pass return v
def add_variables(self, v, name, solr, soli=None): from petram.helper.variables import add_coordinates from petram.helper.variables import add_scalar from petram.helper.variables import add_components from petram.helper.variables import add_expression from petram.helper.variables import add_surf_normals from petram.helper.variables import add_constant from petram.phys.em3d.eval_deriv import eval_curl ''' def evalB(gfr, gfi = None): gfr, gfi, extra = eval_curl(gfr, gfi) gfi /= (2*self.freq*np.pi) # real B gfr /= -(2*self.freq*np.pi) # imag B return gfi, gfr, extra ''' ind_vars = [x.strip() for x in self.ind_vars.split(',')] suffix = self.dep_vars_suffix from petram.helper.variables import TestVariable #v['debug_test'] = TestVariable() add_coordinates(v, ind_vars) add_surf_normals(v, ind_vars) add_scalar(v, name, "", ind_vars, solr, soli) return v '''
def add_variables(self, v, name, solr, soli = None): from petram.helper.variables import add_coordinates from petram.helper.variables import add_scalar from petram.helper.variables import add_components from petram.helper.variables import add_expression from petram.helper.variables import add_surf_normals from petram.helper.variables import add_constant from petram.helper.variables import GFScalarVariable ind_vars = [x.strip() for x in self.ind_vars.split(',')] suffix = self.dep_vars_suffix #from petram.helper.variables import TestVariable #v['debug_test'] = TestVariable() add_coordinates(v, ind_vars) add_surf_normals(v, ind_vars) dep_vars = self.dep_vars sdim = self.geom_dim isVector = False isNormal=False if self.element.startswith('RT'): if self.dim != sdim: if self.element.endswith(')'): isVector = True else: isNormal = True else: isVector = True elif self.element.startswith('ND'): isVector = True for dep_var in dep_vars: if name != dep_var: continue if isVector: add_components(v, dep_var, "", ind_vars, solr, soli) elif isNormal: add_scalar(v, dep_var+"n", "", ind_vars, solr, soli) else: if self.vdim == 1: add_scalar(v, dep_var, "", ind_vars, solr, soli) else: names = self.dep_vars_base_txt.split(',') for k, n in enumerate(names): name = n + suffix v[name] = GFScalarVariable(solr, soli, comp=k+1) return v
def add_variables(self, v, name, solr, soli = None): from petram.helper.variables import add_coordinates from petram.helper.variables import add_scalar from petram.helper.variables import add_components from petram.helper.variables import add_elements from petram.helper.variables import add_expression from petram.helper.variables import add_surf_normals from petram.helper.variables import add_constant from petram.phys.em3d.eval_deriv import eval_curl def evalB(gfr, gfi = None): gfr, gfi, extra = eval_curl(gfr, gfi) gfi /= (2*self.freq*np.pi) # real B gfr /= -(2*self.freq*np.pi) # imag B return gfi, gfr, extra ind_vars = [x.strip() for x in self.ind_vars.split(',')] suffix = self.dep_vars_suffix from petram.helper.variables import TestVariable #v['debug_test'] = TestVariable() add_coordinates(v, ind_vars) add_surf_normals(v, ind_vars) if name.startswith('Et'): add_elements(v, 'E', suffix, ind_vars, solr, soli, elements=[0,1]) elif name.startswith('rEf'): add_scalar(v, 'rEf', suffix, ind_vars, solr, soli) add_expression(v, 'Ephi', suffix, ind_vars, 'rEf/r', ['rEf',]) elif name.startswith('psi'): add_scalar(v, 'psi', suffix, ind_vars, solr, soli) add_expression(v, 'E', suffix, ind_vars, 'array([Er, Ephi, Ez])', ['Er', 'Ephi', 'Ez']) # collect all definition from children #for mm in self.walk(): # if not mm.enabled: continue # if mm is self: continue # mm.add_domain_variables(v, name, suffix, ind_vars, # solr, soli) # mm.add_bdr_variables(v, name, suffix, ind_vars, # solr, soli) return v
def add_variables(self, v, name, solr, soli=None): from petram.helper.variables import add_coordinates from petram.helper.variables import add_scalar from petram.helper.variables import add_components from petram.helper.variables import add_expression from petram.helper.variables import add_surf_normals from petram.helper.variables import add_constant ind_vars = [x.strip() for x in self.ind_vars.split(',')] suffix = self.dep_vars_suffix #from petram.helper.variables import TestVariable #v['debug_test'] = TestVariable() add_coordinates(v, ind_vars) add_surf_normals(v, ind_vars) dep_vars = self.dep_vars for dep_var in dep_vars: if name.startswith(dep_var): add_scalar(v, dep_var, suffix, ind_vars, solr, soli) return v
def add_variables(self, v, name, solr, soli = None): from petram.helper.variables import add_coordinates from petram.helper.variables import add_scalar from petram.helper.variables import add_components from petram.helper.variables import add_expression from petram.helper.variables import add_surf_normals from petram.helper.variables import add_constant ind_vars = [x.strip() for x in self.ind_vars.split(',')] suffix = self.dep_vars_suffix from petram.helper.variables import TestVariable #v['debug_test'] = TestVariable() add_coordinates(v, ind_vars) add_surf_normals(v, ind_vars) if name.startswith('E'): #add_constant(v, 'freq', suffix, self._global_ns['freq']) #add_constant(v, 'mu0', suffix, self._global_ns['mu0']) #add_constant(v, 'e0', suffix, self._global_ns['e0']) add_components(v, 'E', suffix, ind_vars, solr, soli) add_components(v, 'B', suffix, ind_vars, solr, soli, deriv=evalB) add_expression(v, 'normE', suffix, ind_vars, '(conj(Ex)*Ex + conj(Ey)*Ey +conj(Ez)*Ez)**(0.5)', ['E']) add_expression(v, 'normB', suffix, ind_vars, '(conj(Bx)*Bx + conj(By)*By + conj(Bz)*Bz)**(0.5)', ['B']) # Poynting Flux add_expression(v, 'Poyx', suffix, ind_vars, '(conj(Ey)*Bz - conj(Ez)*By)/mu0', ['B', 'E']) add_expression(v, 'Poyy', suffix, ind_vars, '(conj(Ez)*Bx - conj(Ex)*Bz)/mu0', ['B', 'E']) add_expression(v, 'Poyz', suffix, ind_vars, '(conj(Ex)*By - conj(Ey)*Bx)/mu0', ['B', 'E']) #e = - epsion * w^2 - i * sigma * w # Jd : displacement current = -i omega* e0 er E add_expression(v, 'Jdx', suffix, ind_vars, '(-1j*(dot(epsilonr, E))*freq*2*pi*e0)[0]', ['epsilonr', 'E']) add_expression(v, 'Jdy', suffix, ind_vars, '(-1j*(dot(epsilonr, E))*freq*2*pi*e0)[1]', ['epsilonr', 'E']) add_expression(v, 'Jdz', suffix, ind_vars, '(-1j*(dot(epsilonr, E))*freq*2*pi*e0)[2]', ['epsilonr', 'E']) # Ji : induced current = sigma *E add_expression(v, 'Jix', suffix, ind_vars, '(dot(sigma, E))[0]', ['sigma', 'E']) add_expression(v, 'Jiy', suffix, ind_vars, '(dot(sigma, E))[1]', ['sigma', 'E']) add_expression(v, 'J*z', suffix, ind_vars, '(dot(sigma, E))[2]', ['sigma', 'E']) # Jp : polarization current (Jp = -i omega* e0 (er - 1) E add_expression(v, 'Jpx', suffix, ind_vars, '(-1j*(dot(epsilonr, E) - E)*freq*2*pi*e0)[0]', ['epsilonr', 'E']) add_expression(v, 'Jpy', suffix, ind_vars, '(-1j*(dot(epsilonr, E) - E)*freq*2*pi*e0)[1]', ['epsilonr', 'E']) add_expression(v, 'Jpz', suffix, ind_vars, '(-1j*(dot(epsilonr, E) - E)*freq*2*pi*e0)[2]', ['epsilonr', 'E']) elif name.startswith('psi'): add_scalar(v, 'psi', suffix, ind_vars, solr, soli) # collect all definition from children #for mm in self.walk(): # if not mm.enabled: continue # if mm is self: continue # mm.add_domain_variables(v, name, suffix, ind_vars, # solr, soli) # mm.add_bdr_variables(v, name, suffix, ind_vars, # solr, soli) return v