Esempio n. 1
0
void
LinearIsotropicMaterial::computeProperties()
{
  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
  {
    Real alpha = computeAlpha();

    _local_elasticity_tensor->calculate(_qp);

    _elasticity_tensor[_qp] = *_local_elasticity_tensor;

    SymmTensor strn(_grad_disp_x[_qp](0),
                    _grad_disp_y[_qp](1),
                    _grad_disp_z[_qp](2),
                    0.5 * (_grad_disp_x[_qp](1) + _grad_disp_y[_qp](0)),
                    0.5 * (_grad_disp_y[_qp](2) + _grad_disp_z[_qp](1)),
                    0.5 * (_grad_disp_z[_qp](0) + _grad_disp_x[_qp](2)));

    // Add in Isotropic Thermal Strain
    if (_has_temp)
    {
      Real isotropic_strain = alpha * (_temp[_qp] - _t_ref);

      strn.addDiag(-isotropic_strain);

      _d_strain_dT.zero();
      _d_strain_dT.addDiag(-alpha);
    }

    SymmTensor strain(strn);

    computeStress(strain, _stress[_qp]);
  }
}
void
LinearIsotropicMaterial::computeProperties()
{
  for (_qp=0; _qp < _qrule->n_points(); ++_qp)
  {
      Real alpha = computeAlpha();

    _local_elasticity_tensor->calculate(_qp);

    _elasticity_tensor[_qp] = *_local_elasticity_tensor;


    SymmTensor strn( _grad_disp_x[_qp](0),
                     _grad_disp_y[_qp](1),
                     _grad_disp_z[_qp](2),
                     0.5*(_grad_disp_x[_qp](1)+_grad_disp_y[_qp](0)),
                     0.5*(_grad_disp_y[_qp](2)+_grad_disp_z[_qp](1)),
                     0.5*(_grad_disp_z[_qp](0)+_grad_disp_x[_qp](2)) );

    // Add in Isotropic Thermal Strain
    if (_has_temp)
    {
      Real isotropic_strain = alpha * (_temp[_qp] - _t_ref);

      strn.addDiag( -isotropic_strain );

      _d_strain_dT.zero();
      _d_strain_dT.addDiag( -alpha );

    }

    SymmTensor v_strain(0);
    SymmTensor dv_strain_dT(0);
    for (unsigned int i(0); i < _volumetric_models.size(); ++i)
    {
      _volumetric_models[i]->modifyStrain(_qp, 1, v_strain, dv_strain_dT);
    }
    SymmTensor strain( v_strain );
    strain *= _dt;
    strain += strn;

    dv_strain_dT *= _dt;
    _d_strain_dT += dv_strain_dT;

    computeStress(strain, _stress[_qp]);

  }
}
Esempio n. 3
0
string StringUtil::trimCopy(const string& str)
{
	string strn(str);
	trim(strn);
	return strn;
}
Esempio n. 4
0
string StringUtil::capitalizedCopy(const string& str)
{
	string strn(str);
	capitalized(strn);
	return strn;
}
Esempio n. 5
0
int phypp_main(int argc, char* argv[]) {
    if (argc < 2) {
        print("usage: make_shifts <ob_filter> [options]");
        return 0;
    }

    vec1u exclude;
    std::string helper;

    read_args(argc-1, argv+1, arg_list(exclude, helper));

    if (helper.empty()) {
        error("please provide the name of (one of) the helper target you used to "
            "calibrate the shifts (helper=...)");
        return 1;
    }

    helper = tolower(helper);

    std::string scis = argv[1];

    vec1d cent_ra, cent_dec;
    file::read_table("centroid_helper.txt", 0, cent_ra, cent_dec);

    vec1u ids = uindgen(cent_ra.size())+1;
    vec1u idex = where(is_any_of(ids, exclude));
    inplace_remove(ids, idex);
    inplace_remove(cent_ra, idex);
    inplace_remove(cent_dec, idex);

    std::ofstream cmb("combine.sof");

    vec1d shx, shy;

    vec1d x0, y0;
    bool first_line = true;
    uint_t nexp = 0;

    for (uint_t i : range(ids)) {
        std::string dir = scis+align_right(strn(ids[i]), 2, '0')+"/";
        print(dir);

        vec1s files = dir+file::list_files(dir+"sci_reconstructed*-sci.fits");
        inplace_sort(files);

        // Find out which exposures contain the helper target from which the
        // shifts were calibrated
        vec1u ignore;
        for (uint_t k : range(files)) {
            std::string f = files[k];
            fits::generic_file fcubes(f);

            vec1s arms(24);
            bool badfile = false;
            for (uint_t u : range(24)) {
                if (!fcubes.read_keyword("ESO OCS ARM"+strn(u+1)+" NAME", arms[u])) {
                    note("ignoring invalid file '", f, "'");
                    note("missing keyword 'ESO OCS ARM"+strn(u+1)+" NAME'");
                    ignore.push_back(k);
                    badfile = true;
                    break;
                }
            }

            if (badfile) continue;

            arms = tolower(trim(arms));

            vec1u ida = where(arms == helper);
            if (ida.empty()) {
                ignore.push_back(k);
            } else if (x0.empty()) {
                // Get astrometry of IFUs from first exposure
                // NB: assumes the rotation is the same for all exposures,
                // which is anyway what kmos_combine does later on.
                fcubes.reach_hdu(ida[0]+1);
                fits::wcs astro(fcubes.read_header());
                fits::ad2xy(astro, cent_ra, cent_dec, x0, y0);
            }
        }

        inplace_remove(files, ignore);

        if (files.empty()) {
            warning("folder ", dir, " does not contain any usable file");
            continue;
        }

        for (std::string f : files) {
            cmb << f << " COMMAND_LINE\n";
            ++nexp;
        }

        double dox = x0[0] - x0[i], doy = y0[0] - y0[i];

        if (first_line) {
            // Ommit first line which has, by definition, no offset
            first_line = false;
        } else {
            shx.push_back(dox);
            shy.push_back(doy);
        }

        if (file::exists(dir+"helpers/shifts.txt")) {
            vec1d tx, ty;
            file::read_table(dir+"helpers/shifts.txt", 0, tx, ty);
            for (uint_t j : range(tx)) {
                shx.push_back(dox+tx[j]);
                shy.push_back(doy+ty[j]);
            }
        }
    }

    note("found ", nexp, " exposures");

    cmb.close();

    auto truncate_decimals = vectorize_lambda([](double v, uint_t nd) {
        return long(v*e10(nd))/e10(nd);
    });

    shx = truncate_decimals(shx, 2);
    shy = truncate_decimals(shy, 2);

    file::write_table("shifts.txt", 10, shx, shy);

    return 0;
}