Git Product home page Git Product logo

femt2d's People

Contributors

ruboerner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

femt2d's Issues

Excuse me, sir, i have a doubt?

There is a difference between the analytical solution and driverlayered.m about the layered model
This picture is layer model
2020-08-02_10-44

This Python code is analytical method

import math
import cmath
import time


print('====================================');
print('1D MAGNETOTELLURIC MODELLING PROGRAM');
print('====================================');
print('    LAST UPDATED 17TH DECEMBER 2013 ');
print('    DEVELOPED BY ANDREW PETHICK     ');
print('      WWW.DIGITIALEARTHLAB.COM      ');
print('====================================');
print('');
print('licensed under WTFPL')
print('');
start = time.clock();

mu = 4*math.pi*1E-7; #Magnetic Permeability (H/m)
resistivities = [100, 1100, 600,10];
thicknesses = [1000,2000,3400];
n = len(resistivities);

import numpy as np
l = np.logspace(-2,3,24)
sl = (1/l).tolist()

frequencies = sl;

print('freq     \t ares   \t\t\t   phase');
for frequency in frequencies:   
    w =  2*math.pi*frequency;       
    impedances = list(range(n));
    #compute basement impedance
    impedances[n-1] = cmath.sqrt(w*mu*resistivities[n-1]*1j);


   
    for j in range(n-2,-1,-1):
        resistivity = resistivities[j];
        thickness = thicknesses[j];
  
        # 3. Compute apparent resistivity from top layer impedance
        #Step 2. Iterate from bottom layer to top(not the basement) 
        # Step 2.1 Calculate the intrinsic impedance of current layer
        dj = cmath.sqrt((w * mu * (1.0/resistivity))*1j);
        wj = dj * resistivity;
        # Step 2.2 Calculate Exponential factor from intrinsic impedance
        ej = cmath.exp(-2*thickness*dj);                     
    
        # Step 2.3 Calculate reflection coeficient using current layer
        #          intrinsic impedance and the below layer impedance
        belowImpedance = impedances[j + 1];
        rj = (wj - belowImpedance)/(wj + belowImpedance);
        re = rj*ej; 
        Zj = wj * ((1 - re)/(1 + re));
        impedances[j] = Zj;    

    # Step 3. Compute apparent resistivity from top layer impedance
    Z = impedances[0];
    absZ = abs(Z);
    apparentResistivity = (absZ * absZ)/(mu * w);
    phase = math.atan2(Z.imag, Z.real)
    print(frequency, '\t', apparentResistivity, '\t', phase);
    
print('');
print('time taken = ', time.clock() - start, 's');

I modified your driverlayered.m to satisfy this model

clearvars();
close('all');
clc();

%%
meshFile = 'meshes/layeredz1.1';

mesh = mesh.getMesh('filename', meshFile, ...
    'format', 'triangle', ...
    'shift', 0, 'scale', 1, 'verbose', true);

%%
figure(1);
plot.plotMT('mesh', mesh, 'section', 'subdomains');

%%
periods = logspace(-2, 3, 24);
freq = 1 ./ periods;
omega = 2 * pi * freq;
mu0 = pi * 4e-7;

sigma = 1.0 ./ [10, 600, 1100, 100, 1e9];
mu = [1, 1, 1, 1,1];
sigmaBCL = 1.0 ./ [100,1100, 600,10];
muL = [1, 1, 1, 1];
thkBCL = [1e3, 2e3,3.4e3];

xobs = tools.asRow(-1e4:1e3:1e4);
obs = [xobs; zeros(size(xobs)) + 0.1];

%%
fem = fe.FEMproblem('mesh', mesh, ...
    'elementtype', 'Lagrange', ...
    'order', 2, 'dimension', 2, ...
    'sigma', sigma, 'mu', mu, ...
    'application', 'MT', ...
    'polarization', 'both', ...
    'frequency', freq(1), ...
    'verbose', true);

%%
figure(2);
plot.plotMT('fem', fem, 'section', 'conductivity');

%%
fem = fe.getQ(fem, obs);
% fem = fe.getQfull(fem);

fem = fe.FEMassemble(fem, 'output', 'matrices', ...
    'verbose', false);

solution.rhoaxy = zeros(length(xobs), length(periods));
solution.rhoayx = zeros(length(xobs), length(periods));
solution.phixy = zeros(length(xobs), length(periods));
solution.phiyx = zeros(length(xobs), length(periods));


for k = 1:length(freq)
    freq = 1.0 / periods(k);

    
    fem = fe.removeDirichlet(fem, ...
        'sigmaBC', sigmaBCL, ...
        'thicknessBC', thkBCL, ...
        'frequency', freq);

    sol = fe.FEMsolve(fem, 'verbose', false);

    sol = mt.postProcessing(fem, sol);
    solution.rhoaxy(:, k) = sol.rhoaxy;
    solution.rhoayx(:, k) = sol.rhoayx;
    solution.phixy(:, k) = sol.phixy;
    solution.phiyx(:, k) = sol.phiyx;
end

%%
figure(3)
plot.plotMT('fem', fem, 'sol', solution, ...
    'sounding', 'rhoa+phase', ...
    'station', 12, 'periods', periods);

I modified your Layered_Halfspace.ipynb to mesh this model

import pygimli as pg
import matplotlib.pyplot as plt
import pygimli.meshtools as mt
import os
from os import system
import numpy as np

                 quality=33, 
                 triangle='triangle',
                 verbose=True):
    
    filebody = filename.replace('.poly', '')

    syscal = triangle + ' -pq' + str(quality)
    syscal += 'Aa ' + filebody + '.poly'
 
    if verbose:
        print(syscal)

    system(syscal)

world = mt.createWorld(start=[-4e5, -4e5], 
                       end=[4e5, 4e5], 
                       layers=[0, 1e3, 3e3,6.4e3], 
                       area=[0, 1e7, 1e6, 1e6,0],
                       marker=[1, 2, 3, 4,5],
                       worldMarker=False)

geom = world

ax, _ = pg.show(geom, 
                showNodes=False, 
                boundaryMarker=False)
ax.set_ylim(ax.get_ylim()[::-1]);

mt.exportPLC(geom,
             '../meshes/layeredz1.poly', 
             float_format='.8e')

print(geom)

callTriangle('../meshes/layeredz1.poly', 
             quality=34.2,
             verbose=False)

mesh = mt.createMesh(geom, quality=34.2)
ax, _ = pg.show(mesh)
ax.set_ylim(ax.get_ylim()[::-1]);

Then I use ./triangle -pq34.2Aa layeredz1.poly in the terminal to generate layeredz1.1.ele,layeredz1.1.node,layeredz1.1.poly.
this zip file contain these four files.
layeredz1.zip

this is analytical solution
2020-08-02_11-29

this solution is after modifying the driverlayered.m
four_layers

How to creat *.node ,*.ele,and *.1.ploy file?

Sir,I modified your notebook code to create my mesh of model,but I do not know how to creat *.node , *.ele, and *.1.ploy files,Please help me,thank a lot!

mt.exportPLC(geom,
'../meshes/layered.poly',
float_format='.8e')

print(geom)

callTriangle('../meshes/layered.poly',
quality=34.2,
verbose=False)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.