예제 #1
0
 // Вывод треугольника
  void ShowTr( int p1,int p2,int p3 ){
		int Triangle[6] =
		  { XC(W[p1-1]), YC(W[p1-1]),
				XC(W[p2-1]), YC(W[p2-1]),
				XC(W[p3-1]), YC(W[p3-1]) };
		fillpoly(sizeof(Triangle)/sizeof(pointtype),Triangle);
  };
예제 #2
0
파일: libxc.c 프로젝트: qsnake/gpaw
static void lxcXCFunctional_dealloc(lxcXCFunctionalObject *self)
{
  /* destroy xc functional */
  switch(self->xc_functional.family)
    {
    case XC_FAMILY_GGA:
      XC(gga_end)(&(self->xc_functional.gga_func));
      break;
    case XC_FAMILY_HYB_GGA:
      XC(hyb_gga_end)(&(self->xc_functional.hyb_gga_func));
      break;
    case XC_FAMILY_MGGA:
      XC(mgga_end)(&(self->xc_functional.mgga_func));
      break;

    case XC_FAMILY_LCA:
      /* XC(lca_end)(&(self->xc_functional.lca_func)); */ /* MDTMP - does not exist in libx! */
      break;
/*     default: */
/*       printf("lxcXCFunctional_dealloc: cannot destroy nonexisting %d xc functional\n", self->xc_functional.family); */
    }
  /* destroy x functional */
  switch(self->x_functional.family)
    {
    case XC_FAMILY_LDA:
      /*XC(lda_end)(&(self->x_functional.lda_func)); */
      break;
    case XC_FAMILY_GGA:
      XC(gga_end)(&(self->x_functional.gga_func));
      break;
    case XC_FAMILY_HYB_GGA:
      XC(hyb_gga_end)(&(self->x_functional.hyb_gga_func));
      break;
    case XC_FAMILY_MGGA:
      XC(mgga_end)(&(self->x_functional.mgga_func));
      break;
/*     default: */
/*       printf("lxcXCFunctional_dealloc: cannot destroy nonexisting %d x functional\n", self->x_functional.family); */
    }
  /* destroy c functional */
  switch(self->c_functional.family)
    {
    case XC_FAMILY_LDA:
      /*      XC(lda_end)(&(self->c_functional.lda_func)); */
      break;
    case XC_FAMILY_GGA:
      XC(gga_end)(&(self->c_functional.gga_func));
      break;
    case XC_FAMILY_HYB_GGA:
      XC(hyb_gga_end)(&(self->c_functional.hyb_gga_func));
      break;
    case XC_FAMILY_MGGA:
      XC(mgga_end)(&(self->c_functional.mgga_func));
      break;
/*     default: */
/*       printf("lxcXCFunctional_dealloc: cannot destroy nonexisting %d c functional\n", self->c_functional.family); */
    }
  PyObject_DEL(self);
}
예제 #3
0
/*------------------------------------------------------*/
int XC(functional_get_number)(const char *name)
{
  int ii;

  for(ii=0;;ii++){
    if(XC(functional_keys)[ii].number == -1)
      return -1;
    if(strncasecmp(XC(functional_keys)[ii].name, name, 256) == 0) 
      return XC(functional_keys)[ii].number;
  }
}
예제 #4
0
/*------------------------------------------------------*/
char *XC(functional_get_name)(int number)
{
  int ii;

  for(ii=0;;ii++){
    if(XC(functional_keys)[ii].number == -1)
      return NULL;
    if(XC(functional_keys)[ii].number == number)
      /* return duplicated: caller has the responsibility to dealloc string */
      return strdup(XC(functional_keys)[ii].name);
  }
}
예제 #5
0
/*------------------------------------------------------*/
int XC(family_from_id)(int id, int *family, int *number)
{
  int ii;

  /* first let us check if it is an LDA */
  for(ii=0; XC(lda_known_funct)[ii]!=NULL; ii++){
    if(XC(lda_known_funct)[ii]->number == id){
      if(family != NULL) *family = XC_FAMILY_LDA;
      if(number != NULL) *number = ii;
      return XC_FAMILY_LDA;
    }
  }

  /* or is it a GGA? */
  for(ii=0; XC(gga_known_funct)[ii]!=NULL; ii++){
    if(XC(gga_known_funct)[ii]->number == id){
      if(family != NULL) *family = XC_FAMILY_GGA;
      if(number != NULL) *number = ii;
      return XC_FAMILY_GGA;
    }
  }

  /* or is it a hybrid GGA? */
  for(ii=0; XC(hyb_gga_known_funct)[ii]!=NULL; ii++){
    if(XC(hyb_gga_known_funct)[ii]->number == id){
      if(family != NULL) *family = XC_FAMILY_HYB_GGA;
      if(number != NULL) *number = ii;
      return XC_FAMILY_HYB_GGA;
    }
  }

  /* or is it a meta GGA? */
  for(ii=0; XC(mgga_known_funct)[ii]!=NULL; ii++){
    if(XC(mgga_known_funct)[ii]->number == id){
      if(family != NULL) *family = XC_FAMILY_MGGA;
      if(number != NULL) *number = ii;
      return XC_FAMILY_MGGA;
    }
  }

  /* or is it a hybrid meta GGA? */
  for(ii=0; XC(hyb_mgga_known_funct)[ii]!=NULL; ii++){
    if(XC(hyb_mgga_known_funct)[ii]->number == id){
      if(family != NULL) *family = XC_FAMILY_HYB_MGGA;
      if(number != NULL) *number = ii;
      return XC_FAMILY_HYB_MGGA;
    }
  }

  return XC_FAMILY_UNKNOWN;
}
예제 #6
0
파일: libxc.c 프로젝트: qsnake/gpaw
/* a general call for a GGA functional */
void get_vxc_gga(functionals_type *func, double point[7], double *e, double der[7])
{
  switch(func->family)
    {
    case XC_FAMILY_GGA:
      XC(gga_vxc)(&(func->gga_func), &(point[0]), &(point[2]),
                  e, &(der[0]), &(der[2]));
      break;
    case XC_FAMILY_HYB_GGA:
      XC(hyb_gga)(&(func->hyb_gga_func), &(point[0]), &(point[2]),
                  e, &(der[0]), &(der[2]));
      break;
    }
}
예제 #7
0
 // Выводим числа
  void ShowNamb(){
		char st[2] = "1";
		for (int i=0;i<DimNods;i++){
		  st[0]=Mask[i];
		  outtextxy( XC(W[i])-10,YC(W[i])-8,st);
		};
  };
예제 #8
0
파일: libxc.c 프로젝트: qsnake/gpaw
/* a general call for an LDA functional - finite difference */
void get_fxc_fd_lda(functionals_type *func, double point[7], double der[5][5])
{
  double v2rho2[3], v2rhosigma[6], v2sigma2[6];

  for(int i=0; i<3; i++) v2rho2[i] = 0.0;
  for(int i=0; i<6; i++){
    v2rhosigma[i] = 0.0;
    v2sigma2[i]    = 0.0;
  }
  XC(lda_fxc_fd)(&(func->lda_func), point, v2rho2);
  der[0][0] = v2rho2[0];
  der[0][1] = der[1][0] = v2rho2[1];
  der[1][1] = v2rho2[2];
  der[0][2] = der[2][0] = v2rhosigma[0];
  der[0][3] = der[3][0] = v2rhosigma[1];
  der[0][4] = der[4][0] = v2rhosigma[2];
  der[1][2] = der[2][1] = v2rhosigma[3];
  der[1][3] = der[3][1] = v2rhosigma[4];
  der[1][4] = der[4][1] = v2rhosigma[5];
  der[2][2] = v2sigma2[0];
  der[2][3] = der[3][2] = v2sigma2[1];
  der[2][4] = der[4][2] = v2sigma2[2];
  der[3][3] = v2sigma2[3];
  der[3][4] = der[4][3] = v2sigma2[4];
  der[4][4] = v2sigma2[5];
}
예제 #9
0
bool needs_VV10(int func_id, double & b, double & C) {
  b=0.0;
  C=0.0;
  
  bool ret=false;
#ifdef XC_FLAGS_VV10
  if(func_id>0) {
    xc_func_type func;
    if(xc_func_init(&func, func_id, XC_UNPOLARIZED) != 0){
      ERROR_INFO();
      std::ostringstream oss;
      oss << "Functional "<<func_id<<" not found!";
      throw std::runtime_error(oss.str());
    }
    // Get flag
    ret=func.info->flags & XC_FLAGS_VV10;
    if(ret)
      XC(nlc_coef)(&func, &b, &C);
    // Free functional
    xc_func_end(&func);
  }
#endif
  
  return ret;
}
예제 #10
0
// Find out ID of functional
int find_func(std::string name) {
  // Was functional given as a number? If so, use it.
  if(isdigit(name[0]))
    return atoi(name.c_str());

  // Check if 'none' was specified. This is internal to ERKALE
  if(stricmp(name,"none")==0)
    return 0;

  // Otherwise, call libxc function.
  char help[strlen(name.c_str())+1];
  strcpy(help,name.c_str());
  int funcid=XC(functional_get_number)(help);

  // If libxc returned -1, the functional was not found.
  if(funcid==-1) {
    std::ostringstream oss;
    oss << "\nError: libxc did not recognize functional "<<name<<"!\n";
    throw std::runtime_error(oss.str());
  } else
    return funcid;

  // Dummy return clause
  return 0;
}
예제 #11
0
static void
parse_forecast_xml (GWeatherInfo    *master_info,
                    SoupMessageBody *body)
{
    GWeatherInfoPrivate *priv;
    xmlDocPtr doc;
    xmlXPathContextPtr xpath_ctx;
    xmlXPathObjectPtr xpath_result;
    int i;

    priv = master_info->priv;

    doc = xmlParseMemory (body->data, body->length);
    if (!doc)
	return;

    xpath_ctx = xmlXPathNewContext (doc);
    xpath_result = xmlXPathEval (XC("/weatherdata/forecast/time"), xpath_ctx);

    if (!xpath_result || xpath_result->type != XPATH_NODESET)
	goto out;

    for (i = 0; i < xpath_result->nodesetval->nodeNr; i++) {
	xmlNodePtr node;
	GWeatherInfo *info;

	node = xpath_result->nodesetval->nodeTab[i];
	info = make_info_from_node (master_info, node);

	priv->forecast_list = g_slist_append (priv->forecast_list, info);
    }

    xmlXPathFreeObject (xpath_result);

    xpath_result = xmlXPathEval (XC("/weatherdata/credit/link"), xpath_ctx);
    if (!xpath_result || xpath_result->type != XPATH_NODESET)
	goto out;

    priv->forecast_attribution = g_strdup(_("Weather data from the <a href=\"http://openweathermap.org\">Open Weather Map project</a>"));

 out:
    if (xpath_result)
	xmlXPathFreeObject (xpath_result);
    xmlXPathFreeContext (xpath_ctx);
    xmlFreeDoc (doc);
}
예제 #12
0
static GWeatherInfo *
make_info_from_node (GWeatherInfo *master_info,
		     xmlNodePtr    node)
{
    GWeatherInfo *info;
    GWeatherInfoPrivate *priv;
    xmlChar *val;
    int code;

    g_return_val_if_fail (node->type == XML_ELEMENT_NODE, NULL);

    info = _gweather_info_new_clone (master_info);
    priv = info->priv;

    val = xmlGetProp (node, XC("date"));
    priv->current_time = priv->update = date_to_time_t (val);
    xmlFree (val);

    val = xmlGetProp (node, XC("high"));
    priv->temp_max = g_ascii_strtod ((const char*) val, NULL);
    xmlFree (val);

    val = xmlGetProp (node, XC("low"));
    priv->temp_min = g_ascii_strtod ((const char*) val, NULL);
    xmlFree (val);

    priv->tempMinMaxValid = priv->tempMinMaxValid || (priv->temp_max > -999.0 && priv->temp_min > -999.0);
    priv->valid = priv->tempMinMaxValid;

    val = xmlGetProp (node, XC("text"));
    priv->forecast = g_strdup ((const char*) val);
    xmlFree (val);

    val = xmlGetProp (node, XC("code"));
    code = strtol((const char*) val, NULL, 0);
    if (code >= 0 && code < G_N_ELEMENTS (condition_codes)) {
	priv->cond = condition_codes[code];
	priv->sky = sky_codes[code];
    } else
	priv->valid = FALSE;
    xmlFree (val);

    return info;
}
예제 #13
0
static inline void
read_temperature (GWeatherInfo *info,
		  xmlNodePtr    node)
{
    xmlChar *unit;
    xmlChar *val;
    double celsius;

    unit = xmlGetProp (node, XC("unit"));
    if (unit == NULL || strcmp ((char*)unit, "celsius"))
        return;

    val = xmlGetProp (node, XC("value"));
    if (val == NULL)
	return;

    celsius = g_ascii_strtod ((char*) val, NULL);
    info->priv->temp = TEMP_C_TO_F (celsius);
}
예제 #14
0
파일: test.c 프로젝트: gimunu/octopus_hhg
void test_gga()
{
  XC(func_type) gga, gga2, gga3, gga4;
  int i;

  //XC(func_init)(&gga,  XC_GGA_C_LM2,  XC_POLARIZED);
  //XC(func_init)(&gga2, XC_GGA_C_PW912, XC_POLARIZED);

  /*
  for(i=0; i<=10000; i++){
    double s = 4.0*i/(10000.0);

    XC(gga_x_rpbe_enhance)(gga.gga,  2, s/X2S, &a, &da, &dummy, &d2a);
    XC(gga_x_wc_enhance)  (gga2.gga, 2, s/X2S, &b, &db, &dummy, &d2b);
    XC(gga_x_pbe_enhance) (gga3.gga, 2, s/X2S, &c, &da, &dummy, &d2a);
    XC(gga_x_htbs_enhance)(gga4.gga, 2, s/X2S, &d, &dd, &dummy, &d2d);
    
    printf("%20.14e %20.14e %20.14e %20.14e %20.14e\n", s, a, b, c, d);
  }
  */
  
  for(i=0; i<=10000; i++){
    double rho[2], sigma[3], tau[2], lapl[2];
    double zk,   vrho[2],  vsigma[3];
    double zkp, vrhop[2], vsigmap[3];
    double v2rho2[3],  v2sigma2[6],  v2rhosigma[6];
    double v2rho2p[3], v2sigma2p[6], v2rhosigmap[6];

    rho[0]   = .1 + i/10000.0;
    rho[1]   = 0.2;
    sigma[0] = 0.3;
    sigma[1] = 0.4;
    sigma[2] = 0.00005;

    XC(gga)(&gga,  1, rho, sigma, &zk,  vrho,  vsigma,  v2rho2,  v2rhosigma,  v2sigma2);
    //XC(gga)(&gga2, 1, rho, sigma, &zkp, vrhop, vsigmap, NULL, v2rhosigmap, v2sigma2p);
    
    //fprintf(stderr, "%16.10lf\t%16.10lf\t%16.10lf\n", sigma[0], (rho[0])*zk, vsigma[0]);
    fprintf(stderr, "%16.10lf\t%16.10lf\t%16.10lf\n", rho[0], vrho[0], v2rho2[0]);
    //fprintf(stderr, "%16.10lf\t%16.10lf\t%16.10lf\n", sigma[0], vsigmap[0], v2sigma2p[0]);
  }
}
예제 #15
0
static inline void
read_pressure (GWeatherInfo *info,
	       xmlNodePtr    node)
{
    xmlChar *unit;
    xmlChar *val;
    double hpa;

    /* hPa == mbar */
    unit = xmlGetProp (node, XC("unit"));
    if (unit == NULL || strcmp ((char*)unit, "hPa"))
        return;

    val = xmlGetProp (node, XC("value"));
    if (val == NULL)
	return;

    hpa = g_ascii_strtod ((char*) val, NULL);
    info->priv->pressure = PRESSURE_MBAR_TO_INCH (hpa);
}
예제 #16
0
 // Выводим ребра
  void ShowLoops( int Ind ){
		int i,j;
		for (i=0;i<DimLoops;i++)
		  for (j=0;j<2;j++)
				switch (Ind) {
				  case 0: Loops[i][j]=LT3[i][j]; break;
				  case 1: Loops[i][j]=LC3[i][j]; break;
				  case 2: Loops[i][j]=LO3[i][j]; break;
				  case 3: Loops[i][j]=LT4[i][j]; break;
				  case 4: Loops[i][j]=LO4[i][j]; break;
				  case 5: Loops[i][j]=LL4[i][j]; break;
				  case 6: Loops[i][j]=LC4[i][j]; break;
				  case 7: Loops[i][j]=LC5[i][j]; break;
				  case 8: Loops[i][j]=LC6[i][j]; break;
				  case 9: Loops[i][j]=LI3[i][j]; break;
		   };
		for (i=0;i<DimLoops;i++)
		  line( XC(W[Loops[i][0]-1]),YC(W[Loops[i][0]-1]),
				XC(W[Loops[i][1]-1]),YC(W[Loops[i][1]-1]));
  };
예제 #17
0
static inline void
read_humidity (GWeatherInfo *info,
               xmlNodePtr    node)
{
    xmlChar *unit;
    xmlChar *val;
    double percent;

    unit = xmlGetProp (node, XC("unit"));
    if (unit == NULL || strcmp ((char*)unit, "%"))
        return;

    val = xmlGetProp (node, XC("value"));
    if (val == NULL)
	return;

    percent = g_ascii_strtod ((char*) val, NULL);
    info->priv->humidity = percent;
    info->priv->hasHumidity = TRUE;
}
예제 #18
0
static void
parse_forecast_xml (GWeatherInfo    *master_info,
		    SoupMessageBody *body)
{
    GWeatherInfoPrivate *priv;
    xmlDocPtr doc;
    xmlXPathContextPtr xpath_ctx;
    xmlXPathObjectPtr xpath_result;
    int i;

    priv = master_info->priv;

    doc = xmlParseMemory (body->data, body->length);
    if (!doc)
	return;

    xpath_ctx = xmlXPathNewContext (doc);
    xmlXPathRegisterNs (xpath_ctx, XC("yweather"), XC("http://xml.weather.yahoo.com/ns/rss/1.0"));
    xpath_result = xmlXPathEval (XC("/rss/channel/item/yweather:forecast"), xpath_ctx);

    if (!xpath_result || xpath_result->type != XPATH_NODESET)
	goto out;

    for (i = 0; i < xpath_result->nodesetval->nodeNr; i++) {
	xmlNodePtr node;
	GWeatherInfo *info;

	node = xpath_result->nodesetval->nodeTab[i];
	info = make_info_from_node (master_info, node);

	priv->forecast_list = g_slist_append (priv->forecast_list, info);
    }

    xmlXPathFreeObject (xpath_result);

 out:
    xmlXPathFreeContext (xpath_ctx);
    xmlFreeDoc (doc);
}
예제 #19
0
static inline void
read_wind_speed (GWeatherInfo *info,
		 xmlNodePtr    node)
{
    xmlChar *val;
    double mps;

    val = xmlGetProp (node, XC("mps"));
    if (val == NULL)
	return;

    mps = g_ascii_strtod ((char*) val, NULL);
    info->priv->windspeed = WINDSPEED_MS_TO_KNOTS (mps);
}
예제 #20
0
static inline void
read_wind_direction (GWeatherInfo *info,
		     xmlNodePtr    node)
{
    xmlChar *val;
    int i;

    val = xmlGetProp (node, XC("code"));
    if (val == NULL)
	return;

    for (i = 0; i < G_N_ELEMENTS (wind_directions); i++) {
	if (strcmp ((char*) val, wind_directions[i].name) == 0) {
	    info->priv->wind = wind_directions[i].direction;
	    return;
	}
    }
}
예제 #21
0
void range_separation(int func_id, double & omega, double & alpha, double & beta, bool check) {
  // Defaults
  omega=0.0;
  alpha=0.0;
  beta=0.0;

  if(func_id>0) {
    xc_func_type func;
    if(xc_func_init(&func, func_id, XC_UNPOLARIZED) != 0){
      ERROR_INFO();
      std::ostringstream oss;
      oss << "Functional "<<func_id<<" not found!";
      throw std::runtime_error(oss.str());
    }

    switch(func.info->family)
      {
      case XC_FAMILY_HYB_GGA:
      case XC_FAMILY_HYB_MGGA:
	XC(hyb_cam_coef(&func,&omega,&alpha,&beta));
	break;
      }

    xc_func_end(&func);
  }

  bool ans=is_range_separated(func_id,false);
  if(check) {
    if(ans && omega==0.0) {
      fprintf(stderr,"Error in libxc detected - functional is marked range separated but with vanishing omega!\n");
      printf("Error in libxc detected - functional is marked range separated but with vanishing omega!\n");
    } else if(!ans && omega!=0.0) {
      fprintf(stderr,"Error in libxc detected - functional is not marked range separated but has nonzero omega!\n");
      printf("Error in libxc detected - functional is not marked range separated but has nonzero omega!\n");
    }
  }

  // Work around libxc bug
  if(!ans) {
    omega=0.0;
    beta=0.0;
  }
}
예제 #22
0
파일: test.c 프로젝트: gimunu/octopus_hhg
void test_lda()
{
  XC(func_type) l1, l2, l3;
  int i;
  
  XC(func_init)(&l1, XC_LDA_C_GOMBAS, XC_UNPOLARIZED);
  XC(func_init)(&l2, XC_LDA_C_PW, XC_POLARIZED);
  XC(func_init)(&l3, XC_LDA_X, XC_UNPOLARIZED);

  //XC(lda_x_1d_set_params)(&l1, 0, 1.0);
  //XC(lda_c_1d_csc_set_params)(&l2, 1, 1.0);

  for(i=0; i<=1000; i++){
    double dens, rs, zeta, rho[2];
    double ec1, vc1[2], fxc1[3], kxc1[4];
    double ec2, vc2[2], fxc2[3], kxc2[4];
    double ec3, vc3[2], fxc3[3], kxc3[4];
    
    //rs   = 0.5 + i/500.0;
    //zeta = -1.0 + 2.0*i/1000000000.0;

    //dens = 1.0/(4.0/3.0*M_PI*POW(rs,3)); /* 3D */
    //dens = 1.0/(2.0*rs); /* 1D */

    //rho[0] = dens*(1.0 + zeta)/2.0;
    //rho[1] = dens*(1.0 - zeta)/2.0;

    rho[0] = 0.01 + i/1000.0;
    rho[1] = 0.0;

    //rho[0] = 1.0/(2.0*rs);
    //rho[1] = 0.0;

    //dens = rho[0] + rho[1];

    XC(lda)(&l1, 1, rho, &ec1, vc1, fxc1, kxc1);
    XC(lda)(&l2, 1, rho, &ec2, vc2, NULL, NULL);
    //XC(lda_fxc_fd)(&l2, rho, fxc2);
    //XC(lda_kxc_fd)(&l2, rho, kxc2);

    //rho[0] = dens; rho[1] = 0.0;
    //XC(lda)(&l3, rho, &ec3, vc3, fxc3, kxc3);

    // printf("%e\t%e\t%e\n", dens, (fxc1[0]+2.0*fxc1[1]+fxc1[2])/4.0, fxc3[0]);
    // printf("%e\t%e\t%e\n", dens, (kxc1[0]+3.0*kxc1[1]+3.0*kxc1[2]+kxc1[3])/8.0, kxc3[0]);

    printf("%e\t%e\t%e\n", rho[0], fxc1[0], kxc1[0]);
  }
}
예제 #23
0
파일: pv3if.c 프로젝트: rolk/ug
void pVGRID(float *xyz)
{
  MULTIGRID *mg;
  ELEMENT *e;
  VERTEX *v;
  int i;

  mg = GetCurrentMultigrid();
  ClearVertexMarkers(mg);
  SURFACE_LOOP_BEGIN(mg, e)
  for (i = 0; i < CORNERS_OF_ELEM(e); i++) {
    v = MYVERTEX(CORNER(e, i));
    if (USED(v)) continue;
    SETUSED(v, 1);
    *xyz++ = XC(v);
    *xyz++ = YC(v);
    *xyz++ = ZC(v);
  }
  SURFACE_LOOP_END
}
예제 #24
0
static GWeatherInfo *
make_info_from_node (GWeatherInfo *master_info,
                     xmlNodePtr    node)
{
    GWeatherInfo *info;
    GWeatherInfoPrivate *priv;
    xmlChar *val;

    g_return_val_if_fail (node->type == XML_ELEMENT_NODE, NULL);

    info = _gweather_info_new_clone (master_info);
    priv = info->priv;

    val = xmlGetProp (node, XC("from"));
    priv->current_time = priv->update = date_to_time_t (val, info->priv->location.tz_hint);
    xmlFree (val);

    fill_info_from_node (info, node);

    return info;
}
예제 #25
0
// Print keyword corresponding to functional.
std::string get_keyword(int func_id) {
  // Check if none was specified. This is internal to ERKALE.
  if(func_id==0)
    return "none";

  // Call libxc function
  char *keyword=XC(functional_get_name)(func_id);

  if(keyword==NULL) {
    // Functional id not recognized.
    std::ostringstream oss;
    oss << "\nError: libxc did not recognize functional id "<<func_id<<"!\n";
    throw std::runtime_error(oss.str());
  }

  // Get the keyword
  std::string key(keyword);
  // and free memory allocated by libxc
  free(keyword);

  return key;
}
예제 #26
0
static inline void
read_symbol (GWeatherInfo *info,
	     xmlNodePtr    node)
{
    xmlChar *val;
    GWeatherInfoPrivate *priv = info->priv;
    struct owm_symbol *obj, ref;

    val = xmlGetProp (node, XC("number"));

    ref.symbol = strtol ((char*) val, NULL, 0) - 1;
    obj = bsearch (&ref, symbols, G_N_ELEMENTS (symbols),
                   sizeof (struct owm_symbol), symbol_compare);

    if (obj == NULL) {
        g_warning ("Unknown symbol %d returned from OpenWeatherMap",
                   ref.symbol);
        return;
    }

    priv->valid = TRUE;
    priv->sky = obj->sky;
    priv->cond = obj->condition;
}
예제 #27
0
파일: test.c 프로젝트: gimunu/octopus_hhg
void test_tpss()
{
  XC(func_type) tpss, tpss2;
  XC(func_type) agga;
  int i;

  XC(func_init)(&tpss,  XC_MGGA_X_TPSS, XC_UNPOLARIZED);
  XC(func_init)(&tpss2, XC_MGGA_C_TPSS, XC_UNPOLARIZED);
  //XC(mgga_c_tpss_init)(tpss2.mgga);
  
  for(i=0; i<=1000; i++){
    double rho[2], sigma[3], tau[2], lapl[2];
    double zk,   vrho[2],  vsigma[3],  vtau[2],  vlapl[2];
    double zk2, vrho2[2], vsigma2[3], vtau2[2], vlapl2[2];
    double v2rho2[3], v2sigma2[6], v2lapl2[3], v2tau2[3];
    double v2rhosigma[6], v2rholapl[3], v2rhotau[3];
    double v2sigmalapl[6], v2sigmatau[6], v2lapltau[3];

    rho[0]   = 0.60775363329505661 + i/1000.0;
    rho[1]   = 0.15;
    sigma[0] = 0.0;//1.2032882206468622;
    sigma[1] = 0.11;
    sigma[2] = 0.7;
    tau[0]   = 0.24779036624605069;
    tau[1]   = 0.15;
    lapl[0]  = -18.518421131246519;
    lapl[1]  = 0.12;

    XC(mgga)(&tpss, 1, rho, sigma, lapl, tau, 
    	     &zk,  vrho, vsigma, vlapl, vtau, 
    	     NULL, v2sigma2, v2lapl2, v2tau2, v2rhosigma, v2rholapl, v2rhotau,
	     v2sigmalapl, v2sigmatau, v2lapltau);
    XC(mgga)(&tpss2, 1, rho, sigma, lapl, tau, 
    	     &zk2,  vrho2, vsigma2, vlapl2, vtau2, 
    	     NULL, v2sigma2, v2lapl2, v2tau2, v2rhosigma, v2rholapl, v2rhotau,
	     v2sigmalapl, v2sigmatau, v2lapltau);

    //XC(gga)(&agga, rho,  sigma,
    //&zk,  vrho, vsigma,
    //	    v2rho2, v2rhosigma, v2sigma2);
    fprintf(stderr, "%16.10lf\t%16.10lf\t%16.10lf\n", rho[0], rho[0]*(zk2), vrho[0] + vrho2[0]);
  }
}
예제 #28
0
*/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "util.h"

#define XC_GGA_X_OPTX         110 /* Handy & Cohen OPTX 01                          */

typedef struct{
  FLOAT a, b, gamma;
} gga_x_optx_params;


static void 
gga_x_optx_init(XC(func_type) *p)
{
  assert(p!=NULL && p->params == NULL);
  p->params = malloc(sizeof(gga_x_optx_params));

  XC(gga_x_optx_set_params)(p, 1.05151, 1.43169/X_FACTOR_C, 0.006);
}


void 
XC(gga_x_optx_set_params)(XC(func_type) *p, FLOAT a, FLOAT b, FLOAT gamma)
{
  gga_x_optx_params *params;

  assert(p != NULL && p->params != NULL);
  params = (gga_x_optx_params *) (p->params);
예제 #29
0
  
 You should have received a copy of the GNU Lesser General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <stdio.h>
#include <assert.h>
#include "util.h"

#define XC_GGA_X_WC         118 /* Wu & Cohen */

static FLOAT wc_mu, wc_c;

static void
gga_x_wc_init(XC(func_type) *p_)
{
  wc_mu  = 0.2195149727645171;
  wc_c   = (146.0/2025.0)*(4.0/9.0) - (73.0/405.0)*(2.0/3.0) + (wc_mu - 10.0/81.0);
}

void XC(gga_x_wc_enhance)
  (const XC(func_type) *p, int order, FLOAT x, 
   FLOAT *f, FLOAT *dfdx, FLOAT *d2fdx2, FLOAT *d3fdx3)
{
  const FLOAT kappa = 0.8040;

  FLOAT ss, ss2;
  FLOAT aux1, aux2, f0, df0, d2f0, d3f0, dd;

  ss  = X2S*x;
예제 #30
0
#define XC_HYB_MGGA_XC_PW86B95  442  /* Mixture of PW86 with BC95                        */
#define XC_HYB_MGGA_XC_BB1K     443  /* Mixture of B88 with BC95 from Zhao and Truhlar   */
#define XC_HYB_MGGA_XC_MPW1B95  445  /* Mixture of mPW91 with BC95 from Zhao and Truhlar */
#define XC_HYB_MGGA_XC_MPWB1K   446  /* Mixture of mPW91 with BC95 for kinetics          */
#define XC_HYB_MGGA_XC_X1B95    447  /* Mixture of X with BC95                           */
#define XC_HYB_MGGA_XC_XB1K     448  /* Mixture of X with BC95 for kinetics              */
#define XC_HYB_MGGA_XC_M06_HF   444  /* M06-HF functional of Minnesota                   */
#define XC_HYB_MGGA_XC_M06      449  /* M06 functional of Minnesota                      */
#define XC_HYB_MGGA_XC_M06_2X   450  /* M06-2X functional of Minnesota                   */
#define XC_HYB_MGGA_XC_PW6B95   451  /* Mixture of PW91 with BC95 from Zhao and Truhlar  */
#define XC_HYB_MGGA_XC_PWB6K    452  /* Mixture of PW91 with BC95 from Zhao and Truhlar for kinetics */
#define XC_MGGA_XC_TPSSLYP1W    242  /* Functionals fitted for water */

/*************************************************************/
void
XC(hyb_mgga_xc_m05_init)(XC(func_type) *p)
{
  static int   funcs_id  [2] = {XC_MGGA_X_M05, XC_MGGA_C_M05};
  static FLOAT funcs_coef[2] = {1.0 - 0.28, 1.0};

  XC(mix_init)(p, 2, funcs_id, funcs_coef);
  p->cam_alpha = 0.28;
}

XC(func_info_type) XC(func_info_hyb_mgga_xc_m05) = {
  XC_HYB_MGGA_XC_M05,
  XC_EXCHANGE_CORRELATION,
  "M05 functional of Minnesota",
  XC_FAMILY_HYB_MGGA,
  "Y Zhao, NE Schultz, and DG Truhlar, J. Chem. Phys. 123, 161103 (2005)",
  XC_FLAGS_3D | XC_FLAGS_HAVE_EXC | XC_FLAGS_HAVE_VXC,